From 28db55efda9a0505f5fd1572a76eb1d1fd81da80 Mon Sep 17 00:00:00 2001 From: sudlud Date: Tue, 21 Jul 2026 18:28:09 +0200 Subject: [PATCH] fix(CI): stop dashboard ccache from freezing after the first run (#26718) Co-authored-by: Claude Opus 4.8 (1M context) --- .github/workflows/dashboard-ci.yml | 31 ++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/.github/workflows/dashboard-ci.yml b/.github/workflows/dashboard-ci.yml index 9e5ca3872..7de0875b0 100644 --- a/.github/workflows/dashboard-ci.yml +++ b/.github/workflows/dashboard-ci.yml @@ -20,8 +20,9 @@ concurrency: # # - PRs use `refs/pull//merge`, so new commits cancel older # in-progress runs for the same PR. - # - When a PR is merged, a push to the target branch starts a new group, - # canceling any still-running PR CI. + # - A merge does NOT cancel the PR's own runs: this group is keyed on + # refs/pull//merge and the master push on refs/heads/master, so they + # never share a group. # - Branch pushes are isolated by ref. group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -137,15 +138,23 @@ jobs: - name: Echo cache key shell: bash - run: echo "Cache key -> ccache:${{ runner.os }}:${{ steps.detect.outputs.cc_id }}_${{ steps.detect.outputs.cxx_id }}:${{ github.ref_name }}" + run: echo "Cache key -> ccache:${{ matrix.os }}:${{ steps.detect.outputs.cc_id }}_${{ steps.detect.outputs.cxx_id }}:${{ github.ref_name }}-${{ github.run_id }}" + # The primary key must be unique per run. A static key hits on itself from + # the second run onward and the save is then skipped, freezing the cache + # at its first-run contents. It is keyed on matrix.os rather than + # runner.os because both legs report Linux and share a run_id, so only the + # detected compiler would separate them. The first restore-key picks up + # the most recent cache for this leg on this ref; the rest keep runner.os + # because they are cross-workflow fallbacks to the linux-build action. - name: Restore ccache id: restore_ccache uses: actions/cache/restore@v4 with: path: ${{ github.workspace }}/var/ccache - key: ccache:${{ runner.os }}:${{ steps.detect.outputs.cc_id }}_${{ steps.detect.outputs.cxx_id }}:${{ github.ref_name }} + key: ccache:${{ matrix.os }}:${{ steps.detect.outputs.cc_id }}_${{ steps.detect.outputs.cxx_id }}:${{ github.ref_name }}-${{ github.run_id }} restore-keys: | + ccache:${{ matrix.os }}:${{ steps.detect.outputs.cc_id }}_${{ steps.detect.outputs.cxx_id }}:${{ github.ref_name }}- ccache:${{ runner.os }}:${{ steps.detect.outputs.cc_id }}_${{ steps.detect.outputs.cxx_id }}:true:pch=false: ccache:${{ runner.os }}:${{ steps.detect.outputs.cc_id }}_${{ steps.detect.outputs.cxx_id }}:false:pch=false: ccache:${{ runner.os }}:${{ steps.detect.outputs.cc_id }}_${{ steps.detect.outputs.cxx_id }}:true:pch=true: @@ -167,7 +176,7 @@ jobs: CCACHE_MAXSIZE=5G CCACHE_SLOPPINESS=pch_defines,time_macros,include_file_mtime CCACHE_COMPRESS=1 - CCACHE_COMPRESSLEVEL=9 + CCACHE_COMPRESSLEVEL=3 CCACHE_COMPILERCHECK=content CCACHE_LOGFILE=${{ github.workspace }}/var/ccache/cache.debug CMAKE_C_COMPILER_LAUNCHER=ccache @@ -273,13 +282,19 @@ jobs: timeout-minutes: 30 continue-on-error: false - # save only if we didn't hit the cache + # The old "only save on a cache miss" guard is dropped: the per-run key + # only ever collides on a re-run, since github.run_id is stable across + # attempts, and there the save is a no-op anyway. + # A failed build still compiled most of the tree and that work is worth + # keeping. A cancelled one is skipped so a superseded run cannot publish + # a half-populated cache as the newest for the ref, and a run that died + # before the restore has no compiler id and no ccache dir to save. - name: Save ccache - if: steps.restore_ccache.outputs.cache-hit != 'true' + if: ${{ !cancelled() && steps.restore_ccache.outcome == 'success' }} uses: actions/cache/save@v4 with: path: ${{ github.workspace }}/var/ccache - key: ccache:${{ runner.os }}:${{ steps.detect.outputs.cc_id }}_${{ steps.detect.outputs.cxx_id }}:${{ github.ref_name }} + key: ccache:${{ matrix.os }}:${{ steps.detect.outputs.cc_id }}_${{ steps.detect.outputs.cxx_id }}:${{ github.ref_name }}-${{ github.run_id }} - name: ccache stats (after) shell: bash