Fix Gradle cache save races when restore hits a fallback key.

Save always uses the job scope key; do not reuse cache-primary-key from a partial restore (e.g. Android saving build-jar).

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-14 16:11:33 +03:00
Unverified
parent 3416bc2b0e
commit 7d7e78c534
3 changed files with 12 additions and 12 deletions
@@ -10,9 +10,9 @@ outputs:
cache-hit: cache-hit:
description: Whether an exact cache key match was restored description: Whether an exact cache key match was restored
value: ${{ steps.cache.outputs.cache-hit }} value: ${{ steps.cache.outputs.cache-hit }}
cache-primary-key: cache-save-scope:
description: Primary cache key to pass to the save action after the build description: Scope to pass to the save action (always this job's scope, not a restored fallback key)
value: ${{ steps.cache.outputs.cache-primary-key }} value: ${{ inputs.scope }}
runs: runs:
using: composite using: composite
@@ -2,8 +2,8 @@ name: Save Gradle build directories
description: Save project .gradle/, build/ trees after a Gradle build description: Save project .gradle/, build/ trees after a Gradle build
inputs: inputs:
primary-key: scope:
description: cache-primary-key from cache-gradle-build restore step description: Same scope passed to cache-gradle-build (save always uses this job's key, not a restored fallback key)
required: true required: true
runs: runs:
@@ -12,7 +12,7 @@ runs:
- uses: actions/cache/save@v5 - uses: actions/cache/save@v5
continue-on-error: true continue-on-error: true
with: with:
key: ${{ inputs.primary-key }} key: gradle-build-${{ runner.os }}-${{ runner.arch }}-v2-${{ inputs.scope }}-${{ hashFiles('gradle/libs.versions.toml', 'settings.gradle.kts', 'gradle.properties', 'build.gradle.kts', 'app/desktop/build.gradle.kts', 'app/desktop/proguard-rules.pro', 'app/shared/build.gradle.kts', 'app/android/build.gradle.kts', 'utils/shared/build.gradle.kts', 'utils/android/build.gradle.kts') }}
path: | path: |
.gradle .gradle
build build
+6 -6
View File
@@ -119,7 +119,7 @@ jobs:
- uses: ./.github/actions/save-gradle-build-cache - uses: ./.github/actions/save-gradle-build-cache
if: always() if: always()
with: with:
primary-key: ${{ steps.gradle-build-cache.outputs.cache-primary-key }} scope: ${{ steps.gradle-build-cache.outputs.cache-save-scope }}
- uses: actions/upload-artifact@v5 - uses: actions/upload-artifact@v5
with: with:
name: desktop-proguard name: desktop-proguard
@@ -170,7 +170,7 @@ jobs:
- uses: ./.github/actions/save-gradle-build-cache - uses: ./.github/actions/save-gradle-build-cache
if: always() if: always()
with: with:
primary-key: ${{ steps.gradle-build-cache.outputs.cache-primary-key }} scope: ${{ steps.gradle-build-cache.outputs.cache-save-scope }}
windows-package: windows-package:
name: Windows (${{ matrix.label }}) name: Windows (${{ matrix.label }})
@@ -246,7 +246,7 @@ jobs:
- uses: ./.github/actions/save-gradle-build-cache - uses: ./.github/actions/save-gradle-build-cache
if: always() if: always()
with: with:
primary-key: ${{ steps.gradle-build-cache.outputs.cache-primary-key }} scope: ${{ steps.gradle-build-cache.outputs.cache-save-scope }}
macos: macos:
name: macOS (${{ matrix.label }}) name: macOS (${{ matrix.label }})
@@ -316,7 +316,7 @@ jobs:
- uses: ./.github/actions/save-gradle-build-cache - uses: ./.github/actions/save-gradle-build-cache
if: always() if: always()
with: with:
primary-key: ${{ steps.gradle-build-cache.outputs.cache-primary-key }} scope: ${{ steps.gradle-build-cache.outputs.cache-save-scope }}
linux: linux:
name: Linux (${{ matrix.label }}) name: Linux (${{ matrix.label }})
@@ -382,7 +382,7 @@ jobs:
- uses: ./.github/actions/save-gradle-build-cache - uses: ./.github/actions/save-gradle-build-cache
if: always() if: always()
with: with:
primary-key: ${{ steps.gradle-build-cache.outputs.cache-primary-key }} scope: ${{ steps.gradle-build-cache.outputs.cache-save-scope }}
android: android:
name: Android name: Android
@@ -441,7 +441,7 @@ jobs:
- uses: ./.github/actions/save-gradle-build-cache - uses: ./.github/actions/save-gradle-build-cache
if: always() if: always()
with: with:
primary-key: ${{ steps.gradle-build-cache.outputs.cache-primary-key }} scope: ${{ steps.gradle-build-cache.outputs.cache-save-scope }}
- name: Stage APK - name: Stage APK
run: | run: |
mkdir -p release-staging mkdir -p release-staging