Compare commits

...

4 Commits

Author SHA1 Message Date
Daz DeBoer
a94b9252d5 Improve cache logging 2021-10-16 10:15:40 -06:00
Daz DeBoer
25672bf196 Build outputs 2021-10-16 09:50:40 -06:00
Daz DeBoer
cb6a0acca4 Use precise matching for artifact bundles
This should fix the warnings issued when saving artifact bundles.
2021-10-16 09:49:15 -06:00
Daz DeBoer
aa2ed2e033 Use cache protocol version for bundle keys too 2021-10-16 09:49:14 -06:00
8 changed files with 32 additions and 14 deletions

View File

@@ -38,7 +38,7 @@ inputs:
["generated-gradle-jars", "caches/*/generated-gradle-jars/*.jar"],
["wrapper-zips", "wrapper/dists/*/*/*.zip"],
["dependency-jars", "caches/modules-*/files-*/**/*.jar"],
["instrumented-jars", "caches/jars-*/*"]
["instrumented-jars", "caches/jars-*/*/"]
]
outputs:

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

@@ -5,7 +5,12 @@ import * as core from '@actions/core'
import * as glob from '@actions/glob'
import * as exec from '@actions/exec'
import {AbstractCache, hashFileNames, tryDelete} from './cache-utils'
import {
AbstractCache,
getCacheKeyPrefix,
hashFileNames,
tryDelete
} from './cache-utils'
// Which paths under Gradle User Home should be cached
const CACHE_PATH = ['caches', 'notifications']
@@ -73,7 +78,9 @@ export class GradleUserHomeCache extends AbstractCache {
async beforeSave(): Promise<void> {
await this.reportGradleUserHomeSize('before saving common artifacts')
await this.saveArtifactBundles()
await this.reportGradleUserHomeSize('after saving common artifacts')
await this.reportGradleUserHomeSize(
'after saving common artifacts (./wrapper dir is not cached)'
)
}
private async saveArtifactBundles(): Promise<void> {
@@ -96,7 +103,10 @@ export class GradleUserHomeCache extends AbstractCache {
): Promise<void> {
const bundleMetaFile = this.getBundleMetaFile(bundle)
const globber = await glob.create(artifactPath)
const globber = await glob.create(artifactPath, {
implicitDescendants: false,
followSymbolicLinks: false
})
const bundleFiles = await globber.glob()
// Handle no matching files
@@ -131,7 +141,7 @@ export class GradleUserHomeCache extends AbstractCache {
}
protected createCacheKey(bundle: string, files: string[]): string {
const cacheKeyPrefix = process.env['CACHE_KEY_PREFIX'] || ''
const cacheKeyPrefix = getCacheKeyPrefix()
const relativeFiles = files.map(x =>
path.relative(this.gradleUserHome, x)
)
@@ -194,7 +204,7 @@ export class GradleUserHomeCache extends AbstractCache {
}
)
core.info(`Gradle User Home cache entry (directories >5M): ${label}`)
core.info(`Gradle User Home (directories >5M): ${label}`)
core.info(
result.stdout

View File

@@ -17,9 +17,13 @@ export function isCacheDebuggingEnabled(): boolean {
return process.env['CACHE_DEBUG_ENABLED'] ? true : false
}
function generateCacheKey(cacheName: string): CacheKey {
export function getCacheKeyPrefix(): string {
// Prefix can be used to force change all cache keys (defaults to cache protocol version)
const cacheKeyPrefix = process.env['CACHE_KEY_PREFIX'] || 'v2-'
return process.env['CACHE_KEY_PREFIX'] || 'v2-'
}
function generateCacheKey(cacheName: string): CacheKey {
const cacheKeyPrefix = getCacheKeyPrefix()
// At the most general level, share caches for all executions on the same OS
const runnerOs = process.env['RUNNER_OS'] || ''

View File

@@ -7,7 +7,9 @@ const BUILD_ROOT_DIR = 'BUILD_ROOT_DIR'
export async function restore(buildRootDirectory: string): Promise<void> {
if (isCacheDisabled()) {
core.debug('Cache read disabled')
core.info(
'Cache is disabled: will not restore state from previous builds.'
)
return
}
@@ -22,7 +24,9 @@ export async function restore(buildRootDirectory: string): Promise<void> {
export async function save(): Promise<void> {
if (isCacheReadOnly()) {
core.debug('Cache is read-only: not saving cache entry')
core.info(
'Cache is read-only: will not save state for use in subsequent builds.'
)
return
}