From e59a0c94ab5b22932ffd9220ea4c035b00942bfb Mon Sep 17 00:00:00 2001 From: FredApps Date: Wed, 11 Nov 2026 13:57:21 +0100 Subject: [PATCH] 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 --- .github/workflows/gate.yml | 11 ++++++----- README.md | 6 +++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/.github/workflows/gate.yml b/.github/workflows/gate.yml index f8f3474..3997bf3 100644 --- a/.github/workflows/gate.yml +++ b/.github/workflows/gate.yml @@ -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" diff --git a/README.md b/README.md index 8c4fcc3..c477398 100644 --- a/README.md +++ b/README.md @@ -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;