ci: stabilize the Rust cache key by removing the runner's bundled toolchain#598
Merged
Merged
Conversation
Swatinem/rust-cache includes the version of every installed Rust toolchain in its environment hash, which is part of the cache key. GitHub runner images ship a `stable` toolchain whose version drifts as the image is updated, so the cache key silently changes from run to run and jobs miss the cache and rebuild from cold (observed as two different env hashes for otherwise-identical builds). We pin the toolchain via rust-toolchain.toml (1.95.0), so the bundled `stable` is unused. Remove it before setup-rust-toolchain in every workflow that caches, so only the pinned toolchain remains and the cache key is stable. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
adamspofford-dfinity
approved these changes
Jun 9, 2026
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.
Problem
Swatinem/rust-cachefolds the version of every installed Rust toolchain into its environment hash, which is part of the cache key. GitHub runner images ship astabletoolchain whose version drifts as the image is updated — so the cache key silently changes from run to run, jobs miss the cache, and rebuild from cold.This was observed directly while debugging the Windows test cache: two otherwise-identical builds produced different env hashes (
…-9fc860dc-…vs…-b9079240-…) with the sameCargo.lock, i.e. the only thing that moved was the bundled toolchain version.Fix
We already pin the toolchain via
rust-toolchain.toml(1.95.0), so the runner's bundledstableis never actually used for builds — it only pollutes the cache key. This PR removes it beforesetup-rust-toolchainin every workflow that caches:Added before all 8
setup-rust-toolchainusages:test.yml(2 — unit-tests + test)checks.yml(5 — compile, lint, format, cli-ref, icp-yaml-schema)validate-examples.yml(1)The step is non-fatal (
2>/dev/null || true) and runs under the defaultbashshell on every runner it touches.Notes for reviewers
-test,-checks,-validate) when this merges — removingstableshifts the env hash once more, to whatever the 1.95.0-only environment produces. After that the key should stay put run-to-run, which is the whole point.main, every PR (base =main) reuses the new, stable-keyed caches.🤖 Generated with Claude Code