From 50ca2bca83dd56fdca775f2c611b21938f196acd Mon Sep 17 00:00:00 2001 From: Daz DeBoer Date: Mon, 17 Jan 2022 13:50:55 -0700 Subject: [PATCH] Improve messages for cache-disabled scenario --- src/caches.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/caches.ts b/src/caches.ts index b640ef8..68d83df 100644 --- a/src/caches.ts +++ b/src/caches.ts @@ -8,7 +8,7 @@ const GRADLE_USER_HOME = 'GRADLE_USER_HOME' const CACHE_LISTENER = 'CACHE_LISTENER' export async function restore(gradleUserHome: string): Promise { - // Only restore cache on first action step in workflow. + // Bypass restore cache on all but first action step in workflow. if (process.env[CACHE_RESTORED_VAR]) { core.info('Cache only restored on first action step.') return @@ -17,13 +17,6 @@ export async function restore(gradleUserHome: string): Promise { // Initialize the Gradle User Home even when caching is disabled. const gradleStateCache = new GradleStateCache(gradleUserHome) - if (gradleStateCache.cacheOutputExists()) { - core.info('Gradle User Home already exists: will not restore from cache.') - // We still add init-scripts for build-scan capture - gradleStateCache.init() - return - } - gradleStateCache.init() if (isCacheDisabled()) { @@ -31,6 +24,11 @@ export async function restore(gradleUserHome: string): Promise { return } + if (gradleStateCache.cacheOutputExists()) { + core.info('Gradle User Home already exists: will not restore from cache.') + return + } + await core.group('Restore Gradle state from cache', async () => { core.saveState(GRADLE_USER_HOME, gradleUserHome) @@ -72,7 +70,7 @@ function shouldSaveCaches(): boolean { } if (!core.getState(CACHE_RESTORED_VAR)) { - core.info('Cache will only be saved in final post-action step.') + core.info('Cache will not be saved: not restored in main action step.') return false }