build: add sccache for faster local and CI builds
Some checks failed
CI / Format (push) Successful in 4s
CI / Clippy (push) Failing after 40s
CI / Security Audit (push) Has been skipped
CI / Tests (push) Has been skipped
CI / Format (pull_request) Successful in 3s
CI / Clippy (pull_request) Failing after 4s
CI / Security Audit (pull_request) Has been skipped
CI / Tests (pull_request) Has been skipped
CI / Deploy (push) Has been skipped
CI / Deploy (pull_request) Has been skipped

- Add .cargo/config.toml with rustc-wrapper = sccache for local caching
- Install sccache in CI clippy/test jobs via prebuilt musl binary
- Add actions/cache to persist sccache dir across CI runs (keyed by Cargo.lock)
- Add BuildKit cache mounts in Dockerfile for sccache across Docker builds
- Disable sccache for fmt/audit jobs where it adds no value

Local clean-rebuild speedup: 1m58s -> 34s (3.4x) with warm cache.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Sharang Parnerkar
2026-02-22 13:34:08 +01:00
parent 007c7e2686
commit 456976c494
3 changed files with 62 additions and 4 deletions

5
.cargo/config.toml Normal file
View File

@@ -0,0 +1,5 @@
[build]
# Use sccache as the rustc wrapper for compile caching.
# Falls back gracefully: if sccache is not installed, cargo will warn but
# still compile. Install with: cargo install sccache
rustc-wrapper = "sccache"