Usability improvements:

- Include bundle name in cache key
- Emit a few more messages at 'info'
This commit is contained in:
Daz DeBoer 2021-09-15 15:48:55 -06:00
parent 6084a4eb65
commit bebb162342
No known key found for this signature in database
GPG key ID: DD6B9F0B06683D5D
6 changed files with 13 additions and 10 deletions

2
dist/main/index.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/post/index.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -53,7 +53,7 @@ export class GradleUserHomeCache extends AbstractCache {
const cacheKey = fs.readFileSync(cacheMetaFile, 'utf-8').trim()
const restoreKey = await this.restoreCache([pattern], cacheKey)
if (restoreKey) {
this.debug(
core.info(
`Restored ${bundle} with key ${cacheKey} to ${pattern}`
)
} else {
@ -149,14 +149,17 @@ export class GradleUserHomeCache extends AbstractCache {
const previouslyRestoredKey = fs.existsSync(cacheMetaFile)
? fs.readFileSync(cacheMetaFile, 'utf-8').trim()
: ''
const cacheKey = this.createCacheKey(hashStrings(commonArtifactFiles))
const cacheKey = this.createCacheKey(
bundle,
hashStrings(commonArtifactFiles)
)
if (previouslyRestoredKey === cacheKey) {
this.debug(
`No change to previously restored ${bundle}. Not caching.`
)
} else {
this.debug(`Caching ${bundle} with cache key: ${cacheKey}`)
core.info(`Caching ${bundle} with cache key: ${cacheKey}`)
await this.saveCache([pattern], cacheKey)
this.debug(`Writing cache metafile: ${cacheMetaFile}`)
@ -168,9 +171,9 @@ export class GradleUserHomeCache extends AbstractCache {
}
}
protected createCacheKey(key: string): string {
protected createCacheKey(bundle: string, key: string): string {
const cacheKeyPrefix = process.env['CACHE_KEY_PREFIX'] || ''
return `${cacheKeyPrefix}${key}`
return `${cacheKeyPrefix}${bundle}-${key}`
}
protected getGradleUserHome(): string {

View file

@ -107,7 +107,7 @@ export abstract class AbstractCache {
core.saveState(this.cacheResultStateKey, cacheResult)
core.info(
`${this.cacheDescription} restored from cache key: ${cacheResult}`
`Restored ${this.cacheDescription} from cache key: ${cacheResult}`
)
await this.afterRestore()