Cache workspace member compilation during Clippy#20459
Conversation
|
We might want to stay on stable here, especially since it's not a bottleneck, but I want to see the timings. Nightly lints are nice to check sometimes too. |
|
It's always super awkward and annoying when local dev and CI diverge on what version of clippy to use. At least historically it's been common for stable and nightly to incompatibly disagree on a clippy lint (e.g. if you fix one, the other then breaks, making it impossible to satisfy both at once). So I wouldn't ship this unless we're willing to make nightly be our pin in rust-toolchain.toml (and I don't think we want to be living that life...?). |
| - name: "Install Rust toolchain" | ||
| run: rustup toolchain install nightly-2026-07-13 --profile minimal --component clippy | ||
| - uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 | ||
| env: | ||
| RUSTUP_TOOLCHAIN: nightly-2026-07-13 | ||
| with: | ||
| prefix-key: v1-rust-workspace | ||
| cache-workspace-crates: "true" | ||
| save-if: ${{ inputs.save-rust-cache == 'true' }} | ||
| - name: "Check uv_build dependencies" | ||
| uses: EmbarkStudios/cargo-deny-action@bb137d7af7e4fb67e5f82a49c4fce4fad40782fe # v2.0.20 | ||
| with: | ||
| command: check bans | ||
| manifest-path: crates/uv-build/Cargo.toml | ||
| - name: "Install Rust toolchain" | ||
| run: rustup component add clippy | ||
| - name: "Clippy" | ||
| run: cargo clippy --workspace --all-targets --all-features --locked -- -D warnings | ||
| run: cargo +nightly-2026-07-13 clippy --workspace --all-targets --all-features --locked -Z checksum-freshness -- -D warnings |
There was a problem hiding this comment.
Why do we use + and set RUSTUP_TOOLCHAIN? Isn't only one of those needed?
Also, unsure if we have a new enough rustup, but rustup toolchain install has an --override flag to make the installed toolchain used within this directory. An upcoming version adds a --default so it isn't directory based.
There was a problem hiding this comment.
The environment variable is only set in the Swatinem/rust-cache action where we can't control the command
Clippy currently restores only third-party Rust dependencies, so every run recompiles the uv workspace before linting. Install the pinned nightly toolchain before cache restoration on Linux and Windows, retain workspace-member artifacts under a new cache generation, and use checksum freshness so restored artifacts remain reusable despite changed mtimes.
Pinned nightly also exposes several actionable diagnostics that stable Clippy does not: fix the unbalanced documentation backtick, return ready futures for non-awaiting trait methods, remove redundant
elseblocks, and box the large error variants. The lint scope and-D warningspolicy remain unchanged.Five warm-cache samples on each production runner show lower Clippy and overall job times (Linux, Windows). The table shows stable → optimized means and the change with a 95% confidence interval. Cold compilation and cache saves have one observation per side.
ubuntu-latest)namespace-profile-windows-2022-x86-64-4)The workspace cache adds only about 25–28 MiB compressed. Warm Clippy saves about 27s on Linux and 9s on Windows, while cache-save and restore changes are small or inconclusive.