Improve messages for cache-disabled scenario

This commit is contained in:
Daz DeBoer 2022-01-17 13:50:55 -07:00
parent 3aa7bfe163
commit 50ca2bca83
No known key found for this signature in database
GPG key ID: DD6B9F0B06683D5D

View file

@ -8,7 +8,7 @@ const GRADLE_USER_HOME = 'GRADLE_USER_HOME'
const CACHE_LISTENER = 'CACHE_LISTENER' const CACHE_LISTENER = 'CACHE_LISTENER'
export async function restore(gradleUserHome: string): Promise<void> { export async function restore(gradleUserHome: string): Promise<void> {
// 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]) { if (process.env[CACHE_RESTORED_VAR]) {
core.info('Cache only restored on first action step.') core.info('Cache only restored on first action step.')
return return
@ -17,13 +17,6 @@ export async function restore(gradleUserHome: string): Promise<void> {
// Initialize the Gradle User Home even when caching is disabled. // Initialize the Gradle User Home even when caching is disabled.
const gradleStateCache = new GradleStateCache(gradleUserHome) 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() gradleStateCache.init()
if (isCacheDisabled()) { if (isCacheDisabled()) {
@ -31,6 +24,11 @@ export async function restore(gradleUserHome: string): Promise<void> {
return 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 () => { await core.group('Restore Gradle state from cache', async () => {
core.saveState(GRADLE_USER_HOME, gradleUserHome) core.saveState(GRADLE_USER_HOME, gradleUserHome)
@ -72,7 +70,7 @@ function shouldSaveCaches(): boolean {
} }
if (!core.getState(CACHE_RESTORED_VAR)) { 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 return false
} }