diff --git a/.github/workflows/smoke-test-basic-cache-provider.yml b/.github/workflows/smoke-test-basic-cache-provider.yml index e32c811d..c31284b2 100644 --- a/.github/workflows/smoke-test-basic-cache-provider.yml +++ b/.github/workflows/smoke-test-basic-cache-provider.yml @@ -39,9 +39,12 @@ jobs: with: cache-provider: basic cache-read-only: false # For testing, allow writing cache entries on non-default branches + # Basic caching does no daemon management, so the workflow must ensure no daemon is left + # holding locks on the Gradle User Home when the post-action save runs. Without this, `tar` + # cannot read the Gradle '*.lock' files on Windows and the cache entry is never saved. - name: Build kotlin-dsl project working-directory: .github/workflow-samples/kotlin-dsl - run: ./gradlew build + run: ./gradlew build --no-daemon basic-cache-verify-build: needs: basic-cache-seed-build diff --git a/sources/src/cache-service-basic.ts b/sources/src/cache-service-basic.ts index 89a6350d..ad620b86 100644 --- a/sources/src/cache-service-basic.ts +++ b/sources/src/cache-service-basic.ts @@ -80,7 +80,28 @@ export class BasicCacheService implements CacheService { const cachePaths = getCachePaths(gradleUserHome) try { - await cache.saveCache(cachePaths, primaryKey) + // A cacheId of -1 means the save failed: `saveCache` reports the underlying cause and returns + // normally, rather than throwing. Warn and continue: caching failures should not fail the build. + const cacheId = await cache.saveCache(cachePaths, primaryKey) + if (cacheId === -1) { + core.warning( + `Basic caching failed to save entry with key \`${primaryKey}\`. See preceding log output for the cause.` + ) + return { + status: 'enabled', + entries: [ + entryReport({ + primaryKey, + restoredKey, + restoredOutcome: restoredKey + ? '(Entry restored: exact match found)' + : '(Entry not restored: no match found)', + savedOutcome: '(Entry not saved: save failed)' + }) + ] + } + } + core.info(`Basic caching saved entry with key: ${primaryKey}`) return { status: 'enabled',