feat(cache): --cargo-cache flag and [cargo_cache] config section

Default on, because the cache is safe by construction rather than by
convention: it engages only where a Cargo.lock exists, and refuses to publish
anything the prune assertion cannot vouch for. Two independent off switches --
the flag for one job, `enabled = false` for the host.

The store root is resolved after the environment overrides are applied, so
CI_ROOT relocates it along with everything else, while an explicit root in the
config still wins. Both directions are covered by tests.

Also asserts that the Windows branch never receives the argument at all: the
cache is Linux-only and the two branches stay separate, per AGENTS.md.
This commit is contained in:
2026-07-22 21:02:35 +02:00
parent a7a22a29be
commit dc89427164
5 changed files with 210 additions and 1 deletions
+19
View File
@@ -53,3 +53,22 @@ type = "workstation"
# netmask = "255.255.255.0"
# gateway = "192.168.79.2" # VMnet8 gateway; leave empty to skip default route
# lease_file = "/var/lib/ci/ip-pool.json"
# ------------------------------------------------- cargo dependency cache
# Compiled Rust dependency artifacts, reused between jobs. Engages only for
# Linux guests whose build workdir contains a Cargo.lock, so non-Rust jobs
# need no flag. Workspace crates are stripped before an entry is stored and
# the job refuses to publish if any survive, so a restored entry cannot carry
# the code under test.
#
# One immutable file per key under `root`; a key is
# sha256(Cargo.lock) + rustc version + host triple. Deleting entries by hand
# is always safe -- each one costs exactly one cold build to regenerate.
#
# `root` defaults to <paths.root>/cache/cargo and follows CI_ROOT unless set
# here explicitly. Measured on LinuxRust2404: an entry is ~645 MB and a warm
# job pays ~8s to skip ~120s of dependency compilation.
[cargo_cache]
enabled = true
# root = "/var/lib/ci/cache/cargo"
retention_days = 30