Skip to content

ci: stabilize the Rust cache key by removing the runner's bundled toolchain#598

Merged
lwshang merged 1 commit into
mainfrom
lwshang/ci-stabilize-rust-cache-key
Jun 9, 2026
Merged

ci: stabilize the Rust cache key by removing the runner's bundled toolchain#598
lwshang merged 1 commit into
mainfrom
lwshang/ci-stabilize-rust-cache-key

Conversation

@lwshang

@lwshang lwshang commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Problem

Swatinem/rust-cache folds the version of every installed Rust toolchain into 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, 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 same Cargo.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 bundled stable is never actually used for builds — it only pollutes the cache key. This PR removes it before setup-rust-toolchain in every workflow that caches:

- name: Remove the runner's bundled Rust toolchain
  run: rustup toolchain remove stable 2>/dev/null || true

Added before all 8 setup-rust-toolchain usages:

  • 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 default bash shell on every runner it touches.

Notes for reviewers

  • Expect one more cold prime per cache namespace (-test, -checks, -validate) when this merges — removing stable shifts 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.
  • Follow-up to ci: speed up Windows integration tests #595 (Windows test speedups). Same rollout logic applies: once it's on main, every PR (base = main) reuses the new, stable-keyed caches.

🤖 Generated with Claude Code

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>
@lwshang lwshang marked this pull request as ready for review June 9, 2026 20:18
@lwshang lwshang requested a review from a team as a code owner June 9, 2026 20:18
@lwshang lwshang enabled auto-merge (squash) June 9, 2026 20:18
@lwshang lwshang merged commit 8ad2488 into main Jun 9, 2026
90 checks passed
@lwshang lwshang deleted the lwshang/ci-stabilize-rust-cache-key branch June 9, 2026 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants