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:
description: Whether an exact cache key match was restored
value: ${{ steps.cache.outputs.cache-hit }}
cache-primary-key:
description: Primary cache key to pass to the save action after the build
value: ${{ steps.cache.outputs.cache-primary-key }}
cache-save-scope:
description: Scope to pass to the save action (always this job's scope, not a restored fallback key)
value: ${{ inputs.scope }}
runs:
using: composite
@@ -2,8 +2,8 @@ name: Save Gradle build directories
description: Save project .gradle/, build/ trees after a Gradle build
inputs:
primary-key:
description: cache-primary-key from cache-gradle-build restore step
scope:
description: Same scope passed to cache-gradle-build (save always uses this job's key, not a restored fallback key)
required: true
runs:
@@ -12,7 +12,7 @@ runs:
- uses: actions/cache/save@v5
continue-on-error: true
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: |
.gradle
build
+6 -6
View File
@@ -119,7 +119,7 @@ jobs:
- uses: ./.github/actions/save-gradle-build-cache
if: always()
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
with:
name: desktop-proguard
@@ -170,7 +170,7 @@ jobs:
- uses: ./.github/actions/save-gradle-build-cache
if: always()
with:
primary-key: ${{ steps.gradle-build-cache.outputs.cache-primary-key }}
scope: ${{ steps.gradle-build-cache.outputs.cache-save-scope }}
windows-package:
name: Windows (${{ matrix.label }})
@@ -246,7 +246,7 @@ jobs:
- uses: ./.github/actions/save-gradle-build-cache
if: always()
with:
primary-key: ${{ steps.gradle-build-cache.outputs.cache-primary-key }}
scope: ${{ steps.gradle-build-cache.outputs.cache-save-scope }}
macos:
name: macOS (${{ matrix.label }})
@@ -316,7 +316,7 @@ jobs:
- uses: ./.github/actions/save-gradle-build-cache
if: always()
with:
primary-key: ${{ steps.gradle-build-cache.outputs.cache-primary-key }}
scope: ${{ steps.gradle-build-cache.outputs.cache-save-scope }}
linux:
name: Linux (${{ matrix.label }})
@@ -382,7 +382,7 @@ jobs:
- uses: ./.github/actions/save-gradle-build-cache
if: always()
with:
primary-key: ${{ steps.gradle-build-cache.outputs.cache-primary-key }}
scope: ${{ steps.gradle-build-cache.outputs.cache-save-scope }}
android:
name: Android
@@ -441,7 +441,7 @@ jobs:
- uses: ./.github/actions/save-gradle-build-cache
if: always()
with:
primary-key: ${{ steps.gradle-build-cache.outputs.cache-primary-key }}
scope: ${{ steps.gradle-build-cache.outputs.cache-save-scope }}
- name: Stage APK
run: |
mkdir -p release-staging