Skip to content

ci(doc): cache the opam switch to skip recompiling the dependency tree#266

Merged
balat merged 1 commit into
masterfrom
ci/cache-opam-switch
Jun 30, 2026
Merged

ci(doc): cache the opam switch to skip recompiling the dependency tree#266
balat merged 1 commit into
masterfrom
ci/cache-opam-switch

Conversation

@balat

@balat balat commented Jun 30, 2026

Copy link
Copy Markdown
Member

Problem

The Documentation workflow recompiles the whole dependency tree (incl. wasm_of_ocaml) plus wodoc and odoc from source on every push (several minutes); setup-ocaml@v3 only caches the base switch (the compiler).

Fix

Cache the whole _opam switch with actions/cache, keyed on *.opam (the dependency set) and wodoc's resolved HEAD commit. The install is split:

  • Install dependencies and wodoc — cache miss only (deps tree + wodoc).
  • Install always: the project's own sources change every push, so opam install . re-syncs the local pin and rebuilds it for odoc_driver --remap to document. Only the project recompiles on the hot path, not its dependencies.

The cache rebuilds once when an *.opam file or wodoc's HEAD move.

Same approach validated on ocsigen.github.io and ocsigenserver (each ~5 min → ~1 min).

⚠️ This project pulls wasm_of_ocaml; if a validation run hits the current Aandreba/setup-binaryen/wasm_of_ocaml build breakage (see ocsigen/eliom#894), that is independent of this change and would block the next master push too.
The release job (manual, infrequent) is left as-is.

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.
@balat

balat commented Jun 30, 2026

Copy link
Copy Markdown
Member Author

⚠️ The validation dispatch on this branch failed at Install dependencies and wodoc, but not because of this change — it died building wasm_of_ocaml-compiler 6.4.0 (pulled in via eliom), the same Aandreba/setup-binaryen/wasm_of_ocaml breakage as ocsigen/eliom#894 and ocsigen-start. This is independent of caching and would block the next master doc push too.

So this caching PR is logically ready but can't be validated until the wasm build is fixed. The pattern itself (cache deps+wodoc, always rebuild the project via opam install .) is validated on the equivalent API projects (ocsigenserver: 5 min → ~1 min) and on the dogfood/manual variants (wodoc, ocsigen.github.io).

@balat balat merged commit 2888ebd into master Jun 30, 2026
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant