ci: Ensure rust-cache respects versions in Cargo.lock#674
Merged
kylebarron merged 1 commit intomainfrom Apr 22, 2026
Merged
Conversation
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.
[This PR summary written by claude]
Summary
Add an explicit
key:toSwatinem/rust-cachein all three workflows that use it, so Cargo.lock changes actually invalidate the cache. Also segment the test-python cache bymatrix.python-version.Why
Swatinem/rust-cachenormalizes dependency version numbers to"0.0.0"before hashing Cargo.lock to compute its cache key. This means a patch/minor bump likepyo3 0.28.2 → 0.28.3produces the same cache key as before the bump. rust-cache's stale-crate cleanup only runs on partial (restore-key) hits — on a full-match hit it trusts the cachedtarget/as-is, so stale pre-compiled artifacts can be reused indefinitely.This bit us on #673 (cherry-pick of #672 into
release/py-v0.9): after the PyO3 0.28.3 bump, the release-branch CI kept restoring a pre-0.28.3target/from cache and the 3.14t job failed withSystemError: init function of _obstore returned uninitialized object. Main passed only because it happened to get a partial cache hit, which triggered rust-cache's cleanup and forced a fresh PyO3 rebuild.Appending
hashFiles('**/Cargo.lock')to the cache key means any byte-level change to any lockfile in the repo produces a new cache entry. No more silent staleness.Why segment test-python by Python version
pyo3-build-config'sbuild.rsdetects the target Python ABI via environment variables (PYO3_PYTHON,PYTHON_SYS_EXECUTABLE) set by maturin at build time. Those env vars are not part of cargo's fingerprint, so cargo can reusetarget/artifacts built against Python 3.14 when the next matrix job runs under 3.14t — producing ABI-incompatible.sos with exactly the symptom we just debugged. Giving each matrix entry its own cache slot makes this class of cross-contamination structurally impossible.