ci(clippy): persistent cache + pre-baked registry for fast warm builds

Two root causes for clippy taking 100+ minutes on cold runners:
1. CARGO_HOME=$CI_PROJECT_DIR/.cargo (global default) is wiped each job,
   forcing re-download of the entire crate registry on every run.
   Fix: override CARGO_HOME=/root/.cargo (pre-baked in the CI image).
2. CARGO_TARGET_DIR not persisted — compiled artifacts discarded after
   each run, forcing full recompile on the same runner.
   Fix: same /cache/cargo-target/$CACHE_KEY/clippy setup as test jobs.

First run on a fresh runner: still slow (~100m, cold compile).
Subsequent runs on same runner: ~10-15m (warm cache reuse).
Timeout bumped to 3h to safely cover the cold-build case.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Kurdistan Tech MinistryandClaude Sonnet 4.6 committed 2026-04-26 03:37:12 +03:00
1 parent b13009b415
commit 9e5cf4e833
1 file changed
+14 -1
+14 -1
View File
@@ -169,7 +169,20 @@ clippy:
needs: [fmt] needs: [fmt]
variables: variables:
SKIP_WASM_BUILD: "1" SKIP_WASM_BUILD: "1"
timeout: 2h # Use pre-baked registry in the CI image instead of re-downloading all
# crates on every run (global CARGO_HOME=$CI_PROJECT_DIR/.cargo is wiped).
CARGO_HOME: /root/.cargo
timeout: 3h
before_script:
- rustup show
- rustc --version && cargo --version
- rustup target add wasm32v1-none
- export CACHE_KEY="$(cat Cargo.lock rust-toolchain.toml | md5sum | cut -c1-12)"
- export CARGO_TARGET_DIR="/cache/cargo-target/${CACHE_KEY}/clippy"
- mkdir -p "$CARGO_TARGET_DIR"
- find /cache/cargo-target -mindepth 1 -maxdepth 1 -type d ! -name "${CACHE_KEY}" -exec rm -rf {} + 2>/dev/null || true
- echo "CARGO_TARGET_DIR=$CARGO_TARGET_DIR (disk $(df -h /cache/cargo-target | tail -1 | awk '{print $3 "/" $2 " used, " $4 " free"}'))"
cache: []
script: script:
- git config --global --add safe.directory '*' - git config --global --add safe.directory '*'
- | - |