Skip to content

Commit 0cfd2a6

Browse files
committed
CI: cache ninja build
1 parent 3b10332 commit 0cfd2a6

File tree

3 files changed

+36
-18
lines changed

3 files changed

+36
-18
lines changed

.github/workflows/ci.yml

+32-18
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
if: steps.build-cache.outputs.cache-hit != 'true'
7676
run: cargo build --manifest-path rewatch/Cargo.toml --target ${{matrix.rust-target}} --release
7777

78-
- name: Copy exe to platform bin dirs
78+
- name: Copy rewatch exe to platform bin dir
7979
run: |
8080
cp rewatch/target/${{matrix.rust-target}}/release/rewatch${{ runner.os == 'Windows' && '.exe' || '' }} rewatch
8181
node ./scripts/copyExes.js -rewatch
@@ -121,8 +121,10 @@ jobs:
121121
- name: Get artifact dir name
122122
run: node .github/workflows/get_artifact_dir_name.js
123123

124-
- name: Copy exes to platform bin dirs
125-
run: node ./scripts/copyExes.js -compiler
124+
- name: Copy exes to platform bin dir
125+
run: |
126+
node ./scripts/copyExes.js -compiler
127+
node ./scripts/copyExes.js -ninja
126128
127129
- name: "Upload artifacts: binaries"
128130
uses: actions/upload-artifact@v4
@@ -164,6 +166,11 @@ jobs:
164166
with:
165167
fetch-depth: 2 # to be able to check for changes in subfolder jscomp/syntax later
166168

169+
- name: Use Node.js
170+
uses: actions/setup-node@v4
171+
with:
172+
node-version: 18
173+
167174
- name: Get artifact dir name
168175
run: node .github/workflows/get_artifact_dir_name.js
169176

@@ -175,11 +182,6 @@ jobs:
175182
packages: bubblewrap darcs g++-multilib gcc-multilib mercurial musl-tools rsync
176183
version: v1
177184

178-
- name: Setup Python for ninja build
179-
uses: actions/setup-python@v5
180-
with:
181-
python-version: '3.10'
182-
183185
# matrix.ocaml_compiler may contain commas
184186
- name: Get OPAM cache key
185187
shell: bash
@@ -284,32 +286,44 @@ jobs:
284286
if: runner.os == 'Linux'
285287
run: opam exec -- dune build --display quiet --profile static
286288

287-
- name: Use Node.js
288-
uses: actions/setup-node@v4
289-
with:
290-
node-version: 18
291-
292289
- name: Install npm packages
293290
run: npm ci --ignore-scripts
294291

292+
- name: Copy compiler exes to platform bin dir
293+
run: node ./scripts/copyExes.js -compiler
294+
295+
- name: Restore ninja build cache
296+
id: ninja-build-cache
297+
uses: actions/cache@v4
298+
with:
299+
path: ${{ env.artifact_dir_name }}/ninja.exe
300+
key: ninja-build-v1-${{ matrix.os }}-${{ hashFiles('ninja/src/**') }}
301+
302+
- name: Setup Python for ninja build
303+
if: steps.ninja-build-cache.outputs.cache-hit != 'true'
304+
uses: actions/setup-python@v5
305+
with:
306+
python-version: '3.10'
307+
295308
- name: Setup MSVC for ninja build (Windows)
296-
if: runner.os == 'Windows'
309+
if: steps.ninja-build-cache.outputs.cache-hit != 'true' && runner.os == 'Windows'
297310
uses: TheMrMilchmann/setup-msvc-dev@v3
298311
with:
299312
arch: x64
300313

301314
- name: Build ninja
302-
if: runner.os != 'Linux'
315+
if: steps.ninja-build-cache.outputs.cache-hit != 'true' && runner.os != 'Linux'
303316
run: node scripts/buildNinjaBinary.js
304317

305318
- name: Build ninja (Linux static)
306-
if: runner.os == 'Linux'
319+
if: steps.ninja-build-cache.outputs.cache-hit != 'true' && runner.os == 'Linux'
307320
env:
308321
LDFLAGS: -static
309322
run: node scripts/buildNinjaBinary.js
310323

311-
- name: Copy exes to platform bin dirs
312-
run: node ./scripts/copyExes.js -compiler
324+
- name: Copy ninja exe to platform bin dir
325+
if: steps.ninja-build-cache.outputs.cache-hit != 'true'
326+
run: node ./scripts/copyExes.js -ninja
313327

314328
- name: "Check if syntax subfolder has changed"
315329
id: syntax-diff

Makefile

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ rewatch:
2222

2323
ninja/ninja:
2424
./scripts/buildNinjaBinary.js
25+
./scripts/copyExes.js -ninja
2526

2627
ninja: ninja/ninja
2728

scripts/copyExes.js

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ if (process.argv.includes("-all") || process.argv.includes("-compiler")) {
3535
copyExe(duneBinDir, "rescript");
3636
copyExe(duneBinDir, "bsc");
3737
copyExe(duneBinDir, "bsb_helper");
38+
}
39+
40+
if (process.argv.includes("-all") || process.argv.includes("-ninja")) {
3841
copyExe(ninjaDir, "ninja");
3942
}
4043

0 commit comments

Comments
 (0)