A CI job's Cargo outputs go to its own folder; the compiled crates stay shared #134

Merged
merge-queue merged 2 commits from PIPT-18-cargo-build-dir into main 2026-11-17 12:37:04 -08:00
Owner

Tracked on https://openproject.home.romaine.life/wp/PIPT-18. Found when CI / setup-windows failed on #131 with "Cargo source list contains no tracked inputs".

Cause: in CI, a Rust job's CARGO_TARGET_DIR was the kept folder shared by every run of that repository's job (cargo-target/<repo>/<toolchain>/<job>-<platform>). Cargo locks it only while it builds. rust/build.mjs then reads release/<name>.exe and release/<name>.d, and a concurrent run of the same job can replace both in between. Run 566 (PR 131) and run 568 (another PR) overlapped for four minutes on the Windows runner. 566 read 568's .d, which names the other run's fixture folder. A release build of two merges close together could ship the wrong binary the same way.

Changed: when RUNNER_TEMP is set (CI), rust/cache.mjs points Cargo's build-dir (stable since Cargo 1.91; the suites run 1.100) at the kept folder and CARGO_TARGET_DIR at $RUNNER_TEMP/cargo-target. The compiled crates stay shared and cached. The final binaries and dependency lists go to the job's own folder. rust/lint.mjs's tool installs set their own build-dir so they don't land in the repository's cache.

Unchanged: cache keys, toolchain cleanup and the Linux lock. Local runs (ci-check, no RUNNER_TEMP) work as before.

Proven: locally with Cargo 1.99, build-dir shared and target-dir per run: the exe and .d land in the run's own folder, and a second run with a new target dir reports the crate Fresh and uplifts without recompiling. Suite unit tests pass (93). This PR changes suites/**/*.mjs, so setup-linux and setup-windows run the real fixture release builds on it.

Tracked on https://openproject.home.romaine.life/wp/PIPT-18. Found when `CI / setup-windows` failed on https://forgejo.romaine.life/romaine-life/pipeline-templates/pulls/131 with "Cargo source list contains no tracked inputs". **Cause:** in CI, a Rust job's `CARGO_TARGET_DIR` was the kept folder shared by every run of that repository's job (`cargo-target/<repo>/<toolchain>/<job>-<platform>`). Cargo locks it only while it builds. `rust/build.mjs` then reads `release/<name>.exe` and `release/<name>.d`, and a concurrent run of the same job can replace both in between. Run 566 (PR 131) and run 568 (another PR) overlapped for four minutes on the Windows runner. 566 read 568's `.d`, which names the other run's fixture folder. A release build of two merges close together could ship the wrong binary the same way. **Changed:** when `RUNNER_TEMP` is set (CI), `rust/cache.mjs` points Cargo's `build-dir` (stable since Cargo 1.91; the suites run 1.100) at the kept folder and `CARGO_TARGET_DIR` at `$RUNNER_TEMP/cargo-target`. The compiled crates stay shared and cached. The final binaries and dependency lists go to the job's own folder. `rust/lint.mjs`'s tool installs set their own build-dir so they don't land in the repository's cache. **Unchanged:** cache keys, toolchain cleanup and the Linux lock. Local runs (`ci-check`, no `RUNNER_TEMP`) work as before. **Proven:** locally with Cargo 1.99, `build-dir` shared and `target-dir` per run: the exe and `.d` land in the run's own folder, and a second run with a new target dir reports the crate `Fresh` and uplifts without recompiling. Suite unit tests pass (93). This PR changes `suites/**/*.mjs`, so `setup-linux` and `setup-windows` run the real fixture release builds on it.
A CI job's Cargo outputs go to its own folder; the compiled crates stay shared
Some checks are pending
CI / changes (pull_request) Successful in 13s
CI / actionlint (pull_request) Has been skipped
CI / prune-releases (pull_request) Has been skipped
CI / release-version (pull_request) Has been skipped
CI / check-versions (pull_request) Has been skipped
CI / check-fetches (pull_request) Has been skipped
CI / check-image-digests (pull_request) Has been skipped
CI / cached-images (pull_request) Has been skipped
CI / container-health (pull_request) Has been skipped
CI / azure-cli (pull_request) Has been skipped
CI / home-cache-linux (pull_request) Has been skipped
CI / home-cache-windows (pull_request) Has been skipped
Fleet / align (pull_request) Successful in 10s
CI / service-runtime (one) (pull_request) Successful in 39s
CI / service-runtime (two) (pull_request) Successful in 28s
CI / suite-tests-linux (pull_request) Successful in 31s
CI / service-cancellation (pull_request) Successful in 45s
CI / setup-linux (nas) (pull_request) Successful in 3m12s
CI / suite-tests-windows (pull_request) Successful in 55s
CI / setup-windows (pull_request) Successful in 3m52s
merge-queue 2nd in line, behind #133: CI jobs remove the test images they build
a8fc8f25c2
Two jobs of one repository building at once in the kept Cargo folder could replace each
other's binary and dependency list between Cargo finishing and the release build reading
them: setup-windows failed so on pipeline-templates PR 131 (run 566, overlapping run 568).
Cargo's build-dir (stable since 1.91) keeps the cache shared.
Merge branch 'main' into PIPT-18-cargo-build-dir
All checks were successful
merge-queue landed on main
Fleet / align (pull_request) Successful in 3s
CI / changes (pull_request) Successful in 6s
CI / actionlint (pull_request) Has been skipped
CI / prune-releases (pull_request) Has been skipped
CI / release-version (pull_request) Has been skipped
CI / check-versions (pull_request) Has been skipped
CI / check-fetches (pull_request) Has been skipped
CI / check-image-digests (pull_request) Has been skipped
CI / cached-images (pull_request) Has been skipped
CI / container-health (pull_request) Has been skipped
CI / azure-cli (pull_request) Has been skipped
CI / home-cache-linux (pull_request) Has been skipped
CI / home-cache-windows (pull_request) Has been skipped
CI / service-runtime (two) (pull_request) Successful in 42s
CI / service-runtime (one) (pull_request) Successful in 42s
CI / suite-tests-linux (pull_request) Successful in 39s
CI / service-cancellation (pull_request) Successful in 48s
CI / suite-tests-windows (pull_request) Successful in 1m2s
CI / setup-linux (nas) (pull_request) Successful in 3m4s
CI / setup-windows (pull_request) Successful in 4m22s
933603a709
merge-queue deleted branch PIPT-18-cargo-build-dir 2026-11-17 12:37:04 -08:00
Sign in to join this conversation.
No description provided.