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
+14
View File
@@ -326,6 +326,14 @@ def _destroy_clone(
help="In-guest git clone (default) vs host-side clone + zip transfer.",
)
@click.option("--use-shared-cache", "use_shared_cache", is_flag=True, default=False)
@click.option(
"--cargo-cache/--no-cargo-cache",
"cargo_cache",
default=True,
show_default=True,
help="Reuse compiled Rust dependency artifacts between jobs (Linux only; "
"engages only when the workspace has a Cargo.lock).",
)
@click.option("--skip-artifact", "skip_artifact", is_flag=True, default=False)
@click.option(
"--xvfb",
@@ -409,6 +417,7 @@ def job(
submodules: bool,
use_git_clone: bool,
use_shared_cache: bool,
cargo_cache: bool,
skip_artifact: bool,
use_xvfb: bool,
gitea_credential_target: str,
@@ -634,6 +643,11 @@ def job(
extra_env=extra_env,
skip_artifact=skip_artifact,
use_xvfb=use_xvfb,
cargo_cache_root=(
config.cargo_cache.root
if cargo_cache and config.cargo_cache.enabled
else None
),
)
else:
_windows_build(