Skip to content

CI: cache Cargo with rust-cache, saved from main only - #274

Open
sombraSoft wants to merge 1 commit into
ivall:mainfrom
sombraSoft:ci/rust-cache
Open

sombraSoft wants to merge 1 commit into
ivall:mainfrom
sombraSoft:ci/rust-cache

Conversation

@sombraSoft

@sombraSoft sombraSoft commented Nov 23, 2026 •

Copy link
Copy Markdown

The Cargo cache key holds only the Cargo.lock / Cargo.toml hashes, not the rustc version. CI installs floating stable, so after each stable release the restored dependencies no longer match and are rebuilt on every run until Cargo.lock changes. An exact key hit never saves again, so the cache never catches up. And every PR that changes a Cargo.toml saves its own ~284 MB cache, which churns the 10 GB repository limit when there are dozens of PRs a day.

Part of #265

What is in it

  • .github/workflows/ci.yml: actions/cache@v4 is replaced by Swatinem/rust-cache@v2. It runs after the toolchain step, so its key includes the installed rustc (as well as Cargo.lock / Cargo.toml and the CARGO* / RUST* env), and it keeps only dependency artifacts. With save-if: ${{ github.ref == 'refs/heads/main' }}, only main saves; PRs restore main's cache and write none. Floating stable and CARGO_INCREMENTAL=0 are unchanged.

CI time

  • 0 on the critical path: the restore takes ~3 s (6 s before). Pull requests no longer spend 7–9 s saving their own cache. After each stable release, the first run on main builds the dependencies again and later runs reuse them; today they rebuild on every run until Cargo.lock changes.

Tested

  • CI-only change. Fork run, green: https://github.com/sombraSoft/xcl/actions/runs/45276290398. The key v0-rust-windows-Windows_NT-x64-1ffb72bd-aedbd39e includes rustc 1.100.0. On the PR save-if was false, and no v0-rust-* cache was written (checked the fork's cache list afterwards). The run was cold because the fork had no cache: Build and test took 2m27s.
  • Full suite on main (9ab7d76), RTX 3060 Ti (driver 621.24), Ryzen 9 5900X, Windows 11, rustc 1.97.1, debug: scripts/test.ps1 → 651 passed, 0 failed, 40 ignored; SKIPPED: 2 (no wave64). This PR changes only CI config, so the compiled code is the same.

Regression run

  • Not needed: no crates/xcl/src change.

Not tested

  • Saving on main, and a PR restoring main's cache: only observable after merge.
  • The existing cargo-Windows-* entries are no longer used; GitHub evicts them after 7 days without access.

AI use

  • Claude Code (Claude Opus 5.5) wrote the change and this description; I read the diff.

The actions/cache key held only the Cargo.lock and Cargo.toml hashes, not
the rustc version. The toolchain is floating stable, so after each stable
release the restored target dependencies no longer match and rebuild on
every run until Cargo.lock changes; an exact key hit never saves again, so
the cache did not catch up. Every pull request that changed a Cargo.toml
also saved its own ~284 MB cache, which churns the 10 GB repository limit.

Swatinem/rust-cache keys on the installed rustc (so it runs after the
toolchain step) as well as the Cargo files, and keeps only dependency
artifacts. save-if limits saving to main; pull requests restore main's
cache.
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.

1 participant