A GitHub Action that implements smart caching for rust/cargo projects with sensible defaults.
open sourceLGPL-3.0self-hostablefree
rust-cache is a GitHub Action that caches Cargo's registry, git dependencies and target directory between workflow runs, keyed on the rustc version, lockfiles and job. It prunes the cache to keep useful dependency artifacts and offers shared keys, prefix keys and workspace settings.
Problems it solves
- my GitHub Actions Rust job recompiles every crate on every push
- actions/cache for cargo keeps missing or uploading huge caches
- what should I cache in CI for a Rust project and what key should I use
- Rust CI takes 10 minutes and most of it is building dependencies
- share a cargo cache between several jobs in one workflow
- the target folder cache in CI keeps growing until it's useless
- invalidate the CI cache automatically when the toolchain changes
- speed up clippy and test jobs on GitHub Actions
Features
- caches registry, git deps and target dir
- automatic cache keys from rustc version and lockfiles
- shared-key and prefix-key
- cache pruning
Alternatives
The same job
These do what Swatinem/rust-cache does.
- Mr Boxington (mbx) A shared cache for Cargo builds
- actions/cache Cache dependencies and build outputs in GitHub Actions
- sccache Shared compilation cache for C, C++, Rust and CUDA, stored locally or in the cloud
- Kache Build once. Reuse the work.
- Blacksmith Faster, cheaper hosted runners for GitHub Actions
- WarpBuild High-performance GitHub Actions runners: 2x faster, 50% cheaper
