mirror of
https://github.com/gradle/gradle-build-action.git
synced 2025-10-20 07:08:56 +08:00
Track 'fully-restored' by tracking each cache restore
Instead of tracking a single 'fully-restored' flag, track the restore status of each cache entry restore. If any of these are requested but not restored, then the overall Gradle User Home cache is not fully restored. Added special handling for the case when zero artifact bundles are set: this is used in tests to simulate a not-fully-restored state.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import {GradleUserHomeCache} from './cache-gradle-user-home'
|
||||
import {ProjectDotGradleCache} from './cache-project-dot-gradle'
|
||||
import * as core from '@actions/core'
|
||||
import {isCacheDisabled, isCacheReadOnly} from './cache-utils'
|
||||
import {CachingReport, isCacheDisabled, isCacheReadOnly} from './cache-utils'
|
||||
|
||||
const BUILD_ROOT_DIR = 'BUILD_ROOT_DIR'
|
||||
|
||||
@@ -13,12 +13,15 @@ export async function restore(buildRootDirectory: string): Promise<void> {
|
||||
|
||||
await core.group('Restore Gradle state from cache', async () => {
|
||||
core.saveState(BUILD_ROOT_DIR, buildRootDirectory)
|
||||
const gradleHomeRestore = await new GradleUserHomeCache(buildRootDirectory).restore()
|
||||
|
||||
const cachingReport = new CachingReport()
|
||||
|
||||
await new GradleUserHomeCache(buildRootDirectory).restore(cachingReport)
|
||||
|
||||
const projectDotGradleCache = new ProjectDotGradleCache(buildRootDirectory)
|
||||
if (gradleHomeRestore.fullyRestored) {
|
||||
if (cachingReport.fullyRestored) {
|
||||
// Only restore the configuration-cache if the Gradle Home is fully restored
|
||||
await projectDotGradleCache.restore()
|
||||
await projectDotGradleCache.restore(cachingReport)
|
||||
} else {
|
||||
// Otherwise, prepare the cache key for later save()
|
||||
projectDotGradleCache.prepareCacheKey()
|
||||
|
Reference in New Issue
Block a user