mirror of
https://github.com/gradle/gradle-build-action.git
synced 2025-11-03 17:18:55 +08:00
Include Gradle invocation arguments in cache keys (#69)
This permits a new cache entry to be persisted when a subsequent Gradle invocation does more work that an earlier invocation. Fixes #68
This commit is contained in:
@@ -21,17 +21,21 @@ export async function restoreCachedDependencies(
|
||||
core.saveState(DEPENDENCIES_CACHE_PATH, cachePath)
|
||||
|
||||
const inputCacheExact = core.getBooleanInput('dependencies-cache-exact')
|
||||
const cacheKeyGlobs = inputCacheKeyGlobs('dependencies-cache-key')
|
||||
const cacheKeyPrefix = 'dependencies|'
|
||||
|
||||
const args = core.getInput('arguments')
|
||||
const cacheKeyWithArgs = `${cacheKeyPrefix}${args}|`
|
||||
|
||||
const cacheKeyGlobs = inputCacheKeyGlobs('dependencies-cache-key')
|
||||
const hash = await crypto.hashFiles(rootDir, cacheKeyGlobs)
|
||||
const cacheKeyPrefix = 'dependencies-'
|
||||
const cacheKey = `${cacheKeyPrefix}${hash}`
|
||||
const cacheKey = `${cacheKeyWithArgs}${hash}`
|
||||
|
||||
core.saveState(DEPENDENCIES_CACHE_KEY, cacheKey)
|
||||
|
||||
const cacheResult = await cache.restoreCache(
|
||||
[cachePath],
|
||||
cacheKey,
|
||||
inputCacheExact ? [] : [cacheKeyPrefix]
|
||||
inputCacheExact ? [] : [cacheKeyWithArgs, cacheKeyPrefix]
|
||||
)
|
||||
|
||||
if (!cacheResult) {
|
||||
|
||||
Reference in New Issue
Block a user