@@ -213,17 +213,24 @@ jobs:
213
213
chmod +x rewatch/rewatch
214
214
chmod +x _build/install/default/bin/*
215
215
216
+ - name : Restore OPAM env
217
+ id : cache-opam-env
218
+ uses : actions/cache/restore@v4
219
+ with :
220
+ path : ~/.opam
221
+ key : opam-env-${{ runner.os }}-${{ hashFiles('dune-project') }}
222
+
216
223
- name : Use OCaml ${{matrix.ocaml_compiler}}
217
224
uses : ocaml/setup-ocaml@v2
218
- if : matrix.os != 'windows-latest'
225
+ if : steps.cache-opam-env.outputs.cache-hit != 'true' && matrix.os != 'windows-latest'
219
226
with :
220
227
ocaml-compiler : ${{matrix.ocaml_compiler}}
221
228
opam-pin : false
222
229
opam-depext : false
223
230
224
231
- name : Use OCaml ${{matrix.ocaml_compiler}} (Win)
225
232
uses : ocaml/setup-ocaml@v2
226
- if : matrix.os == 'windows-latest'
233
+ if : steps.cache-opam-env.outputs.cache-hit != 'true' && matrix.os == 'windows-latest'
227
234
with :
228
235
ocaml-compiler : ocaml-variants.5.2.0+options,ocaml-option-mingw
229
236
opam-pin : false
@@ -234,8 +241,46 @@ jobs:
234
241
default: https://github.com/ocaml/opam-repository.git
235
242
236
243
- name : " Install OPAM dependencies"
244
+ if : steps.cache-opam-env.outputs.cache-hit != 'true'
237
245
run : opam install . --deps-only
238
246
247
+ - name : Cache OPAM env
248
+ if : steps.cache-opam-env.outputs.cache-hit != 'true'
249
+ uses : actions/cache/save@v4
250
+ with :
251
+ path : ~/.opam
252
+ key : opam-env-${{ runner.os }}-${{ hashFiles('dune-project') }}
253
+
254
+ - name : Get OPAM path
255
+ if : steps.cache-opam-env.outputs.cache-hit != 'true'
256
+ run : |
257
+ which opam > .opam-path
258
+
259
+ - name : Cache OPAM path
260
+ id : cache-opam-path
261
+ if : steps.cache-opam-env.outputs.cache-hit != 'true'
262
+ uses : actions/cache/save@v4
263
+ with :
264
+ path : .opam-path
265
+ key : opam-path-${{ runner.os }}
266
+
267
+ - name : Restore OPAM path
268
+ if : steps.cache-opam-env.outputs.cache-hit == 'true'
269
+ uses : actions/cache/restore@v4
270
+ with :
271
+ path : .opam-path
272
+ key : opam-path-${{ runner.os }}
273
+
274
+ - name : Use cached OPAM env
275
+ if : steps.cache-opam-env.outputs.cache-hit == 'true'
276
+ run : |
277
+ cat .opam-path >> $GITHUB_PATH
278
+
279
+ - name : Use cached OPAM env
280
+ if : steps.cache-opam-env.outputs.cache-hit == 'true'
281
+ run : |
282
+ opam env | sed "s/'//g; s/; export .*//g" >> $GITHUB_ENV
283
+
239
284
- name : " Build compiler"
240
285
if : runner.os != 'Linux'
241
286
run : opam exec -- dune build --display quiet --profile release
0 commit comments