Skip to content

ci: cache cargo registry and target dir with Swatinem/rust-cache#142

Open
mazurroman wants to merge 1 commit into
mainfrom
rm/ci-rust-cache
Open

ci: cache cargo registry and target dir with Swatinem/rust-cache#142
mazurroman wants to merge 1 commit into
mainfrom
rm/ci-rust-cache

Conversation

@mazurroman

Copy link
Copy Markdown
Member

Summary

All three CI jobs (rust, lit, coverage) currently rebuild every dependency from scratch on every run, which dominates CI time. The coverage job also recompiles cargo-llvm-cov itself every time.

Add Swatinem/rust-cache@v2 right after each Rust toolchain install so the cargo registry, git index, and target/ directory are restored from a per-job cache.

The action keys the cache off Cargo.lock + toolchain by default, so:

  • cache hits skip the dependency compile entirely
  • Cargo.lock or toolchain changes invalidate cleanly
  • per-job key isolation means the rust / lit / coverage jobs each get a cache layout that matches their build profile

Test plan

  • Drop-in change: no scripts modified, no flags changed.
  • Cold-cache runs (this PR and any others targeting main before a cache exists) behave the same as before; subsequent runs benefit from cached deps.
  • Each job installs the toolchain before rust-cache runs, which is the action's required ordering.

All three CI jobs currently rebuild every dependency from scratch on
every run, which dominates CI time. Add Swatinem/rust-cache@v2 right
after each Rust toolchain install so the cargo registry, git index,
and target directory are restored from the per-job cache.

The action keys the cache off Cargo.lock + toolchain by default, so:
- cache hits skip the dependency compile entirely
- Cargo.lock or toolchain changes invalidate cleanly
- per-job key isolation means the rust/lit/coverage jobs each get
  the cache layout that matches their build profile

Drop-in change: no scripts modified, no flags changed. Cold-cache runs
behave the same; subsequent runs should drop from minutes of dep
compile to seconds of restore.
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