Skip to content

ci: persist cargo caches on runner volume#75

Merged
wavekat-eason merged 1 commit into
mainfrom
ci/persistent-cargo-target
May 23, 2026
Merged

ci: persist cargo caches on runner volume#75
wavekat-eason merged 1 commit into
mainfrom
ci/persistent-cargo-target

Conversation

@wavekat-eason
Copy link
Copy Markdown
Contributor

What

Point CARGO_HOME and CARGO_TARGET_DIR at the runner's persistent volume (/home/runner/runner) in the GitHub Actions runner image, instead of the image layer (CARGO_HOME=/usr/local/cargo) and the default ./target inside the checkout.

Why

Workflows run actions/checkout, which git clean -ffdxs the checkout's target/ every run. So Rust CI had no warm on-disk artifacts and relied on Swatinem/rust-cache, which tars ~370 MB and round-trips it to GitHub's cloud cache on every run — minutes of upload at a few MB/s on these self-hosted runners (and the wavekat-voice parallel-jobs split doubled it to two caches).

With cargo's caches as siblings of _work on the same persistent volume, compiled artifacts (incl. the 5–10 min ONNX/sherpa build) and the crate registry survive both the git-clean and container recreation. That lets wavekat-voice drop rust-cache (companion PR), eliminating the upload entirely.

The toolchain binaries stay baked at /usr/local/cargo/bin (still first on PATH) and rustup resolves toolchains via RUSTUP_HOME, so only the registry/git cache and compiled artifacts relocate.

Rollout (volume-preserving — keeps registration)

On the runner host (aoc-m3l):

cd wavekat.com && git pull
sudo docker build -t wavekat/gha-runner:latest scripts/docker
sudo systemctl restart gha-runner@{1..4}

systemctl restart re-execs docker run --rm … wavekat/gha-runner:latest with the rebuilt image, so the new ENV applies while the gha-runner-N volume (and the runner's registration) persists. Do not re-run setup-gha-runners-docker.sh for this — it wipes volumes.

First CI run per runner after the restart is cold (fresh cargo-home/cargo-target on the volume); every run after is warm with zero cache upload.

Sequencing

Deploy this before merging the wavekat-voice cache: false PR — otherwise that PR's runs go fully cold every run (no on-disk target, no cloud cache).

Note

The entrypoint's chown -R runner:runner /home/runner/runner now also recurses over cargo-target on container (re)start — a one-time-ish cost on restart, not per job. Can be narrowed later if it bites.

🤖 Generated with Claude Code

Point CARGO_HOME and CARGO_TARGET_DIR at the runner's persistent volume
(/home/runner/runner) instead of the image layer / the git-cleaned
checkout. Workflows run actions/checkout, which `git clean`s the
checkout's target/ every run; with cargo's caches as siblings of _work
on the volume, build output survives both the clean and container
recreation.

This lets Rust CI (wavekat-voice) drop Swatinem/rust-cache entirely:
warmth now comes from on-disk artifacts on the persistent runner rather
than tarring ~370 MB and round-tripping it to GitHub's cloud cache on
every run. The toolchain binaries stay baked at /usr/local/cargo/bin
(still first on PATH) and rustup resolves toolchains via RUSTUP_HOME, so
only the registry/git cache and compiled artifacts relocate.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

@wavekat-eason wavekat-eason merged commit 730d95f into main May 23, 2026
2 checks passed
@wavekat-eason wavekat-eason deleted the ci/persistent-cargo-target branch May 23, 2026 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant