Skip to content

Commit 9170a1c

Browse files
committed
[PM-29567] Cache cargo-run-bin tools in the lint workflow
cargo-run-bin builds its tools into .bin, which was not cached, so every lint check rebuilt its tools from source each run. Cache .bin with a dedicated actions/cache step rather than via rust-cache's cache-directories. rust-cache keys every matrix check under one shared job-based key (so only the first check to save wins, and the others rebuild their tools anyway) and folds in the Cargo.lock hash (which rotates every day or two). The tools depend only on their pinned versions and the toolchain, so key on Cargo.toml + rust-toolchain.toml per check instead, with restore-keys for graceful fallback.
1 parent bfe97b2 commit 9170a1c

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

.github/workflows/lint.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,20 @@ jobs:
9797
if: matrix.needs_rust
9898
uses: Swatinem/rust-cache@779680da715d629ac1d338a641029a2f4372abb5 # v2.8.2
9999

100+
# Cache cargo-run-bin's built tools (.bin) separately from rust-cache. The
101+
# tools depend only on their pinned versions (Cargo.toml) and the toolchain,
102+
# not on Cargo.lock, so this key avoids rust-cache's lockfile rotation. Keyed
103+
# per check so each one caches only the tools it builds, with no contention
104+
# (rust-cache keys all matrix checks under one shared job-based key).
105+
- name: Cache cargo-run-bin tools
106+
if: matrix.needs_rust
107+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
108+
with:
109+
path: .bin
110+
key: cargo-bin-${{ runner.os }}-${{ matrix.check }}-${{ hashFiles('Cargo.toml', 'rust-toolchain.toml') }}
111+
restore-keys: |
112+
cargo-bin-${{ runner.os }}-${{ matrix.check }}-
113+
100114
- name: Install cargo-run-bin
101115
if: matrix.needs_rust
102116
run: cargo install cargo-run-bin --locked --version 1.7.4

0 commit comments

Comments
 (0)