Fix sccache --show-stats not working sometimes on windows (#48974)

Conrad Irwin created

Closes #ISSUE

- [ ] Tests or screenshots needed?
- [ ] Code Reviewed
- [ ] Manual QA

Release Notes:

- N/A

Change summary

.github/workflows/release.yml              | 4 ++--
.github/workflows/release_nightly.yml      | 4 ++--
.github/workflows/run_tests.yml            | 4 ++--
script/setup-sccache.ps1                   | 4 ++--
tooling/xtask/src/tasks/workflows/steps.rs | 4 +++-
5 files changed, 11 insertions(+), 9 deletions(-)

Detailed changes

.github/workflows/release.yml 🔗

@@ -137,7 +137,7 @@ jobs:
       run: cargo nextest run --workspace --no-fail-fast
       shell: pwsh
     - name: steps::show_sccache_stats
-      run: sccache --show-stats; exit 0
+      run: '& $env:RUSTC_WRAPPER --show-stats; exit 0'
       shell: pwsh
     - name: steps::cleanup_cargo_config
       if: always()
@@ -234,7 +234,7 @@ jobs:
       run: ./script/clippy.ps1
       shell: pwsh
     - name: steps::show_sccache_stats
-      run: sccache --show-stats; exit 0
+      run: '& $env:RUSTC_WRAPPER --show-stats; exit 0'
       shell: pwsh
     timeout-minutes: 60
   check_scripts:

.github/workflows/release_nightly.yml 🔗

@@ -57,7 +57,7 @@ jobs:
       run: cargo nextest run --workspace --no-fail-fast
       shell: pwsh
     - name: steps::show_sccache_stats
-      run: sccache --show-stats; exit 0
+      run: '& $env:RUSTC_WRAPPER --show-stats; exit 0'
       shell: pwsh
     - name: steps::cleanup_cargo_config
       if: always()
@@ -90,7 +90,7 @@ jobs:
       run: ./script/clippy.ps1
       shell: pwsh
     - name: steps::show_sccache_stats
-      run: sccache --show-stats; exit 0
+      run: '& $env:RUSTC_WRAPPER --show-stats; exit 0'
       shell: pwsh
     timeout-minutes: 60
   bundle_linux_aarch64:

.github/workflows/run_tests.yml 🔗

@@ -166,7 +166,7 @@ jobs:
       run: ./script/clippy.ps1
       shell: pwsh
     - name: steps::show_sccache_stats
-      run: sccache --show-stats; exit 0
+      run: '& $env:RUSTC_WRAPPER --show-stats; exit 0'
       shell: pwsh
     timeout-minutes: 60
   clippy_linux:
@@ -271,7 +271,7 @@ jobs:
       run: cargo nextest run --workspace --no-fail-fast${{ needs.orchestrate.outputs.changed_packages && format(' -E "{0}"', needs.orchestrate.outputs.changed_packages) || '' }}
       shell: pwsh
     - name: steps::show_sccache_stats
-      run: sccache --show-stats; exit 0
+      run: '& $env:RUSTC_WRAPPER --show-stats; exit 0'
       shell: pwsh
     - name: steps::cleanup_cargo_config
       if: always()

script/setup-sccache.ps1 🔗

@@ -63,8 +63,8 @@ function Install-Sccache {
 
 function Configure-Sccache {
     if (-not $env:R2_ACCOUNT_ID) {
-        Write-Host "::error::R2_ACCOUNT_ID not set, cannot configure sccache"
-        exit 1
+        Write-Host "R2_ACCOUNT_ID not set, skipping sccache configuration"
+        return
     }
 
     # Verify sccache is available before configuring

tooling/xtask/src/tasks/workflows/steps.rs 🔗

@@ -170,7 +170,9 @@ pub fn setup_sccache(platform: Platform) -> Step<Run> {
 
 pub fn show_sccache_stats(platform: Platform) -> Step<Run> {
     match platform {
-        Platform::Windows => named::pwsh("sccache --show-stats; exit 0"),
+        // Use $env:RUSTC_WRAPPER (absolute path) because GITHUB_PATH changes
+        // don't take effect until the next step in PowerShell
+        Platform::Windows => named::pwsh("& $env:RUSTC_WRAPPER --show-stats; exit 0"),
         Platform::Linux | Platform::Mac => named::bash("sccache --show-stats || true"),
     }
 }