ci: save main sccache right after build; pull requests only read it #1733

Merged
tedin7 merged 4 commits from upstream-pr/1740 into main 2026-11-25 14:56:57 +00:00
tedin7 commented 2026-11-24 18:00:45 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T18:00:45Z.


What

Two changes in .github/workflows/windows.yml, from the CI audit of the 20-minute timeouts on main pushes. Nothing in the ctest lines is touched, so this does not overlap #1173 (git merge-tree of this branch against #1173: 0 conflicts, and the merged workflow still parses and keeps --parallel 4).

A. Main saves its compiler cache right after the build.

  • Measured on main at 17:13 UTC (run 45445914677): the dev and /O2 jobs both log Cache not found for input keys: sccache-...-dev- and then Cache hits 0 / Cache misses 765. gh api shows no sccache entry on refs/heads/main, only per-PR ones.
  • actions/cache saves in its post step and only if the job succeeds; the cold job (build 515 s dev, 645 s /O2, then up to 751 serial tests) hits timeout-minutes: 20 first, so nothing is saved and the next run is cold again.
  • Now, on non-PR events, the build runs in its own step (Build on Windows / Build on Windows at /O2), actions/cache/save runs straight after it with !cancelled() && github.event_name != 'pull_request' && steps.build.outcome != 'skipped' (so a failed build still saves its objects), and only then the existing test step runs. The existing step is not edited: its cmake --build becomes a no-op (cost: a second cmake --preset configure, about 12 s measured, plus an up-to-date ninja check).
  • Expected effect: pull request runs on the same sccache go from 59-70 s (0/82 hits) to 14-17 s (81/82 hits) in the preset pr build (measured, runs 45452219940 and 45451614588); main's dev and /O2 builds should drop by a similar factor once warm. That scale-up is an estimate until the first main runs after merge.

B. Pull requests stop filling the repository cache.

  • gh api actions/cache/usage: 10.94 GB active in 244 entries (limit 10 GB). The 100 newest entries (17:06 to 17:53 UTC) were 41 pip caches of 74 MB (3.0 GB) and 57 sccache-pr caches of about 22 MB (1.25 GB), about 5.5 GB per hour, which evicts main's entries first.
  • The Windows jobs use cache: 'pip' only outside pull requests, and the compiler cache step is now actions/cache/restore with the -dev- / -release- prefix as restore key. Pull requests read main's entries (a PR can read its base branch's caches) and write none. The Linux job's 1 MB pip cache is unchanged.

Not verified (read this)

Linux only: no Actions run of this workflow. Done locally: yaml.safe_load of the workflow and of the merge with #1173; checks that every ${{ }} is balanced, step ids are defined before use, restore and save use identical key and path, no remaining actions/cache@ for sccache; git diff --check; docs_links_check.py; bidi_controls_check.py; dev_ps1_sccache_check.py (text only, no pwsh here). To confirm after merge: the save step appears in the main run log (Cache saved with key: sccache-...) and the next main run shows hits. Open points: the first main run after merge is still cold (about 515 s and 645 s build, inside the 20 minutes); the key includes a hash of all sources, so each push that completes the build writes one new entry of roughly 70 MB, which is bounded by the 2 GB SCCACHE_CACHE_SIZE per entry and by the eviction of old ones.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:issue:6588178891 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1740). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T18:00:45Z. --- ## What Two changes in `.github/workflows/windows.yml`, from the CI audit of the 20-minute timeouts on main pushes. Nothing in the `ctest` lines is touched, so this does not overlap #1173 (`git merge-tree` of this branch against #1173: 0 conflicts, and the merged workflow still parses and keeps `--parallel 4`). **A. Main saves its compiler cache right after the build.** - Measured on main at 17:13 UTC (run 45445914677): the dev and /O2 jobs both log `Cache not found for input keys: sccache-...-dev-` and then `Cache hits 0 / Cache misses 765`. `gh api` shows no sccache entry on `refs/heads/main`, only per-PR ones. - `actions/cache` saves in its post step and only if the job succeeds; the cold job (build 515 s dev, 645 s /O2, then up to 751 serial tests) hits `timeout-minutes: 20` first, so nothing is saved and the next run is cold again. - Now, on non-PR events, the build runs in its own step (`Build on Windows` / `Build on Windows at /O2`), `actions/cache/save` runs straight after it with `!cancelled() && github.event_name != 'pull_request' && steps.build.outcome != 'skipped'` (so a failed build still saves its objects), and only then the existing test step runs. The existing step is not edited: its `cmake --build` becomes a no-op (cost: a second `cmake --preset` configure, about 12 s measured, plus an up-to-date ninja check). - Expected effect: pull request runs on the same sccache go from 59-70 s (0/82 hits) to 14-17 s (81/82 hits) in the preset `pr` build (measured, runs 45452219940 and 45451614588); main's dev and /O2 builds should drop by a similar factor once warm. That scale-up is an estimate until the first main runs after merge. **B. Pull requests stop filling the repository cache.** - `gh api` `actions/cache/usage`: 10.94 GB active in 244 entries (limit 10 GB). The 100 newest entries (17:06 to 17:53 UTC) were 41 pip caches of 74 MB (3.0 GB) and 57 sccache-pr caches of about 22 MB (1.25 GB), about 5.5 GB per hour, which evicts main's entries first. - The Windows jobs use `cache: 'pip'` only outside pull requests, and the compiler cache step is now `actions/cache/restore` with the `-dev-` / `-release-` prefix as restore key. Pull requests read main's entries (a PR can read its base branch's caches) and write none. The Linux job's 1 MB pip cache is unchanged. ## Not verified (read this) Linux only: no Actions run of this workflow. Done locally: `yaml.safe_load` of the workflow and of the merge with #1173; checks that every `${{ }}` is balanced, step ids are defined before use, restore and save use identical key and path, no remaining `actions/cache@` for sccache; `git diff --check`; `docs_links_check.py`; `bidi_controls_check.py`; `dev_ps1_sccache_check.py` (text only, no pwsh here). To confirm after merge: the save step appears in the main run log (`Cache saved with key: sccache-...`) and the next main run shows hits. Open points: the first main run after merge is still cold (about 515 s and 645 s build, inside the 20 minutes); the key includes a hash of all sources, so each push that completes the build writes one new entry of roughly 70 MB, which is bounded by the 2 GB `SCCACHE_CACHE_SIZE` per entry and by the eviction of old ones. AI-assisted; commands listed were executed locally.
upstream-sync changed title from [PR #1740] ci: save the main sccache right after the build; pull requests only read it to [PR #1740] ci: save main sccache right after build; pull requests only read it 2026-11-24 19:01:12 +00:00
chatgpt-codex-connector[bot commented 2026-11-24 19:01:13 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T18:16:59Z.

Review: COMMENTED


💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9f96425eba

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6044886162 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1740#pullrequestreview-6044886162). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T18:16:59Z. **Review:** COMMENTED --- <!-- codex-review-receipt:v1 --> ### 💡 Codex Review Here are some automated review suggestions for this pull request. **Reviewed commit:** `9f96425eba` <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". </details>
tedin7 commented 2026-11-24 19:01:13 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T18:37:21Z.

Review: COMMENTED


No description provided.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review:6045169118 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1740#pullrequestreview-6045169118). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T18:37:21Z. **Review:** COMMENTED --- _No description provided._
chatgpt-codex-connector[bot commented 2026-11-24 19:01:39 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T18:11:46Z.


Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-24T18:17:02.320326Z 9f96425 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7140295566 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1740#issuecomment-7140295566). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T18:11:46Z. --- <!-- codex-pull-request-review-summary --> <!-- codex-review-state:v1 {"code_review":{"commit_sha":"9f96425eba57b6ae61ee58341dc57e9c08b0066e","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} --> <details> <summary><strong>Codex Review Summary</strong>: ✅ Completed</summary> This comment shows the latest Codex review activity on this pull request. | Review | Status | Commit | Review trigger | | --- | --- | --- | --- | | 📝 **Code Review** | ✅ **Completed** <relative-time datetime="2026-11-24T18:17:02.320326Z">2026-11-24T18:17:02.320326Z</relative-time> | `9f96425` | Draft marked ready | <details> <summary>ℹ️ About Codex in GitHub</summary> <br/> [Your team has set up Codex to review pull requests in this repo](https://chatgpt.com/codex/cloud/settings/general). Reviews are triggered when you - Open a pull request for review - Mark a draft as ready - Comment "@codex review" or "@codex security review". Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. </details> </details>
chatgpt-codex-connector[bot commented 2026-11-24 19:01:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by chatgpt-codex-connector[bot] on 2026-11-24T18:16:59Z.

Code review location: .github/workflows/windows.yml; line 254

@@ -221,14 +221,37 @@ jobs:
         run: .\tools\setup-spirv-tools.ps1
       - name: Install sccache
         uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11
+      # Only main saves the compiler cache; pull requests read it (restore-keys) and never write a
+      # per-PR copy, which filled the repository cache limit. The cache is saved right after the
+      # build, before the tests, so a run that later times out still leaves a warm cache behind.
       - name: Restore compiler cache
-        uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
+        id: sccache-restore
+        uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
         with:
           path: ${{ runner.temp }}/sccache
-          key: sccache-${{ runner.os }}-msvc-${{ steps.toolset.outputs.msvc }}-${{ github.event_name == 'pull_request' && 'pr' || 'dev' }}-${{ hashFiles('CMakeLists.txt', 'CMakePresets.json', 'cmake/**', '**/*.c', '**/*.cc', '**/*.cpp', '**/*.h', '**/*.hpp', '**/*.inc', '**/*.inl', '**/*.asm') }}
+          key: sccache-${{ runner.os }}-msvc-${{ steps.toolset.outputs.msvc }}-dev-${{ hashFiles('CMakeLists.txt', 'CMakePresets.json', 'cmake/**', '**/*.c', '**/*.cc', '**/*.cpp', '**/*.h', '**/*.hpp', '**/*.inc', '**/*.inl', '**/*.asm') }}
           restore-keys: |
-            sccache-${{ runner.os }}-msvc-${{ steps.toolset.outputs.msvc }}-${{ github.event_name == 'pull_request' && 'pr' || 'dev' }}-
             sccache-${{ runner.os }}-msvc-${{ steps.toolset.outputs.msvc }}-dev-
+      - name: Build on Windows
+        id: build
+        if: github.event_name != 'pull_request'
+        shell: pwsh
+        env:
+          X2W_REQUIRE_SPIRV_TOOLS: '1'
+          X2W_USE_SCCACHE: '1'
+        run: |
+          .\tools\dev.ps1
+          cmake --preset dev @X2wSccacheCmakeArgs
+          if ($LASTEXITCODE) { exit $LASTEXITCODE }
+          cmake --build --preset dev
+          if ($LASTEXITCODE) { exit $LASTEXITCODE }
+          if (Get-Command sccache -CommandType Application -ErrorAction SilentlyContinue) { sccache --show-stats }
+      - name: Save compiler cache
+        if: ${{ !cancelled() && github.event_name != 'pull_request' && steps.build.outcome != 'skipped' && steps.sccache-restore.outputs.cache-hit != 'true' }}
+        uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
+        with:
+          path: ${{ runner.temp }}/sccache
+          key: sccache-${{ runner.os }}-msvc-${{ steps.toolset.outputs.msvc }}-dev-${{ hashFiles('CMakeLists.txt', 'CMakePresets.json', 'cmake/**', '**/*.c', '**/*.cc', '**/*.cpp', '**/*.h', '**/*.hpp', '**/*.inc', '**/*.inl', '**/*.asm') }}

P2 Badge Save with the cache key computed before the build

When a new source revision is built on a clean Windows runner, CMake writes generated headers/C++ into out/build/... (CMakeLists.txt:465-471 is one concrete example). Those files match this hashFiles call, so evaluating it after the build produces a different key from the restore step's pre-build key. Identical reruns then fall back to restore-keys rather than getting an exact hit, leaving the save condition true and causing needless archive/save attempts in both Windows jobs even when the cache is already warm. Reuse ${{ steps.sccache-restore.outputs.cache-primary-key }} for both saves, or exclude the generated out/** tree from both hashes.

AGENTS.md reference: AGENTS.md:L28-L29

Useful? React with 👍 / 👎.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4684536647 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1740#discussion_r4684536647). Originally posted by [chatgpt-codex-connector[bot]](https://github.com/chatgpt-codex-connector%5Bbot%5D) on 2026-11-24T18:16:59Z. **Code review location:** `.github/workflows/windows.yml`; line 254 ~~~~diff @@ -221,14 +221,37 @@ jobs: run: .\tools\setup-spirv-tools.ps1 - name: Install sccache uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11 + # Only main saves the compiler cache; pull requests read it (restore-keys) and never write a + # per-PR copy, which filled the repository cache limit. The cache is saved right after the + # build, before the tests, so a run that later times out still leaves a warm cache behind. - name: Restore compiler cache - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 + id: sccache-restore + uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 with: path: ${{ runner.temp }}/sccache - key: sccache-${{ runner.os }}-msvc-${{ steps.toolset.outputs.msvc }}-${{ github.event_name == 'pull_request' && 'pr' || 'dev' }}-${{ hashFiles('CMakeLists.txt', 'CMakePresets.json', 'cmake/**', '**/*.c', '**/*.cc', '**/*.cpp', '**/*.h', '**/*.hpp', '**/*.inc', '**/*.inl', '**/*.asm') }} + key: sccache-${{ runner.os }}-msvc-${{ steps.toolset.outputs.msvc }}-dev-${{ hashFiles('CMakeLists.txt', 'CMakePresets.json', 'cmake/**', '**/*.c', '**/*.cc', '**/*.cpp', '**/*.h', '**/*.hpp', '**/*.inc', '**/*.inl', '**/*.asm') }} restore-keys: | - sccache-${{ runner.os }}-msvc-${{ steps.toolset.outputs.msvc }}-${{ github.event_name == 'pull_request' && 'pr' || 'dev' }}- sccache-${{ runner.os }}-msvc-${{ steps.toolset.outputs.msvc }}-dev- + - name: Build on Windows + id: build + if: github.event_name != 'pull_request' + shell: pwsh + env: + X2W_REQUIRE_SPIRV_TOOLS: '1' + X2W_USE_SCCACHE: '1' + run: | + .\tools\dev.ps1 + cmake --preset dev @X2wSccacheCmakeArgs + if ($LASTEXITCODE) { exit $LASTEXITCODE } + cmake --build --preset dev + if ($LASTEXITCODE) { exit $LASTEXITCODE } + if (Get-Command sccache -CommandType Application -ErrorAction SilentlyContinue) { sccache --show-stats } + - name: Save compiler cache + if: ${{ !cancelled() && github.event_name != 'pull_request' && steps.build.outcome != 'skipped' && steps.sccache-restore.outputs.cache-hit != 'true' }} + uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 + with: + path: ${{ runner.temp }}/sccache + key: sccache-${{ runner.os }}-msvc-${{ steps.toolset.outputs.msvc }}-dev-${{ hashFiles('CMakeLists.txt', 'CMakePresets.json', 'cmake/**', '**/*.c', '**/*.cc', '**/*.cpp', '**/*.h', '**/*.hpp', '**/*.inc', '**/*.inl', '**/*.asm') }} ~~~~ --- **<sub><sub>![P2 Badge](https://img.shields.io/badge/P2-yellow?style=flat)</sub></sub> Save with the cache key computed before the build** When a new source revision is built on a clean Windows runner, CMake writes generated headers/C++ into `out/build/...` (`CMakeLists.txt:465-471` is one concrete example). Those files match this `hashFiles` call, so evaluating it after the build produces a different key from the restore step's pre-build key. Identical reruns then fall back to `restore-keys` rather than getting an exact hit, leaving the save condition true and causing needless archive/save attempts in both Windows jobs even when the cache is already warm. Reuse `${{ steps.sccache-restore.outputs.cache-primary-key }}` for both saves, or exclude the generated `out/**` tree from both hashes. AGENTS.md reference: [AGENTS.md:L28-L29](https://github.com/R0Y00/Xbox2Windows/blob/9f96425eba57b6ae61ee58341dc57e9c08b0066e/AGENTS.md#L28-L29) Useful? React with 👍 / 👎. <!-- codex-code-review-finding:v1 -->
tedin7 commented 2026-11-24 19:01:44 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-24T18:37:21Z.

Code review location: .github/workflows/windows.yml; line 254

@@ -221,14 +221,37 @@ jobs:
         run: .\tools\setup-spirv-tools.ps1
       - name: Install sccache
         uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11
+      # Only main saves the compiler cache; pull requests read it (restore-keys) and never write a
+      # per-PR copy, which filled the repository cache limit. The cache is saved right after the
+      # build, before the tests, so a run that later times out still leaves a warm cache behind.
       - name: Restore compiler cache
-        uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
+        id: sccache-restore
+        uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
         with:
           path: ${{ runner.temp }}/sccache
-          key: sccache-${{ runner.os }}-msvc-${{ steps.toolset.outputs.msvc }}-${{ github.event_name == 'pull_request' && 'pr' || 'dev' }}-${{ hashFiles('CMakeLists.txt', 'CMakePresets.json', 'cmake/**', '**/*.c', '**/*.cc', '**/*.cpp', '**/*.h', '**/*.hpp', '**/*.inc', '**/*.inl', '**/*.asm') }}
+          key: sccache-${{ runner.os }}-msvc-${{ steps.toolset.outputs.msvc }}-dev-${{ hashFiles('CMakeLists.txt', 'CMakePresets.json', 'cmake/**', '**/*.c', '**/*.cc', '**/*.cpp', '**/*.h', '**/*.hpp', '**/*.inc', '**/*.inl', '**/*.asm') }}
           restore-keys: |
-            sccache-${{ runner.os }}-msvc-${{ steps.toolset.outputs.msvc }}-${{ github.event_name == 'pull_request' && 'pr' || 'dev' }}-
             sccache-${{ runner.os }}-msvc-${{ steps.toolset.outputs.msvc }}-dev-
+      - name: Build on Windows
+        id: build
+        if: github.event_name != 'pull_request'
+        shell: pwsh
+        env:
+          X2W_REQUIRE_SPIRV_TOOLS: '1'
+          X2W_USE_SCCACHE: '1'
+        run: |
+          .\tools\dev.ps1
+          cmake --preset dev @X2wSccacheCmakeArgs
+          if ($LASTEXITCODE) { exit $LASTEXITCODE }
+          cmake --build --preset dev
+          if ($LASTEXITCODE) { exit $LASTEXITCODE }
+          if (Get-Command sccache -CommandType Application -ErrorAction SilentlyContinue) { sccache --show-stats }
+      - name: Save compiler cache
+        if: ${{ !cancelled() && github.event_name != 'pull_request' && steps.build.outcome != 'skipped' && steps.sccache-restore.outputs.cache-hit != 'true' }}
+        uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
+        with:
+          path: ${{ runner.temp }}/sccache
+          key: sccache-${{ runner.os }}-msvc-${{ steps.toolset.outputs.msvc }}-dev-${{ hashFiles('CMakeLists.txt', 'CMakePresets.json', 'cmake/**', '**/*.c', '**/*.cc', '**/*.cpp', '**/*.h', '**/*.hpp', '**/*.inc', '**/*.inl', '**/*.asm') }}

Fixed in d65ac1d2:

  • Reused ${{ steps.sccache-restore.outputs.cache-primary-key }} in both dev and release Save compiler cache (actions/cache/[email protected]) steps so the saved key always matches the pre-build key resolved by sccache-restore (actions/cache/[email protected]).
  • Added '!out/**' to hashFiles(...) in both Restore compiler cache steps so pre-build files under out/ cannot affect the primary key either.

Verified locally with /usr/bin/python3 -c "import yaml; yaml.safe_load(open('.github/workflows/windows.yml'))", git diff --check origin/main...HEAD, python3 tests/docs_links_check.py, and python3 tests/bidi_controls_check.py.

AI-assisted; commands listed were executed locally.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:review-comment:4684775027 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1740#discussion_r4684775027). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-24T18:37:21Z. **Code review location:** `.github/workflows/windows.yml`; line 254 ~~~~diff @@ -221,14 +221,37 @@ jobs: run: .\tools\setup-spirv-tools.ps1 - name: Install sccache uses: mozilla-actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11 + # Only main saves the compiler cache; pull requests read it (restore-keys) and never write a + # per-PR copy, which filled the repository cache limit. The cache is saved right after the + # build, before the tests, so a run that later times out still leaves a warm cache behind. - name: Restore compiler cache - uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 + id: sccache-restore + uses: actions/cache/restore@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 with: path: ${{ runner.temp }}/sccache - key: sccache-${{ runner.os }}-msvc-${{ steps.toolset.outputs.msvc }}-${{ github.event_name == 'pull_request' && 'pr' || 'dev' }}-${{ hashFiles('CMakeLists.txt', 'CMakePresets.json', 'cmake/**', '**/*.c', '**/*.cc', '**/*.cpp', '**/*.h', '**/*.hpp', '**/*.inc', '**/*.inl', '**/*.asm') }} + key: sccache-${{ runner.os }}-msvc-${{ steps.toolset.outputs.msvc }}-dev-${{ hashFiles('CMakeLists.txt', 'CMakePresets.json', 'cmake/**', '**/*.c', '**/*.cc', '**/*.cpp', '**/*.h', '**/*.hpp', '**/*.inc', '**/*.inl', '**/*.asm') }} restore-keys: | - sccache-${{ runner.os }}-msvc-${{ steps.toolset.outputs.msvc }}-${{ github.event_name == 'pull_request' && 'pr' || 'dev' }}- sccache-${{ runner.os }}-msvc-${{ steps.toolset.outputs.msvc }}-dev- + - name: Build on Windows + id: build + if: github.event_name != 'pull_request' + shell: pwsh + env: + X2W_REQUIRE_SPIRV_TOOLS: '1' + X2W_USE_SCCACHE: '1' + run: | + .\tools\dev.ps1 + cmake --preset dev @X2wSccacheCmakeArgs + if ($LASTEXITCODE) { exit $LASTEXITCODE } + cmake --build --preset dev + if ($LASTEXITCODE) { exit $LASTEXITCODE } + if (Get-Command sccache -CommandType Application -ErrorAction SilentlyContinue) { sccache --show-stats } + - name: Save compiler cache + if: ${{ !cancelled() && github.event_name != 'pull_request' && steps.build.outcome != 'skipped' && steps.sccache-restore.outputs.cache-hit != 'true' }} + uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 + with: + path: ${{ runner.temp }}/sccache + key: sccache-${{ runner.os }}-msvc-${{ steps.toolset.outputs.msvc }}-dev-${{ hashFiles('CMakeLists.txt', 'CMakePresets.json', 'cmake/**', '**/*.c', '**/*.cc', '**/*.cpp', '**/*.h', '**/*.hpp', '**/*.inc', '**/*.inl', '**/*.asm') }} ~~~~ --- Fixed in d65ac1d2: - Reused `${{ steps.sccache-restore.outputs.cache-primary-key }}` in both dev and release `Save compiler cache` (`actions/cache/[email protected]`) steps so the saved key always matches the pre-build key resolved by `sccache-restore` (`actions/cache/[email protected]`). - Added `'!out/**'` to `hashFiles(...)` in both `Restore compiler cache` steps so pre-build files under `out/` cannot affect the primary key either. Verified locally with `/usr/bin/python3 -c "import yaml; yaml.safe_load(open('.github/workflows/windows.yml'))"`, `git diff --check origin/main...HEAD`, `python3 tests/docs_links_check.py`, and `python3 tests/bidi_controls_check.py`. AI-assisted; commands listed were executed locally.
ChazY11 commented 2026-11-24 22:01:04 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by ChazY11 on 2026-11-24T21:43:24Z.


The premise and the shape both check out

Cache state, from the API rather than the logs:

$ gh api 'repos/R0Y00/Xbox2Windows/actions/caches?ref=refs/heads/main'
total_count: 2                      # everything main holds, any key
$ gh api 'repos/R0Y00/Xbox2Windows/actions/caches?key=sccache'
total_count: 126                    # sccache entries repo-wide

So the 126 sccache caches are attached to anything but main, which matches what the PR read out of the run logs
(Cache not found for input keys: sccache-...-dev-). That is the mechanism the change targets, and it is real.

Shape: the patch adds two Restore compiler cache steps, two Build on Windows steps and two Save compiler cache steps,
i.e. both the dev job and the /O2 job, not just one.

Details that are right, and one I would change

Right, and worth saying so because they are the things that usually go wrong here:

  • The restore key is now literal …-dev-… / …-release-… instead of …-{{ pr|dev }}-…, so a pull request restores main's
    entry. The restore-keys prefix was changed with it (line 233–234 of the file holds sccache-…-dev-), so PR runs do not
    fall back to their own old pr keys.
  • Save uses key: ${{ steps.sccache-restore.outputs.cache-primary-key }} — the exact key that was looked up, not the key that
    happened to match. With restore-keys partial hits that is the correct pairing.
  • The two jobs save under different suffixes (-dev- vs -release-), so neither can collide with the other and fail to reserve
    a key.
  • steps.sccache-restore.outputs.cache-hit != 'true' means an exact hit does not re-save, while a partial restore does.

What I would change: actions/cache/save has no continue-on-error. A cache failure — quota, or two runs racing for the
same key — therefore fails a job that has already built successfully and has not yet run its tests, which turns a cache problem
into a red main. With 126 sccache entries in the repository and 2 GB allowed per entry this is not hypothetical. Adding

continue-on-error: true

to both save steps keeps the benefit (a saved cache) and drops the new failure mode (a lost cache reported as a build failure).
The condition already tolerates a failed build; the step itself should tolerate a failed save.

Minor: steps.build.outcome != 'skipped' is unreachable-false given github.event_name != 'pull_request', since the build step
is skipped only for pull requests. Harmless, but a reader will wonder which of the two guards is meant to do the work.

What I did not verify

The 59–70 s → 14–17 s numbers. I have no way to run these jobs; I checked the cache inventory and the workflow logic, not the
timings. Those come from runs 45452219940 and 45451614588 as cited.

Verdict

The change does what it claims and the cache evidence supports the diagnosis. One suggestion (error-tolerant save) before
merge, since with the build split out, a save failure is now on the critical path of every main run.

Notes

  • AI-assisted review.
<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7145303502 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1740#issuecomment-7145303502). Originally posted by [ChazY11](https://github.com/ChazY11) on 2026-11-24T21:43:24Z. --- ## The premise and the shape both check out **Cache state**, from the API rather than the logs: ```text $ gh api 'repos/R0Y00/Xbox2Windows/actions/caches?ref=refs/heads/main' total_count: 2 # everything main holds, any key $ gh api 'repos/R0Y00/Xbox2Windows/actions/caches?key=sccache' total_count: 126 # sccache entries repo-wide ``` So the 126 sccache caches are attached to anything but `main`, which matches what the PR read out of the run logs (`Cache not found for input keys: sccache-...-dev-`). That is the mechanism the change targets, and it is real. **Shape**: the patch adds two `Restore compiler cache` steps, two `Build on Windows` steps and two `Save compiler cache` steps, i.e. both the `dev` job and the `/O2` job, not just one. ## Details that are right, and one I would change Right, and worth saying so because they are the things that usually go wrong here: - The restore key is now literal `…-dev-…` / `…-release-…` instead of `…-{{ pr|dev }}-…`, so a pull request restores main's entry. The `restore-keys` prefix was changed with it (line 233–234 of the file holds `sccache-…-dev-`), so PR runs do not fall back to their own old `pr` keys. - Save uses `key: ${{ steps.sccache-restore.outputs.cache-primary-key }}` — the exact key that was looked up, not the key that happened to match. With `restore-keys` partial hits that is the correct pairing. - The two jobs save under different suffixes (`-dev-` vs `-release-`), so neither can collide with the other and fail to reserve a key. - `steps.sccache-restore.outputs.cache-hit != 'true'` means an exact hit does not re-save, while a partial restore does. **What I would change**: `actions/cache/save` has no `continue-on-error`. A cache failure — quota, or two runs racing for the same key — therefore fails a job that has already built successfully and has not yet run its tests, which turns a cache problem into a red `main`. With 126 sccache entries in the repository and 2 GB allowed per entry this is not hypothetical. Adding ```yaml continue-on-error: true ``` to both save steps keeps the benefit (a saved cache) and drops the new failure mode (a lost cache reported as a build failure). The condition already tolerates a failed build; the step itself should tolerate a failed save. Minor: `steps.build.outcome != 'skipped'` is unreachable-false given `github.event_name != 'pull_request'`, since the build step is skipped only for pull requests. Harmless, but a reader will wonder which of the two guards is meant to do the work. ## What I did not verify The 59–70 s → 14–17 s numbers. I have no way to run these jobs; I checked the cache inventory and the workflow logic, not the timings. Those come from runs 45452219940 and 45451614588 as cited. ## Verdict The change does what it claims and the cache evidence supports the diagnosis. One suggestion (error-tolerant save) before merge, since with the build split out, a save failure is now on the critical path of every `main` run. ## Notes - AI-assisted review.
tedin7 commented 2026-11-25 11:02:34 +00:00 (Migrated from github.com)

Imported from R0Y00/Xbox2Windows. Originally posted by tedin7 on 2026-11-25T10:59:54Z.


Thanks @ChazY11, good catch. Done in 72e4cea4: continue-on-error: true is now on both Save compiler cache steps, so a failed save no longer turns a built job red.

<!-- greyfinch-sync:R0Y00/Xbox2Windows:comment:7160449576 --> Imported from [R0Y00/Xbox2Windows](https://github.com/R0Y00/Xbox2Windows/pull/1740#issuecomment-7160449576). Originally posted by [tedin7](https://github.com/tedin7) on 2026-11-25T10:59:54Z. --- Thanks @ChazY11, good catch. Done in 72e4cea4: `continue-on-error: true` is now on both `Save compiler cache` steps, so a failed save no longer turns a built job red.
upstream-sync closed this pull request 2026-11-25 15:01:27 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
R0Y00/Xbox2Windows!1733
No description provided.