Add input to disable dependencies caching altogether

This commit is contained in:
Paul Merlin 2020-06-15 14:30:25 +02:00
parent 7c8cc1a9ef
commit 3abad5567a
4 changed files with 13 additions and 2 deletions

View File

@ -20,6 +20,9 @@ inputs:
arguments: arguments:
description: Gradle command line arguments, see gradle --help description: Gradle command line arguments, see gradle --help
required: false required: false
dependencies-cache-enabled:
description: Whether caching dependencies is enabled or not, default to 'true'
required: false
dependencies-cache-key: dependencies-cache-key:
description: Globs of files to hash in the build root directory, separated by new lines, use best-effort if unset description: Globs of files to hash in the build root directory, separated by new lines, use best-effort if unset
required: false required: false

2
dist/main/index.js vendored

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

View File

@ -15,6 +15,8 @@ const DEPENDENCIES_CACHE_RESULT = 'DEPENDENCIES_CACHE_RESULT'
export async function restoreCachedDependencies( export async function restoreCachedDependencies(
rootDir: string rootDir: string
): Promise<void> { ): Promise<void> {
if (isDependenciesCacheDisabled()) return
const cachePath = path.resolve(os.homedir(), '.gradle/caches/modules-2') const cachePath = path.resolve(os.homedir(), '.gradle/caches/modules-2')
core.saveState(DEPENDENCIES_CACHE_PATH, cachePath) core.saveState(DEPENDENCIES_CACHE_PATH, cachePath)
@ -52,6 +54,8 @@ export async function restoreCachedDependencies(
} }
export async function cacheDependencies(): Promise<void> { export async function cacheDependencies(): Promise<void> {
if (isDependenciesCacheDisabled()) return
const cachePath = core.getState(DEPENDENCIES_CACHE_PATH) const cachePath = core.getState(DEPENDENCIES_CACHE_PATH)
const cacheKey = core.getState(DEPENDENCIES_CACHE_KEY) const cacheKey = core.getState(DEPENDENCIES_CACHE_KEY)
const cacheResult = core.getState(DEPENDENCIES_CACHE_RESULT) const cacheResult = core.getState(DEPENDENCIES_CACHE_RESULT)
@ -107,3 +111,7 @@ function tryDeleteFiles(filePaths: string[]): boolean {
} }
return !failure return !failure
} }
function isDependenciesCacheDisabled(): boolean {
return !github.inputBoolean('dependencies-cache-enabled', true)
}