Skip to content

Commit 7078241

Browse files
authored
Merge pull request #49 from ocsigen/ci/cache-opam-switch
ci(doc): cache the opam switch to skip recompiling the dependency tree
2 parents 52a4011 + 3dc0935 commit 7078241

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

.github/workflows/doc.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,26 @@ jobs:
3131
uses: ocaml/setup-ocaml@v3
3232
with:
3333
ocaml-compiler: "5.4.0"
34+
# The bottleneck of this job is compiling the dependency tree plus wodoc and
35+
# odoc from source; setup-ocaml only caches the base switch (the compiler),
36+
# so they recompiled on every push. Cache the whole _opam switch keyed on the
37+
# *.opam files (the dep set) and wodoc's HEAD commit; on a cache hit the
38+
# install is skipped and only the project itself is (re)built by the doc step
39+
# below. The key changes -- and the deps/wodoc rebuild once -- only when an
40+
# *.opam file or wodoc move.
41+
- name: Resolve wodoc HEAD commit
42+
id: wodoc
43+
run: echo "sha=$(git ls-remote https://github.com/ocsigen/wodoc.git HEAD | cut -f1)" >> "$GITHUB_OUTPUT"
44+
45+
- name: Cache the opam switch (deps + wodoc)
46+
id: switch-cache
47+
uses: actions/cache@v4
48+
with:
49+
path: _opam
50+
key: opam-switch-${{ runner.os }}-ocaml5.4.0-${{ hashFiles('*.opam') }}-wodoc-${{ steps.wodoc.outputs.sha }}
51+
3452
- name: Install dependencies
53+
if: steps.switch-cache.outputs.cache-hit != 'true'
3554
run: |
3655
opam install . --deps-only --with-doc
3756
opam pin add -n wodoc https://github.com/ocsigen/wodoc.git

0 commit comments

Comments
 (0)