gate: key sccache's cache on Cargo.toml and build.rs only

clippy records clippy.toml in its dep-info, so sccache already sees it.
The one setting sccache leaves out is --check-cfg, declared in Cargo.toml
lints and build scripts. Correct the comment and README.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
FredAppsandClaude Opus 5.5 committed 2026-11-11 13:57:21 +01:00
1 parent 89b1e8c6ba
commit e59a0c94ab
2 files changed
+9 -8

No files matched your search

+6 -5
View File
@@ -79,7 +79,7 @@ on:
required: false
default: true
sccache:
description: "Also cache the workspace crates' compiled libraries (which rust-cache leaves out) with sccache in the GitHub Actions cache. It writes where the dependency cache is saved (pushes to the default branch, opted-in manual runs); other runs read those entries. SCCACHE_GHA_RW_MODE in `env` overrides that. Test executables are never cached. Its cache starts afresh when cache-version or a Cargo.toml, build.rs or clippy.toml changes; bump cache-version when files a procedural macro reads change (see the README)"
description: "Also cache the workspace crates' compiled libraries (which rust-cache leaves out) with sccache in the GitHub Actions cache. It writes where the dependency cache is saved (pushes to the default branch, opted-in manual runs); other runs read those entries. SCCACHE_GHA_RW_MODE in `env` overrides that. Test executables are never cached. Its cache starts afresh when cache-version, a Cargo.toml or a build.rs changes; bump cache-version when files a procedural macro reads change (see the README)"
type: boolean
required: false
default: false
@@ -283,10 +283,11 @@ jobs:
shell: bash
env:
WRITES: ${{ github.event_name != 'pull_request' && (github.ref_name == github.event.repository.default_branch || (inputs.cache-save-on-dispatch && github.event_name == 'workflow_dispatch')) }}
# sccache's key leaves out lint settings that only change diagnostics (`--check-cfg`,
# clippy.toml), so a cached compile would replay its old warnings. A change to the files
# that declare them, or to cache-version, starts a fresh sccache cache instead.
VERSION: ${{ inputs.cache-version }}-${{ hashFiles('**/Cargo.toml', '**/build.rs', '**/clippy.toml', '**/.clippy.toml') }}
# sccache leaves `--check-cfg` out of its key, so after a change to the expected cfgs a
# cached compile would replay its old `unexpected_cfgs` warnings. A change to the files
# that declare them (Cargo.toml lints, build scripts), or to cache-version, starts a
# fresh sccache cache instead.
VERSION: ${{ inputs.cache-version }}-${{ hashFiles('**/Cargo.toml', '**/build.rs') }}
run: |
echo "SCCACHE_GHA_ENABLED=true" >> "$GITHUB_ENV"
echo "RUSTC_WRAPPER=sccache" >> "$GITHUB_ENV"
+3 -3
View File
@@ -497,9 +497,9 @@ The quality gate for an app's pull requests and pushes to main. It runs `command
library crates, which rust-cache doesn't keep. It writes where the dependency cache saves and
only reads elsewhere; set `SCCACHE_GHA_RW_MODE` in `env` to choose. Test, binary and
proc-macro crates aren't cacheable, so it mainly helps workspaces with many library crates.
sccache's cache starts afresh when `cache-version` or any `Cargo.toml`, `build.rs` or
`clippy.toml` changes, because its key leaves out settings that only change diagnostics
(`--check-cfg` declarations, clippy's configuration). It also can't see files a procedural
sccache's cache starts afresh when `cache-version` or any `Cargo.toml` or `build.rs` changes,
because its key leaves out `--check-cfg`: a cached compile would replay its old
`unexpected_cfgs` warnings after the expected cfgs change. It also can't see files a procedural
macro reads without rustc tracking them (some asset-embedding macros): don't opt in while
such files change often, or bump `cache-version` when they do. `SCCACHE_GHA_VERSION` in
`env` sets the cache's version instead;