feat(ci): cache the docs image build through ghcr.io - #316
Merged
Conversation
Every GitHub Actions run is a fresh VM, so podman's build cache is otherwise local-only and never survives between runs — doc.yaml's image (a Rust toolchain plus five `cargo install`s) was rebuilding from scratch on every single run, cold every time. Add CACHE_REF support to build_doc.sh, mirroring build.sh's existing pattern for the E2E workspace image, and wire doc.yaml to log into ghcr.io and compute a stable dc-doc-cache ref, mirroring ci.yaml's build-workspace job. Verified locally: a second build.sh run against the same Containerfile hits "Using cache" on every layer. ci.yaml's build-e2e-image job also runs a bare podman build with no cache, but its FROM is the just-built, SHA-tagged workspace image, which changes every run — a cache keyed on the prior layer's digest can never hit there, and the layer itself is just 3 COPYs + a chmod. Left as-is (#315). Closes #315 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BxvjR5XyyaEPBBpwGfUK9W Signed-off-by: David Bensoussan <d.bensoussan@proton.me>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BxvjR5XyyaEPBBpwGfUK9W Signed-off-by: David Bensoussan <d.bensoussan@proton.me>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## jazzy #316 +/- ##
=======================================
Coverage 40.48% 40.48%
=======================================
Files 82 82
Lines 5094 5094
=======================================
Hits 2062 2062
Misses 3032 3032
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tools/ci/pre-commit/build_doc.shnever wired up a registry build cache — unliketools/e2e/scripts/build.sh, which already acceptsCACHE_REFand passes--cache-from/--cache-totopodman build. Every GitHub Actions run is a fresh VM, so podman's local build cache never survives between runs;doc.yaml's image (a Rust toolchain + fivecargo installs) was rebuilding from scratch on every single run.CACHE_REFmechanism tobuild_doc.sh, mirroringbuild.sh's pattern.doc.yamlto log intoghcr.io, compute a stabledc-doc-cacheref, and pass it through — mirroringci.yaml'sbuild-workspacejob (including the lowercasing dance, since ghcr image names must be lowercase).packages: writewas added todoc.yaml's permissions, but note: GitHub forcesGITHUB_TOKENto read-only onpull_requestfrom a fork regardless of what's requested — documented inline. A fork PR just builds cold, same as before this change; the build does not fail.Deliberately out of scope
ci.yaml'sbuild-e2e-imagejob also runs a barepodman build(tools/e2e/Containerfile.e2e) with no cache flags. ItsFROMis the just-built, SHA-tagged workspace image — a different ref every run — so a cache keyed on the prior layer's digest can never hit there. The layer itself is also just 3COPYs + achmod(sub-second). Wiring the same mechanism onto it would be cargo-culting with no effect, so it's left as-is.Test plan
IMAGE_TAG=dc-doc:cachetest ./tools/ci/pre-commit/build_doc.shrun twice back-to-back locally (noCACHE_REF) — clean build both times, second run showsUsing cache <digest>on all 12STEPs, confirming--layersdoesn't regress local cachingpre-commit run --files .github/workflows/doc.yaml tools/ci/pre-commit/build_doc.sh—check-yaml,shellcheck, and thebuild-dochook (realstrictdoc export+mdbook build) passCloses #315
Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com
https://claude.ai/code/session_01BxvjR5XyyaEPBBpwGfUK9W