@@ -54,22 +54,32 @@ jobs:
54
54
- name : Checkout
55
55
uses : actions/checkout@v4
56
56
57
+ - name : Restore build cache
58
+ id : build-cache
59
+ uses : actions/cache@v4
60
+ with :
61
+ path : rewatch/target
62
+ key : rewatch-build-${{ matrix.rust-target }}-${{ hashFiles('rewatch/src/**', 'rewatch/Cargo.lock') }}
63
+
57
64
- name : Install musl gcc
58
- if : runner.os == 'Linux'
59
- run : sudo apt-get install -y musl-tools
65
+ if : steps.build-cache.outputs.cache-hit != 'true' && runner.os == 'Linux'
66
+ run : sudo apt-get install -y --no-install-recommends musl-tools
60
67
61
68
- name : Set up sccache
69
+ if : steps.build-cache.outputs.cache-hit != 'true'
62
70
uses :
mozilla-actions/[email protected]
63
71
with :
64
72
version : " v0.8.0"
65
73
66
74
- name : Install rust toolchain
75
+ if : steps.build-cache.outputs.cache-hit != 'true'
67
76
uses : dtolnay/rust-toolchain@master
68
77
with :
69
78
toolchain : stable
70
79
targets : ${{matrix.rust-target}}
71
80
72
81
- name : Build rewatch
82
+ if : steps.build-cache.outputs.cache-hit != 'true'
73
83
run : cargo build --manifest-path rewatch/Cargo.toml --target ${{matrix.rust-target}} --release
74
84
75
85
- name : Get artifact dir name
@@ -106,7 +116,7 @@ jobs:
106
116
- name : Build ninja binary
107
117
uses : docker://ghcr.io/rescript-lang/rescript-ci-build:alpine-3.20-ocaml-5.2.0-01
108
118
with :
109
- args : sh -c "cd ninja && LDFLAGS=-static python3 configure.py --bootstrap"
119
+ args : sh -c "cd ninja && LDFLAGS=-static python configure.py --bootstrap"
110
120
111
121
- name : " Upload artifacts"
112
122
uses : actions/upload-artifact@v4
@@ -213,17 +223,44 @@ jobs:
213
223
chmod +x rewatch/rewatch
214
224
chmod +x _build/install/default/bin/*
215
225
226
+ - name : Install dependencies (Linux)
227
+ if : runner.os == 'Linux'
228
+
229
+ with :
230
+ # See https://github.com/ocaml/setup-ocaml/blob/b2105f9/packages/setup-ocaml/src/unix.ts#L9
231
+ packages : bubblewrap darcs g++-multilib gcc-multilib mercurial musl-tools rsync
232
+ version : v1
233
+
234
+ - name : Setup Python for ninja build
235
+ uses : actions/setup-python@v5
236
+ with :
237
+ python-version : ' 3.10'
238
+
239
+ - name : Restore OPAM environment
240
+ id : cache-opam-env
241
+ uses : actions/cache/restore@v4
242
+ with :
243
+ path : |
244
+ ${{ runner.tool_cache }}/opam
245
+ ~/.opam
246
+ _opam
247
+ .opam-path
248
+ .opam-env
249
+ D:\cygwin
250
+ D:\.opam
251
+ key : opam-env-v8-${{ matrix.os }}-${{ hashFiles('dune-project') }}
252
+
216
253
- name : Use OCaml ${{matrix.ocaml_compiler}}
217
254
uses : ocaml/setup-ocaml@v2
218
- if : matrix.os != 'windows-latest'
255
+ if : steps.cache-opam-env.outputs.cache-hit != 'true' && matrix.os != 'windows-latest'
219
256
with :
220
257
ocaml-compiler : ${{matrix.ocaml_compiler}}
221
258
opam-pin : false
222
259
opam-depext : false
223
260
224
- - name : Use OCaml ${{matrix.ocaml_compiler}} (Win )
261
+ - name : Use OCaml ${{matrix.ocaml_compiler}} (Windows )
225
262
uses : ocaml/setup-ocaml@v2
226
- if : matrix.os == 'windows-latest'
263
+ if : steps.cache-opam-env.outputs.cache-hit != 'true' && matrix.os == 'windows-latest'
227
264
with :
228
265
ocaml-compiler : ocaml-variants.5.2.0+options,ocaml-option-mingw
229
266
opam-pin : false
@@ -233,10 +270,74 @@ jobs:
233
270
sunset: https://github.com/ocaml-opam/opam-repository-mingw.git#sunset
234
271
default: https://github.com/ocaml/opam-repository.git
235
272
236
- - name : " Install OPAM dependencies"
273
+ - name : Get OPAM environment
274
+ if : steps.cache-opam-env.outputs.cache-hit != 'true'
275
+ run : |
276
+ command -v opam | tee .opam-path
277
+ opam env > .opam-env
278
+
279
+ - name : Install OPAM dependencies
280
+ if : steps.cache-opam-env.outputs.cache-hit != 'true'
237
281
run : opam install . --deps-only
238
282
239
- - name : " Build compiler"
283
+ - name : Cache OPAM environment
284
+ if : steps.cache-opam-env.outputs.cache-hit != 'true'
285
+ uses : actions/cache/save@v4
286
+ with :
287
+ path : |
288
+ ${{ runner.tool_cache }}/opam
289
+ ~/.opam
290
+ _opam
291
+ .opam-path
292
+ .opam-env
293
+ D:\cygwin
294
+ D:\.opam
295
+ key : opam-env-v8-${{ matrix.os }}-${{ hashFiles('dune-project') }}
296
+
297
+ - name : Use cached OPAM environment
298
+ if : steps.cache-opam-env.outputs.cache-hit == 'true'
299
+ run : |
300
+ # https://github.com/ocaml/setup-ocaml/blob/b2105f9/packages/setup-ocaml/src/installer.ts#L33
301
+ echo "OPAMVERBOSE=$RUNNER_DEBUG" >> "$GITHUB_ENV"
302
+ echo "OPAMCOLOR=always" >> "$GITHUB_ENV"
303
+ echo "OPAMCONFIRMLEVEL=unsafe-yes" >> "$GITHUB_ENV"
304
+ echo "OPAMERRLOGLEN=0" >> "$GITHUB_ENV"
305
+ echo "OPAMPRECISETRACKING=1" >> "$GITHUB_ENV"
306
+ echo "OPAMYES=1" >> "$GITHUB_ENV"
307
+
308
+ if [[ "$RUNNER_OS" != "Windows" ]]; then
309
+ echo "OPAMROOT=$HOME/.opam" >> "$GITHUB_ENV"
310
+ else
311
+ echo "OPAMROOT=D:\\.opam" >> "$GITHUB_ENV"
312
+ fi
313
+
314
+ if [[ "$RUNNER_OS" != "Windows" ]]; then
315
+ OPAM_PATH="$(cat .opam-path)"
316
+ chmod +x "$OPAM_PATH"
317
+ dirname "$OPAM_PATH" >> "$GITHUB_PATH"
318
+
319
+ else
320
+ fsutil behavior query SymlinkEvaluation
321
+ fsutil behavior set symlinkEvaluation R2L:1 R2R:1
322
+ fsutil behavior query SymlinkEvaluation
323
+
324
+ CYGWIN="winsymlinks:native"
325
+ CYGWIN_ROOT="D:\\cygwin"
326
+ CYGWIN_ROOT_BIN="D:\\cygwin\\bin"
327
+ CYGWIN_ROOT_WRAPPERBIN="D:\\cygwin\\wrapperbin"
328
+
329
+ echo "HOME=$USERPROFILE" >> "$GITHUB_ENV"
330
+ echo "MSYS=winsymlinks:native" >> "$GITHUB_ENV"
331
+ echo "CYGWIN=$CYGWIN" >> "$GITHUB_ENV"
332
+ echo "CYGWIN_ROOT=$CYGWIN_ROOT" >> "$GITHUB_ENV"
333
+ echo "CYGWIN_ROOT_BIN=$CYGWIN_ROOT_BIN" >> "$GITHUB_ENV"
334
+ echo "CYGWIN_ROOT_WRAPPERBIN=$CYGWIN_ROOT_WRAPPERBIN" >> "$GITHUB_ENV"
335
+
336
+ echo "$CYGWIN_ROOT_WRAPPERBIN" >> "$GITHUB_PATH"
337
+ fi
338
+ shell : bash
339
+
340
+ - name : Build compiler
240
341
if : runner.os != 'Linux'
241
342
run : opam exec -- dune build --display quiet --profile release
242
343
@@ -248,7 +349,7 @@ jobs:
248
349
- name : Install npm packages
249
350
run : npm ci --ignore-scripts
250
351
251
- - name : " Windows: Use MSVC for ninja build"
352
+ - name : Setup MSVC for ninja build (Windows)
252
353
if : runner.os == 'Windows'
253
354
uses : TheMrMilchmann/setup-msvc-dev@v3
254
355
with :
@@ -304,10 +405,6 @@ jobs:
304
405
run : node scripts/ciTest.js -mocha -theme -format
305
406
306
407
# Build the playground compiler on the fastest runner (ubuntu-latest)
307
- - name : Install JSOO
308
- if : matrix.os == 'ubuntu-latest'
309
- run : opam install js_of_ocaml.5.8.1
310
-
311
408
- name : Build playground compiler
312
409
if : matrix.os == 'ubuntu-latest'
313
410
run : |
0 commit comments