mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-11-22 17:12:51 +00:00
Usability improvements:
- Include bundle name in cache key - Emit a few more messages at 'info'
This commit is contained in:
parent
6084a4eb65
commit
bebb162342
6 changed files with 13 additions and 10 deletions
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/main/index.js.map
vendored
2
dist/main/index.js.map
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
2
dist/post/index.js.map
vendored
2
dist/post/index.js.map
vendored
File diff suppressed because one or more lines are too long
|
@ -53,7 +53,7 @@ export class GradleUserHomeCache extends AbstractCache {
|
||||||
const cacheKey = fs.readFileSync(cacheMetaFile, 'utf-8').trim()
|
const cacheKey = fs.readFileSync(cacheMetaFile, 'utf-8').trim()
|
||||||
const restoreKey = await this.restoreCache([pattern], cacheKey)
|
const restoreKey = await this.restoreCache([pattern], cacheKey)
|
||||||
if (restoreKey) {
|
if (restoreKey) {
|
||||||
this.debug(
|
core.info(
|
||||||
`Restored ${bundle} with key ${cacheKey} to ${pattern}`
|
`Restored ${bundle} with key ${cacheKey} to ${pattern}`
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
@ -149,14 +149,17 @@ export class GradleUserHomeCache extends AbstractCache {
|
||||||
const previouslyRestoredKey = fs.existsSync(cacheMetaFile)
|
const previouslyRestoredKey = fs.existsSync(cacheMetaFile)
|
||||||
? fs.readFileSync(cacheMetaFile, 'utf-8').trim()
|
? fs.readFileSync(cacheMetaFile, 'utf-8').trim()
|
||||||
: ''
|
: ''
|
||||||
const cacheKey = this.createCacheKey(hashStrings(commonArtifactFiles))
|
const cacheKey = this.createCacheKey(
|
||||||
|
bundle,
|
||||||
|
hashStrings(commonArtifactFiles)
|
||||||
|
)
|
||||||
|
|
||||||
if (previouslyRestoredKey === cacheKey) {
|
if (previouslyRestoredKey === cacheKey) {
|
||||||
this.debug(
|
this.debug(
|
||||||
`No change to previously restored ${bundle}. Not caching.`
|
`No change to previously restored ${bundle}. Not caching.`
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
this.debug(`Caching ${bundle} with cache key: ${cacheKey}`)
|
core.info(`Caching ${bundle} with cache key: ${cacheKey}`)
|
||||||
await this.saveCache([pattern], cacheKey)
|
await this.saveCache([pattern], cacheKey)
|
||||||
|
|
||||||
this.debug(`Writing cache metafile: ${cacheMetaFile}`)
|
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'] || ''
|
const cacheKeyPrefix = process.env['CACHE_KEY_PREFIX'] || ''
|
||||||
return `${cacheKeyPrefix}${key}`
|
return `${cacheKeyPrefix}${bundle}-${key}`
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getGradleUserHome(): string {
|
protected getGradleUserHome(): string {
|
||||||
|
|
|
@ -107,7 +107,7 @@ export abstract class AbstractCache {
|
||||||
core.saveState(this.cacheResultStateKey, cacheResult)
|
core.saveState(this.cacheResultStateKey, cacheResult)
|
||||||
|
|
||||||
core.info(
|
core.info(
|
||||||
`${this.cacheDescription} restored from cache key: ${cacheResult}`
|
`Restored ${this.cacheDescription} from cache key: ${cacheResult}`
|
||||||
)
|
)
|
||||||
|
|
||||||
await this.afterRestore()
|
await this.afterRestore()
|
||||||
|
|
Loading…
Reference in a new issue