Cache SwiftPM build products in CI - #1
Open
RISCfuture wants to merge 1 commit into
Open
Conversation
Every CI run recompiled the package's dependencies from scratch. Cache `.build` alongside the SwiftPM download caches so a run whose dependency graph and toolchain are unchanged reuses the compiled objects. The key is exact-match with no restore-keys: objects built against a different dependency graph or toolchain must never be reused, and a partial restore is how a stale-artifact bug gets in. Matrix jobs put both the OS and the Swift version in the key, so macOS objects can never land on a Linux leg. Each compiling job gets its own key prefix. The lint and swift-format jobs parse source without compiling it and are left alone. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SRgQmnzeh3vsVKudXWs3RV
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.
Every CI run recompiled this package's dependencies from scratch. This caches
.buildalongside the SwiftPM download caches, so a run whose dependency graph and toolchain are unchanged reuses the compiled objects.Not cached:
lint(SwiftLint) andswift-format— both parse source without compiling, so there are no build products to reuse.Key design
Exact-match, no
restore-keys. Objects built against a different dependency graph or toolchain must never be reused, and a partial prefix restore is precisely how a stale-artifact bug gets in. Matrix jobs carry both the OS and the Swift version, so macOS objects can never restore onto a Linux leg, nor 6.1 objects onto a 6.3 toolchain. Each compiling job has its own key prefix so jobs building different products don't clobber one another.Measured on the canary
This exact pattern was validated on
RISCfuture/heartsbefore rollout, with a cold run followed by a warm one:Each key hit independently, confirming the per-job prefixes work as intended.
Note
actionlintandyamllintare clean. This PR's own run is a guaranteed cache miss — the entries don't exist yet. It proves the workflows still pass; a second run is what demonstrates the hit.🤖 Generated with Claude Code
https://claude.ai/code/session_01SRgQmnzeh3vsVKudXWs3RV