Skip to content

Commit 92dd71f

Browse files
committed
fix cache lifecycle
1 parent 71a73eb commit 92dd71f

File tree

1 file changed

+22
-42
lines changed

1 file changed

+22
-42
lines changed

.github/workflows/ci.yml

Lines changed: 22 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -231,27 +231,29 @@ jobs:
231231
packages: bubblewrap darcs g++-multilib gcc-multilib mercurial musl-tools rsync
232232
version: v1
233233

234-
- name: Restore OPAM tool
235-
id: cache-opam-tool
234+
- name: Restore OPAM environment
235+
id: cache-opam-env
236236
uses: actions/cache/restore@v4
237237
with:
238238
path: |
239239
${{ runner.tool_cache }}/opam
240240
~/.opam
241241
_opam
242-
key: opam-tool-v2-${{ matrix.os }}-${{ hashFiles('dune-project') }}
242+
.opam-path
243+
.opam-env
244+
key: opam-env-v3-${{ matrix.os }}-${{ hashFiles('dune-project') }}
243245

244246
- name: Use OCaml ${{matrix.ocaml_compiler}}
245247
uses: ocaml/setup-ocaml@v2
246-
if: steps.cache-opam-tool.outputs.cache-hit != 'true' && matrix.os != 'windows-latest'
248+
if: steps.cache-opam-env.outputs.cache-hit != 'true' && matrix.os != 'windows-latest'
247249
with:
248250
ocaml-compiler: ${{matrix.ocaml_compiler}}
249251
opam-pin: false
250252
opam-depext: false
251253

252254
- name: Use OCaml ${{matrix.ocaml_compiler}} (Win)
253255
uses: ocaml/setup-ocaml@v2
254-
if: steps.cache-opam-tool.outputs.cache-hit != 'true' && matrix.os == 'windows-latest'
256+
if: steps.cache-opam-env.outputs.cache-hit != 'true' && matrix.os == 'windows-latest'
255257
with:
256258
ocaml-compiler: ocaml-variants.5.2.0+options,ocaml-option-mingw
257259
opam-pin: false
@@ -261,22 +263,8 @@ jobs:
261263
sunset: https://github.com/ocaml-opam/opam-repository-mingw.git#sunset
262264
default: https://github.com/ocaml/opam-repository.git
263265
264-
- name: Install OPAM dependencies
265-
if: steps.cache-opam-tool.outputs.cache-hit != 'true'
266-
run: opam install . --deps-only
267-
268-
- name: Save OPAM tool
269-
if: steps.cache-opam-tool.outputs.cache-hit != 'true'
270-
uses: actions/cache/save@v4
271-
with:
272-
path: |
273-
${{ runner.tool_cache }}/opam
274-
~/.opam
275-
_opam
276-
key: opam-tool-v2-${{ matrix.os }}-${{ hashFiles('dune-project') }}
277-
278-
- name: Get OPAM env
279-
if: steps.cache-opam-tool.outputs.cache-hit != 'true'
266+
- name: Get OPAM environment
267+
if: steps.cache-opam-env.outputs.cache-hit != 'true'
280268
run: |
281269
if [[ "$RUNNER_OS" == "Windows" ]]; then
282270
which opam.exe > .opam-path
@@ -286,40 +274,32 @@ jobs:
286274
opam env > .opam-env
287275
shell: bash
288276

289-
- name: Save OPAM env
290-
id: cache-opam-env
291-
if: steps.cache-opam-tool.outputs.cache-hit != 'true'
292-
uses: actions/cache/save@v4
293-
with:
294-
path: |
295-
.opam-path
296-
.opam-env
297-
key: opam-env-v2-${{ matrix.os }}
277+
- name: Install OPAM dependencies
278+
if: steps.cache-opam-env.outputs.cache-hit != 'true'
279+
run: opam install . --deps-only
298280

299-
- name: Restore OPAM env
300-
if: steps.cache-opam-tool.outputs.cache-hit == 'true'
301-
uses: actions/cache/restore@v4
281+
- name: Cache OPAM environment
282+
if: steps.cache-opam-env.outputs.cache-hit != 'true'
283+
uses: actions/cache/save@v4
302284
with:
303285
path: |
286+
${{ runner.tool_cache }}/opam
287+
~/.opam
288+
_opam
304289
.opam-path
305290
.opam-env
306-
key: opam-env-v2-${{ matrix.os }}
291+
key: opam-env-v3-${{ matrix.os }}-${{ hashFiles('dune-project') }}
307292

308-
- name: Use cached OPAM env - $PATH
309-
if: steps.cache-opam-tool.outputs.cache-hit == 'true'
293+
- name: Use cached OPAM environment
294+
if: steps.cache-opam-env.outputs.cache-hit == 'true'
310295
run: |
311296
OPAM_PATH="$(cat .opam-path)"
312297
chmod +x "$OPAM_PATH"
313298
dirname "$OPAM_PATH" >> "$GITHUB_PATH"
314-
shell: bash
315-
316-
- name: Use cached OPAM env - Environment variables
317-
if: steps.cache-opam-tool.outputs.cache-hit == 'true'
318-
run: |
319299
sed "s/'//g; s/; export .*//g" .opam-env >> "$GITHUB_ENV"
320300
shell: bash
321301

322-
- name: "Build compiler"
302+
- name: Build compiler
323303
if: runner.os != 'Linux'
324304
run: opam exec -- dune build --display quiet --profile release
325305

0 commit comments

Comments
 (0)