ci: save the dependency caches from build-only warm legs on main

This commit is contained in:
aiongg committed 2026-11-18 14:55:44 +00:00
1 parent 5b9a9f1850
commit 45e01a84c7
1 file changed
+25 -8
+25 -8
View File
@@ -152,6 +152,10 @@ jobs:
PHOTOCRAFT_NO_PRINT=1
LPDEST=photocraft-no-such-printer
timeout-minutes: 100
# On main, a `cache warm` leg builds the tests and saves the dependency cache as soon as the
# build succeeds; the gate legs then only restore, so a failing test cannot keep the entry
# from being saved (craft-common-actions#270). The same targets as the gate's test step (TEST_TARGETS in xtask/src/main.rs).
warm-command: cargo test --workspace --no-run --locked --features heif --lib --bins --tests
# fmt, clippy, layers, panel-commands, scorecard, tests, panic_hunt, doctests and the wasm32 check, with
# `--locked --features heif`, then the missing-translations report (xtask/src/main.rs).
command: python3 scripts/test-ci-gpu-lavapipe.py && python3 scripts/test-ci-windows-gpu-tests.py && cargo xtask ci && python3 scripts/ci-gpu-lavapipe.py
@@ -170,7 +174,9 @@ jobs:
strategy:
fail-fast: false
matrix:
part: [unit, integration, clippy]
# `warm` builds everything the other legs build and saves the dependency cache. Only main
# runs it; the other legs only restore.
part: ${{ fromJSON(github.ref == 'refs/heads/main' && '["unit","integration","clippy","warm"]' || '["unit","integration","clippy"]') }}
env:
# Released sccache expands Cargo's response files and exceeds Windows' rustc spawn limit
# (#13543). Let Cargo handle long commands until a release includes mozilla/sccache#3026.
@@ -241,15 +247,16 @@ jobs:
shell: bash
# Only main saves caches; PRs restore main's, so the repo's 10 GB cache budget keeps main's.
# Both legs share one key (same dependencies); the integration leg saves it, because it also
# runs Clippy and so leaves Clippy's dependency metadata in it. A failed run saves nothing:
# when Clippy fails, the test build never ran, and an entry saved then would lack its
# dependencies. rust-cache never replaces an entry with the same key, so every later run
# All legs share one key (same dependencies). Only the `warm` leg saves it, as soon as the
# build is done and before any test runs, so a failing test never keeps the entry from being
# saved. It also runs Clippy, so the entry holds Clippy's dependency metadata for the `clippy`
# leg. A failed warm run saves nothing: an entry saved from a half-finished build would lack
# dependencies, and rust-cache never replaces an entry with the same key, so every later run
# would restore that half-filled entry until Cargo.lock changes.
- uses: step-security/rust-cache@8871c8ba063416da7c32246932ea6ae08700453e # v2.9.2
with:
workspaces: . -> ${{ steps.cache-target.outputs.relative }}
save-if: ${{ github.ref == 'refs/heads/main' && matrix.part == 'integration' }}
save-if: ${{ github.ref == 'refs/heads/main' && matrix.part == 'warm' }}
cache-on-failure: false
# Clippy has its own parallel leg: after the test build it ran in the integration leg's
@@ -259,7 +266,7 @@ jobs:
run: cargo clippy --workspace --all-targets --locked --features heif -- -D warnings
- uses: step-security/taiki-e-install-action@76747d22a7567cc4438546a84f11bdf18e670ab8 # v2.87.32
if: matrix.part != 'clippy'
if: matrix.part != 'clippy' && matrix.part != 'warm'
with:
tool: [email protected]
@@ -275,6 +282,7 @@ jobs:
run: |
case "$PART" in
unit) targets=(--lib --bins) ;;
warm) targets=(--lib --bins --test '*') ;;
*) targets=(--test '*') ;;
esac
# The two browser apps are wasm targets; their native test builds check nothing the web job
@@ -288,9 +296,18 @@ jobs:
fi
# nextest reuses this build. The separate step writes cargo's --timings report for it.
cargo test --no-run --timings --workspace "${skip[@]}" --locked --features heif "${targets[@]}"
cargo nextest run --profile ci --workspace "${skip[@]}" --locked --features heif "${targets[@]}"
if [ "$PART" != warm ]; then
cargo nextest run --profile ci --workspace "${skip[@]}" --locked --features heif "${targets[@]}"
fi
shell: bash
# Fills the cache entry's Clippy metadata (the `clippy` leg only restores it). A Clippy
# failure is the `clippy` leg's to report, not a reason to skip saving the cache.
- name: Clippy dependency metadata
if: matrix.part == 'warm'
continue-on-error: true
run: cargo clippy --workspace --all-targets --locked --features heif -- -D warnings
# Per-crate compile and link times of this leg's build (open the HTML in a browser).
- name: Upload cargo build timings
if: always() && matrix.part != 'clippy'