From 4f2b807091ece54cffacfcebe49655a8c35b3f46 Mon Sep 17 00:00:00 2001 From: Vincent Balat Date: Tue, 30 Jun 2026 18:39:26 +0200 Subject: [PATCH] ci(doc): cache the opam switch (deps + wodoc) The doc job recompiled the dependency tree plus wodoc and odoc from source on every push; setup-ocaml only caches the base switch. Cache the whole _opam switch keyed on the *.opam files and wodoc's HEAD commit, so a cache hit skips the install and only the project itself is rebuilt. The deps/wodoc rebuild once when an *.opam file or wodoc move, then re-cache. --- .github/workflows/doc.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/doc.yml b/.github/workflows/doc.yml index 9d01fad3f..2921f9657 100644 --- a/.github/workflows/doc.yml +++ b/.github/workflows/doc.yml @@ -37,7 +37,26 @@ jobs: with: ocaml-compiler: "5.4.0" + # The bottleneck of this job is compiling the dependency tree plus wodoc and + # odoc from source; setup-ocaml only caches the base switch (the compiler), + # so they recompiled on every push. Cache the whole _opam switch keyed on the + # *.opam files (the dep set) and wodoc's HEAD commit; on a cache hit the + # install is skipped and only the project itself is (re)built by the doc step + # below. The key changes -- and the deps/wodoc rebuild once -- only when an + # *.opam file or wodoc move. + - name: Resolve wodoc HEAD commit + id: wodoc + run: echo "sha=$(git ls-remote https://github.com/ocsigen/wodoc.git HEAD | cut -f1)" >> "$GITHUB_OUTPUT" + + - name: Cache the opam switch (deps + wodoc) + id: switch-cache + uses: actions/cache@v4 + with: + path: _opam + key: opam-switch-${{ runner.os }}-ocaml5.4.0-${{ hashFiles('*.opam') }}-wodoc-${{ steps.wodoc.outputs.sha }} + - name: Install dependencies + if: steps.switch-cache.outputs.cache-hit != 'true' run: | opam install . --deps-only --with-doc # odoc is a with-doc dep # wodoc: the odoc driver that themes the pages with the Ocsigen chrome.