From 9e5cf4e8339d294b14417c2b6240e03e4617cbcd Mon Sep 17 00:00:00 2001 From: Kurdistan Tech Ministry Date: Sun, 26 Apr 2026 03:37:12 +0300 Subject: [PATCH] ci(clippy): persistent cache + pre-baked registry for fast warm builds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .gitlab-ci.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 9f935c81..95cb5f6e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -169,7 +169,20 @@ clippy: needs: [fmt] variables: 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: - git config --global --add safe.directory '*' - |