From 8d545a7945670cbb41d19dc7a89e335e351c1a0c Mon Sep 17 00:00:00 2001 From: Eason WaveKat Date: Sun, 24 May 2026 10:06:11 +1200 Subject: [PATCH] ci: persist cargo caches on runner volume 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) --- scripts/docker/Dockerfile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/scripts/docker/Dockerfile b/scripts/docker/Dockerfile index 527203d..a7dc908 100644 --- a/scripts/docker/Dockerfile +++ b/scripts/docker/Dockerfile @@ -60,6 +60,20 @@ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \ && rustc --version \ && cargo --version +# Relocate cargo's caches onto the runner's persistent volume (mounted at +# /home/runner/runner) for runtime. The toolchain binaries stay baked in +# the image at /usr/local/cargo/bin (still first on PATH, set above) and +# rustup resolves toolchains via RUSTUP_HOME — only the registry/git +# cache (CARGO_HOME) and compiled artifacts (CARGO_TARGET_DIR) move. +# +# Why this matters: workflows run `actions/checkout`, which `git clean`s +# the checkout's `target/` every run. With these dirs OUTSIDE the checkout +# (siblings of `_work` on the same volume), build output survives both the +# git-clean and container recreation — so CI stays warm without uploading +# a cache to GitHub's cloud on every run. +ENV CARGO_HOME=/home/runner/runner/cargo-home \ + CARGO_TARGET_DIR=/home/runner/runner/cargo-target + # Non-root runner user. Passwordless sudo so workflows can still do # `sudo apt-get install ...` for one-off deps — safe inside the # container's isolated rootfs.