Skip to content

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

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

sombraSoft wants to merge 1 commit into
xcl-dev: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.
@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

@KOLESNiii KOLESNiii mentioned this pull request Nov 25, 2026
@github-actions

Copy link
Copy Markdown

Nothing has happened on this PR for 3 days, so it is marked stale and will be closed in 4 days. A push or a comment takes the mark off: rebase it onto main if it conflicts, and say in one line what it still fixes. If it only waits for a maintainer, a comment saying so is enough.

@github-actions github-actions Bot added the stale No activity for 3 days; closed 4 days later unless something happens label Nov 29, 2026
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head bf06178

No open or merged PR makes the same change. #286 bumps the same actions/cache step to v6 instead of replacing it, so whichever merges second has to drop or rebase its change of that step; #277 uses the same Swatinem/rust-cache@v2 with save-if on main only for its clippy job, consistent with this one.
No problems found in the diff; main's ci.yml still uses actions/cache@v4 with a key that ignores the rustc version.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

@github-actions github-actions Bot removed the stale No activity for 3 days; closed 4 days later unless something happens label Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

off-goal Does not bear on the current goal (world loading); waits until it is reached

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants