Add caching of Gradle build configuration cache

This commit is contained in:
Paul Merlin
2020-06-15 15:58:20 +02:00
parent 806543fb3a
commit 4c7d97cca4
7 changed files with 125 additions and 13 deletions

View File

@@ -21,16 +21,7 @@ export async function restoreCachedDependencies(
core.saveState(DEPENDENCIES_CACHE_PATH, cachePath)
const inputCacheExact = github.inputBoolean('dependencies-cache-exact')
const inputCacheKeyGlobs = github.inputArrayOrNull('dependencies-cache-key')
const cacheKeyGlobs = inputCacheKeyGlobs
? inputCacheKeyGlobs
: [
'**/*.gradle',
'**/*.gradle.kts',
'**/gradle.properties',
'gradle/**'
]
const cacheKeyGlobs = inputCacheKeyGlobs('dependencies-cache-key')
const hash = await crypto.hashFiles(rootDir, cacheKeyGlobs)
const cacheKeyPrefix = 'dependencies-'
@@ -97,7 +88,7 @@ export async function cacheDependencies(): Promise<void> {
return
}
function tryDeleteFiles(filePaths: string[]): boolean {
export function tryDeleteFiles(filePaths: string[]): boolean {
let failure = false
for (const filePath of filePaths) {
if (fs.existsSync(filePath)) {
@@ -114,3 +105,15 @@ function tryDeleteFiles(filePaths: string[]): boolean {
function isDependenciesCacheDisabled(): boolean {
return !github.inputBoolean('dependencies-cache-enabled', false)
}
export function inputCacheKeyGlobs(input: string): string[] {
const inputValue = github.inputArrayOrNull(input)
return inputValue
? inputValue
: [
'**/*.gradle',
'**/*.gradle.kts',
'**/gradle.properties',
'gradle/**'
]
}