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

Open
github-bot wants to merge 1 commit from github-bot/gh-274 into main AGit
Owner

@⁠sombraSoft on GitHub · 2026-11-23 22:16 UTC · original
sombraSoft:ci/rust-cache → main · +4 −8 · 1 files · 1 commits · open

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.
**@⁠sombraSoft** on GitHub · 2026-11-23 22:16 UTC · [original](https://github.com/xcl-dev/xcl/pull/274) `sombraSoft:ci/rust-cache` → `main` · +4 −8 · 1 files · 1 commits · open 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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:18:24 +00:00
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 15:14 UTC · original

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 15:14 UTC · [original](https://github.com/xcl-dev/xcl/pull/274#issuecomment-7166518573) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/274/head:github-bot/gh-274'
git switch 'github-bot/gh-274'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-274'
git switch 'github-bot/gh-274'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-274'
git switch 'github-bot/gh-274'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-274'
git switch 'main'
git merge --squash 'github-bot/gh-274'
git switch 'main'
git merge --ff-only 'github-bot/gh-274'
git switch 'main'
git merge 'github-bot/gh-274'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.