diff --git a/.github/workflows/code_style.yml b/.github/workflows/code_style.yml index 9fa2707544..0375b49d0c 100644 --- a/.github/workflows/code_style.yml +++ b/.github/workflows/code_style.yml @@ -49,6 +49,11 @@ jobs: clippy: name: Clippy (${{ matrix.name }}) + # Push events only run the all-features leg. That leg builds a superset + # of artifacts, so it deterministically wins the shared cache slot on + # main/staging refreshes and PR legs always restore from a useful + # starting point. PRs still run all three to enforce lint coverage. + if: github.event_name == 'pull_request' || matrix.name == 'all-features' runs-on: ubuntu-latest strategy: fail-fast: false @@ -71,7 +76,11 @@ jobs: components: clippy - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2 with: - key: clippy-${{ matrix.name }} + # Share a single cache across the clippy matrix. `target/` built for + # --all-features is a superset of the other two legs, so restoring + # from whichever variant saved last is still faster than a cold build + # and avoids storing three near-duplicate copies in the GHA cache. + shared-key: clippy - name: Check lints run: cargo clippy --all --benches --tests --examples ${{ matrix.flags }} -- -D warnings @@ -100,7 +109,7 @@ jobs: components: clippy - uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2 with: - key: clippy-windows-${{ matrix.name }} + shared-key: clippy-windows - name: Check lints run: cargo clippy --all --benches --tests --examples ${{ matrix.flags }} -- -D warnings