feat: cache rocks in build-artifacts workflow#51
Open
javierdelapuente wants to merge 1 commit into
Open
Conversation
Cache built rocks between CI runs to avoid redundant rockcraft pack invocations. Modelled on operator-workflows' build.ts caching strategy. What is cached: - The partial artifacts.build.yaml manifest (contains the GHCR image: ref), NOT the .rock file itself — the GHCR image persists across runs with its original tag. Cache key: rock-<name>-<arch>-<hash-of-source-dir>-<YYYY-WNN> where: - hash covers all non-.rock files in the pack-dir (or rockcraft.yaml parent directory), matching operator-workflows' hashFiles() approach. - YYYY-WNN (ISO week) provides explicit weekly rotation; GitHub's 7-day LRU eviction also applies but the weekly key is more predictable. Behaviour: - Cache hit: LXD install, rockcraft install, GHCR login and rockcraft pack are all skipped; restored manifest is uploaded as-is by the existing unconditional 'Upload partial build manifest' step. - Cache miss: build proceeds as before, then manifest is saved to cache. - Artifact mode (fork PRs): no caching — GH artifacts are run-scoped and the .rock file would be too large to cache efficiently. opcli changes: - artifacts_matrix() now includes rockcraft-yaml and pack-dir fields in rock matrix entries so the workflow can locate the source directory for hash computation. Closes #13 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
Caches built rocks between CI runs to avoid redundant
rockcraft packinvocations. Modelled directly on operator-workflows'build.tscaching strategy.Closes #13
What's cached
Only the partial
artifacts.build.yamlmanifest (contains the GHCRimage:ref), not the.rockfile itself — the GHCR image persists across runs with its original tag.Cache key structure
.rockfiles in the pack-dir (orrockcraft.yamlparent dir), matching operator-workflows'hashFiles()approach.restore-keysfallback — a partial hit would restore a manifest with a stale GHCR image ref built from different source files.Behaviour
rockcraft packare all skipped; restored manifest is uploaded by the existing unconditional step.rockfile is too large to cache efficientlyChanges
.github/workflows/build-artifacts.ymlactions/cache/restore@v4.actions/cache/save@v4on cache miss only.src/opcli/core/artifacts.pyartifacts_matrix()now includesrockcraft-yamlandpack-dirfields in rock matrix entries (needed by the workflow to locate the source directory for hash computation).tests/unit/test_artifacts.py