mirror of
https://github.com/gradle/actions.git
synced 2025-11-26 17:09:10 +08:00
Add test for no cache-cleanup with config-cache hit
This commit is contained in:
@@ -24,6 +24,10 @@ export class BuildResults {
|
||||
return this.results.some(result => result.buildFailed)
|
||||
}
|
||||
|
||||
anyConfigCacheHit(): boolean {
|
||||
return this.results.some(result => result.configCacheHit)
|
||||
}
|
||||
|
||||
uniqueGradleHomes(): string[] {
|
||||
const allHomes = this.results.map(buildResult => buildResult.gradleHomeDir)
|
||||
return Array.from(new Set(allHomes))
|
||||
|
||||
@@ -19,6 +19,9 @@ export const DEFAULT_CLEANUP_ENABLED_REASON = `[Cache cleanup](https://github.co
|
||||
export const CLEANUP_DISABLED_DUE_TO_FAILURE =
|
||||
'[Cache cleanup was disabled due to build failure](https://github.com/gradle/actions/blob/v3/docs/setup-gradle.md#enabling-cache-cleanup). Use `cache-cleanup: always` to override this behavior.'
|
||||
|
||||
export const CLEANUP_DISABLED_DUE_TO_CONFIG_CACHE_HIT =
|
||||
'[Cache cleanup was disabled due to configuration-cache reuse](https://github.com/gradle/actions/blob/v3/docs/setup-gradle.md#enabling-cache-cleanup). This is expected.'
|
||||
|
||||
/**
|
||||
* Collects information on what entries were saved and restored during the action.
|
||||
* This information is used to generate a summary of the cache usage.
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import * as core from '@actions/core'
|
||||
import {CacheListener, EXISTING_GRADLE_HOME, CLEANUP_DISABLED_DUE_TO_FAILURE} from './cache-reporting'
|
||||
import {
|
||||
CacheListener,
|
||||
EXISTING_GRADLE_HOME,
|
||||
CLEANUP_DISABLED_DUE_TO_FAILURE,
|
||||
CLEANUP_DISABLED_DUE_TO_CONFIG_CACHE_HIT
|
||||
} from './cache-reporting'
|
||||
import {GradleUserHomeCache} from './gradle-user-home-cache'
|
||||
import {CacheCleaner} from './cache-cleaner'
|
||||
import {DaemonController} from '../daemon-controller'
|
||||
@@ -90,7 +95,10 @@ export async function save(
|
||||
await daemonController.stopAllDaemons()
|
||||
|
||||
if (cacheConfig.isCacheCleanupEnabled()) {
|
||||
if (cacheConfig.shouldPerformCacheCleanup(buildResults.anyFailed())) {
|
||||
if (buildResults.anyConfigCacheHit()) {
|
||||
core.info('Not performing cache-cleanup due to config-cache reuse')
|
||||
cacheListener.setCacheCleanupDisabled(CLEANUP_DISABLED_DUE_TO_CONFIG_CACHE_HIT)
|
||||
} else if (cacheConfig.shouldPerformCacheCleanup(buildResults.anyFailed())) {
|
||||
cacheListener.setCacheCleanupEnabled()
|
||||
await performCacheCleanup(gradleUserHome)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user