mirror of
https://github.com/gradle/gradle-build-action.git
synced 2025-11-06 03:09:06 +08:00
Rename and document parameters for clarity
- cache-paths -> gradle-home-cache-includes - cache-exclude-paths -> gradle-home-cache-excludes - CACHE_DEBUG_ENABLED -> GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED
This commit is contained in:
@@ -14,6 +14,10 @@ import {
|
||||
|
||||
const META_FILE_DIR = '.gradle-build-action'
|
||||
|
||||
const INCLUDE_PATHS_PARAMETER = 'gradle-home-cache-includes'
|
||||
const EXCLUDE_PATHS_PARAMETER = 'gradle-home-cache-excludes'
|
||||
const ARTIFACT_BUNDLES_PARAMETER = 'gradle-home-cache-artifact-bundles'
|
||||
|
||||
export class GradleUserHomeCache extends AbstractCache {
|
||||
private gradleUserHome: string
|
||||
|
||||
@@ -81,7 +85,7 @@ export class GradleUserHomeCache extends AbstractCache {
|
||||
|
||||
private removeExcludedPaths(): void {
|
||||
const rawPaths: string[] = JSON.parse(
|
||||
core.getInput('cache-exclude-paths')
|
||||
core.getInput(EXCLUDE_PATHS_PARAMETER)
|
||||
)
|
||||
const resolvedPaths = rawPaths.map(x =>
|
||||
path.resolve(this.gradleUserHome, x)
|
||||
@@ -189,7 +193,9 @@ export class GradleUserHomeCache extends AbstractCache {
|
||||
}
|
||||
|
||||
protected getCachePath(): string[] {
|
||||
const rawPaths: string[] = JSON.parse(core.getInput('cache-paths'))
|
||||
const rawPaths: string[] = JSON.parse(
|
||||
core.getInput(INCLUDE_PATHS_PARAMETER)
|
||||
)
|
||||
rawPaths.push(META_FILE_DIR)
|
||||
const resolvedPaths = rawPaths.map(x => this.resolveCachePath(x))
|
||||
this.debug(`Using cache paths: ${resolvedPaths}`)
|
||||
@@ -205,7 +211,9 @@ export class GradleUserHomeCache extends AbstractCache {
|
||||
}
|
||||
|
||||
private getArtifactBundles(): Map<string, string> {
|
||||
const artifactBundleDefinition = core.getInput('cache-artifact-bundles')
|
||||
const artifactBundleDefinition = core.getInput(
|
||||
ARTIFACT_BUNDLES_PARAMETER
|
||||
)
|
||||
this.debug(
|
||||
`Using artifact bundle definition: ${artifactBundleDefinition}`
|
||||
)
|
||||
|
||||
@@ -5,21 +5,27 @@ import * as crypto from 'crypto'
|
||||
import * as path from 'path'
|
||||
import * as fs from 'fs'
|
||||
|
||||
const CACHE_DISABLED_PARAMETER = 'cache-disabled'
|
||||
const CACHE_READONLY_PARAMETER = 'cache-read-only'
|
||||
const JOB_CONTEXT_PARAMETER = 'workflow-job-context'
|
||||
const CACHE_DEBUG_VAR = 'GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED'
|
||||
const CACHE_PREFIX_VAR = 'GRADLE_BUILD_ACTION_CACHE_KEY_PREFIX'
|
||||
|
||||
export function isCacheDisabled(): boolean {
|
||||
return core.getBooleanInput('cache-disabled')
|
||||
return core.getBooleanInput(CACHE_DISABLED_PARAMETER)
|
||||
}
|
||||
|
||||
export function isCacheReadOnly(): boolean {
|
||||
return core.getBooleanInput('cache-read-only')
|
||||
return core.getBooleanInput(CACHE_READONLY_PARAMETER)
|
||||
}
|
||||
|
||||
export function isCacheDebuggingEnabled(): boolean {
|
||||
return process.env['CACHE_DEBUG_ENABLED'] ? true : false
|
||||
return process.env[CACHE_DEBUG_VAR] ? true : false
|
||||
}
|
||||
|
||||
export function getCacheKeyPrefix(): string {
|
||||
// Prefix can be used to force change all cache keys (defaults to cache protocol version)
|
||||
return process.env['CACHE_KEY_PREFIX'] || 'v3-'
|
||||
return process.env[CACHE_PREFIX_VAR] || 'v3-'
|
||||
}
|
||||
|
||||
function generateCacheKey(cacheName: string): CacheKey {
|
||||
@@ -47,7 +53,7 @@ function generateCacheKey(cacheName: string): CacheKey {
|
||||
|
||||
function determineJobContext(): string {
|
||||
// By default, we hash the full `matrix` data for the run, to uniquely identify this job invocation
|
||||
const workflowJobContext = core.getInput('workflow-job-context')
|
||||
const workflowJobContext = core.getInput(JOB_CONTEXT_PARAMETER)
|
||||
return hashStrings([workflowJobContext])
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user