@@ -56,43 +56,17 @@ jobs:
5656 uses : DeterminateSystems/flake-checker-action@9ee1c5473f1abdfb299f6c4f0fab813147c97fe3 # main
5757
5858 # GitHub-hosted fallback caches Rust via the Actions cache. The self-hosted
59- # box runs the heavy Rust CI (clippy/doc/test) as crane derivations via
60- # `nix flake check`, so deps cache in /nix/store and there's no persistent
61- # CARGO_TARGET_DIR to manage -- the residual `cargo check`s use the
62- # workspace ./target, which the runner wipes per job.
59+ # box runs the heavy Rust CI (clippy/doc/test) as plain cargo, reusing a
60+ # persistent CARGO_TARGET_DIR set in the runner environment (not here), so
61+ # unchanged crates are reused across jobs; the checkout's ./target is unused.
6362 - name : Rust Cache
6463 if : runner.environment == 'github-hosted'
6564 uses : Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2
6665 with :
6766 cache-on-failure : true
6867
69- # Mark a baseline so the post-run assertion can tell whether anything wrote
70- # under the old persistent target dir (i.e. a CARGO_TARGET_DIR override
71- # leaked back in and would re-grow an unbounded tree).
72- - name : Target-dir baseline
73- if : runner.environment == 'self-hosted'
74- run : touch "$RUNNER_TEMP/target-baseline"
75-
7668 # `just ci` calls `just changed` internally to skip unchanged scopes.
7769 # Login shell so /etc/profile.d puts Nix on PATH; Actions shells don't by
7870 # default. Harmless on the hosted fallback.
7971 - run : nix develop --command just ci
8072 shell : bash -leo pipefail {0}
81-
82- # Invariant: nothing should write to the old persistent target dir anymore.
83- # Fails loudly if a CARGO_TARGET_DIR override sneaks back in. Scope it to
84- # *this* repo's old per-runner dir (moq-$RUNNER_NAME) -- the box's
85- # $HOME/cargo-target is shared with other repos (e.g. moq-pro) and runners,
86- # whose jobs may run concurrently and legitimately still write there.
87- - name : Assert the persistent target dir stayed unused
88- if : runner.environment == 'self-hosted'
89- run : |
90- target="$HOME/cargo-target/moq-$RUNNER_NAME"
91- mkdir -p "$target"
92- leaked=$(find "$target" -type f -newer "$RUNNER_TEMP/target-baseline" 2>/dev/null | head)
93- if [ -n "$leaked" ]; then
94- echo "::error::cargo wrote to $target; a CARGO_TARGET_DIR override leaked back in"
95- echo "$leaked"
96- exit 1
97- fi
98- echo "OK: $target untouched this run"
0 commit comments