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

Closed
sombraSoft wants to merge 1 commit from upstream-pr/274 into main
sombraSoft commented 2026-11-23 22:16:54 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by sombraSoft on 2026-11-23T22:16:54Z.


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.
<!-- greyfinch-sync:ivall/xcl:issue:5462180338 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/274). Originally posted by [sombraSoft](https://github.com/sombraSoft) on 2026-11-23T22:16:54Z. --- 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.
DavidM1911 commented 2026-11-25 16:12:03 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T15:14:13Z.


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!

<!-- greyfinch-sync:ivall/xcl:comment:7166518573 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/274#issuecomment-7166518573). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T15:14:13Z. --- 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!
github-actions[bot] commented 2026-11-29 20:42:45 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by github-actions[bot] on 2026-11-29T20:42:45Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7262297737 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/274#issuecomment-7262297737). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-11-29T20:42:45Z. --- 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.
Foniass commented 2026-12-01 03:02:44 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T03:02:44Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7299262724 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/274#issuecomment-7299262724). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T03:02:44Z. --- **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.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!271
No description provided.