Commit 3abad556 authored by Paul Merlin's avatar Paul Merlin
Browse files

Add input to disable dependencies caching altogether

parent 7c8cc1a9
Loading
Loading
Loading
Loading
+3
Changes for action.yml: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -20,6 +20,9 @@ inputs:
  arguments:
    description: Gradle command line arguments, see gradle --help
    required: false
  dependencies-cache-enabled:
    description: Whether caching dependencies is enabled or not, default to 'true'
    required: false
  dependencies-cache-key:
    description: Globs of files to hash in the build root directory, separated by new lines, use best-effort if unset
    required: false
+1 −1

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1

File changed.

Preview size limit exceeded, changes collapsed.

+8
Changes for src/cache-dependencies.ts: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -15,6 +15,8 @@ const DEPENDENCIES_CACHE_RESULT = 'DEPENDENCIES_CACHE_RESULT'
export async function restoreCachedDependencies(
    rootDir: string
): Promise<void> {
    if (isDependenciesCacheDisabled()) return

    const cachePath = path.resolve(os.homedir(), '.gradle/caches/modules-2')
    core.saveState(DEPENDENCIES_CACHE_PATH, cachePath)

@@ -52,6 +54,8 @@ export async function restoreCachedDependencies(
}

export async function cacheDependencies(): Promise<void> {
    if (isDependenciesCacheDisabled()) return

    const cachePath = core.getState(DEPENDENCIES_CACHE_PATH)
    const cacheKey = core.getState(DEPENDENCIES_CACHE_KEY)
    const cacheResult = core.getState(DEPENDENCIES_CACHE_RESULT)
@@ -107,3 +111,7 @@ function tryDeleteFiles(filePaths: string[]): boolean {
    }
    return !failure
}

function isDependenciesCacheDisabled(): boolean {
    return !github.inputBoolean('dependencies-cache-enabled', true)
}