mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-11-22 16:20:59 -05:00
Add input to make the dependencies caching strict
This commit is contained in:
parent
95e20daa83
commit
053762c1c1
5 changed files with 18 additions and 5 deletions
|
@ -23,6 +23,9 @@ inputs:
|
||||||
dependencies-cache-key:
|
dependencies-cache-key:
|
||||||
description: Globs of files to hash in the build root directory, separated by new lines, use best-effort if unset
|
description: Globs of files to hash in the build root directory, separated by new lines, use best-effort if unset
|
||||||
required: false
|
required: false
|
||||||
|
dependencies-cache-exact:
|
||||||
|
description: Wether to restore only if exact match, default to 'false'
|
||||||
|
required: false
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
build-scan-url:
|
build-scan-url:
|
||||||
|
|
2
dist/main/index.js
vendored
2
dist/main/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/post/index.js
vendored
2
dist/post/index.js
vendored
File diff suppressed because one or more lines are too long
|
@ -18,6 +18,8 @@ export async function restoreCachedDependencies(
|
||||||
const cachePath = path.resolve(os.homedir(), '.gradle/caches/modules-2')
|
const cachePath = path.resolve(os.homedir(), '.gradle/caches/modules-2')
|
||||||
core.saveState(DEPENDENCIES_CACHE_PATH, cachePath)
|
core.saveState(DEPENDENCIES_CACHE_PATH, cachePath)
|
||||||
|
|
||||||
|
const inputCacheExact = github.inputBoolean('dependencies-cache-exact')
|
||||||
|
|
||||||
const inputCacheKeyGlobs = github.inputArrayOrNull('dependencies-cache-key')
|
const inputCacheKeyGlobs = github.inputArrayOrNull('dependencies-cache-key')
|
||||||
const cacheKeyGlobs = inputCacheKeyGlobs
|
const cacheKeyGlobs = inputCacheKeyGlobs
|
||||||
? inputCacheKeyGlobs
|
? inputCacheKeyGlobs
|
||||||
|
@ -33,9 +35,11 @@ export async function restoreCachedDependencies(
|
||||||
const cacheKey = `${cacheKeyPrefix}${hash}`
|
const cacheKey = `${cacheKeyPrefix}${hash}`
|
||||||
core.saveState(DEPENDENCIES_CACHE_KEY, cacheKey)
|
core.saveState(DEPENDENCIES_CACHE_KEY, cacheKey)
|
||||||
|
|
||||||
const cacheResult = await cache.restoreCache([cachePath], cacheKey, [
|
const cacheResult = await cache.restoreCache(
|
||||||
cacheKeyPrefix
|
[cachePath],
|
||||||
])
|
cacheKey,
|
||||||
|
inputCacheExact ? [] : [cacheKeyPrefix]
|
||||||
|
)
|
||||||
core.saveState(DEPENDENCIES_CACHE_RESULT, cacheResult)
|
core.saveState(DEPENDENCIES_CACHE_RESULT, cacheResult)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,3 +16,9 @@ export function inputArrayOrNull(name: string): string[] | null {
|
||||||
.map(s => s.trim())
|
.map(s => s.trim())
|
||||||
.filter(s => s !== '')
|
.filter(s => s !== '')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function inputBoolean(name: string, defaultValue = false): boolean {
|
||||||
|
const string = inputOrNull(name)
|
||||||
|
if (!string) return defaultValue
|
||||||
|
return string === 'true'
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue