mirror of
				https://github.com/gradle/gradle-build-action.git
				synced 2025-11-04 18:08:57 +08:00 
			
		
		
		
	Fail if configuration-cache is enabled without dependencies cache
Fixes #61
This commit is contained in:
		@@ -6,7 +6,11 @@ import * as cache from '@actions/cache'
 | 
			
		||||
 | 
			
		||||
import * as crypto from './crypto-utils'
 | 
			
		||||
 | 
			
		||||
import {inputCacheKeyGlobs, tryDeleteFiles} from './cache-dependencies'
 | 
			
		||||
import {
 | 
			
		||||
    inputCacheKeyGlobs,
 | 
			
		||||
    tryDeleteFiles,
 | 
			
		||||
    isDependenciesCacheDisabled
 | 
			
		||||
} from './cache-dependencies'
 | 
			
		||||
 | 
			
		||||
const CONFIGURATION_CACHE_PATH = 'CONFIGURATION_CACHE_PATH'
 | 
			
		||||
const CONFIGURATION_CACHE_KEY = 'CONFIGURATION_CACHE_KEY'
 | 
			
		||||
@@ -17,6 +21,12 @@ export async function restoreCachedConfiguration(
 | 
			
		||||
): Promise<void> {
 | 
			
		||||
    if (isConfigurationCacheDisabled()) return
 | 
			
		||||
 | 
			
		||||
    if (isDependenciesCacheDisabled()) {
 | 
			
		||||
        throw new Error(
 | 
			
		||||
            `Must enable dependencies-cache when configuration-cache is enabled`
 | 
			
		||||
        )
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const cachePath = path.resolve(rootDir, '.gradle/configuration-cache')
 | 
			
		||||
    if (fs.existsSync(cachePath)) return
 | 
			
		||||
    core.saveState(CONFIGURATION_CACHE_PATH, cachePath)
 | 
			
		||||
 
 | 
			
		||||
@@ -102,7 +102,7 @@ export function tryDeleteFiles(filePaths: string[]): boolean {
 | 
			
		||||
    return !failure
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
function isDependenciesCacheDisabled(): boolean {
 | 
			
		||||
export function isDependenciesCacheDisabled(): boolean {
 | 
			
		||||
    return !core.getBooleanInput('dependencies-cache-enabled')
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user