From 0aa27ec1b081265665f9a12cd6a10248aef4b55c Mon Sep 17 00:00:00 2001 From: Abanoub Doss Date: Wed, 24 Jun 2026 20:49:53 -0500 Subject: [PATCH] ci: key Windows sccache cache on MSVC version --- .github/workflows/sql_catalog_test.yml | 26 +++++++++++++++++++++++--- .github/workflows/test.yml | 24 +++++++++++++++++++++--- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/.github/workflows/sql_catalog_test.yml b/.github/workflows/sql_catalog_test.yml index 768299889..6ff68b58c 100644 --- a/.github/workflows/sql_catalog_test.yml +++ b/.github/workflows/sql_catalog_test.yml @@ -74,6 +74,26 @@ jobs: uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0 with: arch: x64 + # GitHub patches the Windows image roughly weekly via gradual rollouts, so + # back-to-back runs can hit different cl.exe builds. sccache keys on the compiler, + # so a shared key would miss after each bump; the version keeps caches separate. + # Non-Windows legs get an empty suffix, leaving their keys unchanged. + - name: Resolve MSVC version for sccache key + if: ${{ startsWith(matrix.runs-on, 'windows') }} + shell: pwsh + run: | + $PSNativeCommandUseErrorActionPreference = $false + $banner = (cl.exe 2>&1 | Out-String) + if ($banner -match 'Version ([\d.]+)') { + $suffix = "-$($Matches[1])" + } else { + # The key is only a cache hint, so degrade to a shared bucket rather than + # fail the build; the warning flags that the parse needs fixing. + $suffix = '-unknown' + Write-Host "::warning::could not parse cl.exe version for sccache key, using '$suffix'; banner was: $banner" + } + Add-Content -Path $env:GITHUB_ENV -Value "SCCACHE_KEY_SUFFIX=$suffix" + Write-Host "SCCACHE_KEY_SUFFIX=$suffix" - name: Install dependencies on Ubuntu if: ${{ startsWith(matrix.runs-on, 'ubuntu') }} shell: bash @@ -99,9 +119,9 @@ jobs: uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 with: path: ${{ github.workspace }}/.sccache - key: sccache-sqlcatalog-${{ matrix.runs-on }}-${{ github.run_id }} + key: sccache-sqlcatalog-${{ matrix.runs-on }}${{ env.SCCACHE_KEY_SUFFIX }}-${{ github.run_id }} restore-keys: | - sccache-sqlcatalog-${{ matrix.runs-on }}- + sccache-sqlcatalog-${{ matrix.runs-on }}${{ env.SCCACHE_KEY_SUFFIX }}- - name: Setup sccache uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10 - name: Configure Iceberg @@ -129,7 +149,7 @@ jobs: uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 with: path: ${{ github.workspace }}/.sccache - key: sccache-sqlcatalog-${{ matrix.runs-on }}-${{ github.run_id }} + key: sccache-sqlcatalog-${{ matrix.runs-on }}${{ env.SCCACHE_KEY_SUFFIX }}-${{ github.run_id }} - name: Run SQL catalog tests shell: bash run: ctest --test-dir build -R '^sql_catalog_test$' --output-on-failure -C ${{ matrix.cmake_build_type }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e63101194..a51ab537e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -144,6 +144,24 @@ jobs: uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1.13.0 with: arch: x64 + # GitHub patches the Windows image roughly weekly via gradual rollouts, so + # back-to-back runs can hit different cl.exe builds. sccache keys on the compiler, + # so a shared key would miss after each bump; the version keeps caches separate. + - name: Resolve MSVC version for sccache key + shell: pwsh + run: | + $PSNativeCommandUseErrorActionPreference = $false + $banner = (cl.exe 2>&1 | Out-String) + if ($banner -match 'Version ([\d.]+)') { + $msvc = $Matches[1] + } else { + # The key is only a cache hint, so degrade to a shared bucket rather than + # fail the build; the warning flags that the parse needs fixing. + $msvc = 'unknown' + Write-Host "::warning::could not parse cl.exe version for sccache key, using '$msvc'; banner was: $banner" + } + Add-Content -Path $env:GITHUB_ENV -Value "MSVC_VER=$msvc" + Write-Host "Resolved MSVC_VER=$msvc" - name: Cache vcpkg packages uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 id: vcpkg-cache @@ -159,9 +177,9 @@ jobs: uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 with: path: ${{ github.workspace }}/.sccache - key: sccache-test-windows-${{ github.run_id }} + key: sccache-test-windows-${{ env.MSVC_VER }}-${{ github.run_id }} restore-keys: | - sccache-test-windows- + sccache-test-windows-${{ env.MSVC_VER }}- - name: Setup sccache uses: mozilla-actions/sccache-action@9e7fa8a12102821edf02ca5dbea1acd0f89a2696 # v0.0.10 - name: Build Iceberg @@ -176,7 +194,7 @@ jobs: uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 with: path: ${{ github.workspace }}/.sccache - key: sccache-test-windows-${{ github.run_id }} + key: sccache-test-windows-${{ env.MSVC_VER }}-${{ github.run_id }} - name: Build Example shell: pwsh run: |