Menu

#488 ci: save rust caches only on the integration branches

closed
nobody
None
2026-07-19
2026-07-19
Anonymous
No

Originally created by: Akarsh-Hegde

What

Adds save-if to all three Swatinem/rust-cache@v2 steps in ci.yml (rust, windows-portability, macos-universal):

save-if: ${{ github.ref == 'refs/heads/pre-main' || github.ref == 'refs/heads/main' }}

PR runs keep restoring — GitHub lets a PR run read caches from its base branch — they just stop writing a duplicate.

Why

Actions caches are scoped by ref. A branch that is both pushed to pre-main and has an open PR therefore stores two near-identical copies of every target/ cache. Measured 2026-07-19:

Cache pre-main pull/483/merge
macos-universal 2582 MB 2527 MB
windows-portability 1269 MB 1262 MB
rust (Linux) 1091 MB 851 MB

9.58 GB against a 10 GB per-repo quota, from six entries all created inside one 15-minute window. GitHub evicted LRU to stay under, and the casualty was the release job's own 2618 MB cache — written at 13:42, gone by ~16:55. Release run 29696118671 consequently compiled fully cold.

This frees ~4.9 GB (12.18 GB → ~7.3 GB).

Why not cache-targets: false

That was the other candidate and it's the worse trade. Those jobs are already the slowest in CI with a warm cache — on run 29695608454: Windows portability 8.1 min, macOS 6.2 min, Rust 2.3 min. Dropping target/ would add ~10 min to every PR to save ~20 min on an infrequent release.

Costs and limits, stated plainly

  • A long-lived PR branch that drifts from its base gets progressively staler restores. Bounded — never worse than the cold build it would otherwise get.
  • This makes the release cache able to survive, not guaranteed to. ~7.3 GB + 2.62 GB release ≈ 9.9 GB is still close to the line, and a sustained week of CI could age it out. The durable fixes are a scheduled warm-up run on pre-main that refreshes the release-namespace cache, or more quota. Neither is in this PR.
  • Existing stale entries aren't pruned here. Two generations from 07-18 (2.35 GB combined) are still held on superseded lockfile hashes; clearing those would add real headroom.

Testing

save-if is confirmed present in action.yml at the pinned SHA (e18b497). The effect is only observable across runs — after merge, the check is that PR runs stop appearing as pull/* refs in gh cache list while still logging a restore.

Related

Tickets: #494

Discussion

  • Anonymous

    Anonymous - 2026-07-19

    Originally posted by: coderabbitai[bot]

    [!IMPORTANT]

    Review skipped

    Auto reviews are disabled on base/target branches other than the default branch.

    Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.


    ⚙️ Run configuration

    Configuration used: Organization UI

    Review profile: ASSERTIVE

    Plan: Pro Plus

    Run ID: 2d7fe9fe-ee8f-4bb6-96b1-660fe85b38a1

    You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

    Use the checkbox below for a quick retry:
    - [ ] 🔍 Trigger review

    ✨ Finishing Touches
    🧪 Generate unit tests (beta) - [ ] Create PR with unit tests - [ ] Commit unit tests in branch `ci/scope-rust-cache-saves`

    Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

    ❤️ Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)

    Comment @coderabbitai help to get the list of available commands.

     
  • Anonymous

    Anonymous - 2026-07-19

    Ticket changed by: Akarsh-Hegde

    • status: open --> closed
     

Log in to post a comment.