From 64a0ea397cf30ce94594899894096d43e04e92de Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Wed, 12 Aug 2026 01:55:34 -0400 Subject: [PATCH] [Perf] (CI): rewrite one rolling ccache entry per job on the default branch instead of saving one per run --- .github/workflows/apk.yml | 30 ++++++++++++++++++--- .github/workflows/test.yml | 53 +++++++++++++++++++++++++++++++++----- 2 files changed, 74 insertions(+), 9 deletions(-) diff --git a/.github/workflows/apk.yml b/.github/workflows/apk.yml index 062e2ca8..4d15e311 100644 --- a/.github/workflows/apk.yml +++ b/.github/workflows/apk.yml @@ -11,6 +11,9 @@ on: jobs: build: runs-on: ubuntu-latest + permissions: + actions: write + contents: read env: CCACHE_BASEDIR: ${{ github.workspace }} CCACHE_COMPRESS: "true" @@ -41,12 +44,11 @@ jobs: gradle-version: 8.10.2 - name: Restore ccache - uses: actions/cache@v5 + uses: actions/cache/restore@v5 with: path: .ccache - key: ${{ runner.os }}-apk-${{ github.job }}-ccache-${{ github.ref_name }}-${{ github.run_id }} + key: ${{ runner.os }}-apk-${{ github.job }}-ccache-v1 restore-keys: | - ${{ runner.os }}-apk-${{ github.job }}-ccache-${{ github.ref_name }}- ${{ runner.os }}-apk-${{ github.job }}-ccache- - name: Install ccache @@ -125,6 +127,28 @@ jobs: if: always() run: ccache --show-stats + # Rewrite one rolling entry per job on the default branch. The upload stays + # cumulative - it carries every object restored at the top of this run plus + # the few TUs that actually changed - but Actions cache keys are immutable, + # so the superseded blob has to be released before the same key can be + # re-uploaded. Running after the build means a failed build leaves the + # existing entry untouched. The other trigger branches restore this entry + # rather than each writing a ~4 GB one of their own. + - name: Release superseded ccache entry + if: github.ref_name == github.event.repository.default_branch + env: + GH_TOKEN: ${{ github.token }} + CACHE_KEY: ${{ runner.os }}-apk-${{ github.job }}-ccache-v1 + run: gh cache delete "${CACHE_KEY}" || true + + - name: Save ccache + if: github.ref_name == github.event.repository.default_branch + continue-on-error: true + uses: actions/cache/save@v5 + with: + path: .ccache + key: ${{ runner.os }}-apk-${{ github.job }}-ccache-v1 + - name: Verify APK metadata and packaging run: | AAPT2="$(find "$ANDROID_HOME/build-tools" -name aapt2 -type f | sort -V | tail -n 1)" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 210bb132..8a680068 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,6 +11,9 @@ on: jobs: build-linux: runs-on: ubuntu-latest + permissions: + actions: write + contents: read env: BUILD_DIR: build-linux CCACHE_BASEDIR: ${{ github.workspace }} @@ -34,12 +37,11 @@ jobs: uses: lukka/get-cmake@v4.3.3 - name: Restore ccache - uses: actions/cache@v5 + uses: actions/cache/restore@v5 with: path: .ccache - key: ${{ runner.os }}-test-${{ github.job }}-ccache-${{ github.ref_name }}-${{ github.run_id }} + key: ${{ runner.os }}-test-${{ github.job }}-ccache-v1 restore-keys: | - ${{ runner.os }}-test-${{ github.job }}-ccache-${{ github.ref_name }}- ${{ runner.os }}-test-${{ github.job }}-ccache- - name: Prepare Vulkan SDK @@ -97,6 +99,28 @@ jobs: if: always() run: ccache --show-stats + # Rewrite one rolling entry per job on the default branch. The upload stays + # cumulative - it carries every object restored at the top of this run plus + # the few TUs that actually changed - but Actions cache keys are immutable, + # so the superseded blob has to be released before the same key can be + # re-uploaded. Running after the build means a failed build leaves the + # existing entry untouched. The other trigger branches restore this entry + # rather than each writing one of their own. + - name: Release superseded ccache entry + if: github.ref_name == github.event.repository.default_branch + env: + GH_TOKEN: ${{ github.token }} + CACHE_KEY: ${{ runner.os }}-test-${{ github.job }}-ccache-v1 + run: gh cache delete "${CACHE_KEY}" || true + + - name: Save ccache + if: github.ref_name == github.event.repository.default_branch + continue-on-error: true + uses: actions/cache/save@v5 + with: + path: .ccache + key: ${{ runner.os }}-test-${{ github.job }}-ccache-v1 + - name: Package Linux runtime run: | mkdir -p ci-artifacts @@ -320,6 +344,9 @@ jobs: - build-linux - test - benchmark + permissions: + actions: write + contents: read env: BUILD_DIR: build-retrace CCACHE_BASEDIR: ${{ github.workspace }} @@ -344,12 +371,11 @@ jobs: uses: lukka/get-cmake@v4.3.3 - name: Restore ccache - uses: actions/cache@v5 + uses: actions/cache/restore@v5 with: path: .ccache - key: ${{ runner.os }}-test-${{ github.job }}-ccache-${{ github.ref_name }}-${{ github.run_id }} + key: ${{ runner.os }}-test-${{ github.job }}-ccache-v1 restore-keys: | - ${{ runner.os }}-test-${{ github.job }}-ccache-${{ github.ref_name }}- ${{ runner.os }}-test-${{ github.job }}-ccache- - name: Prepare Vulkan SDK @@ -415,6 +441,21 @@ jobs: if: always() run: ccache --show-stats + - name: Release superseded ccache entry + if: github.ref_name == github.event.repository.default_branch + env: + GH_TOKEN: ${{ github.token }} + CACHE_KEY: ${{ runner.os }}-test-${{ github.job }}-ccache-v1 + run: gh cache delete "${CACHE_KEY}" || true + + - name: Save ccache + if: github.ref_name == github.event.repository.default_branch + continue-on-error: true + uses: actions/cache/save@v5 + with: + path: .ccache + key: ${{ runner.os }}-test-${{ github.job }}-ccache-v1 + - name: Normalize CTest command paths run: | python - <<'PY'