Commit 02a8a21e authored by Paul Merlin's avatar Paul Merlin
Browse files

Add input to disable wrapper caching

parent 3abad556
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
  wrapper-cache-enabled:
    description: Whether caching wrapper installation is enabled or not, default to 'true'
    required: false
  dependencies-cache-enabled:
    description: Whether caching dependencies is enabled or not, default to 'true'
    required: false
+1 −1

File changed.

Preview size limit exceeded, changes collapsed.

+1 −1

File changed.

Preview size limit exceeded, changes collapsed.

+12 −2
Changes for src/cache-wrapper.ts: 12 added lines, 2 removed lines.
Original line number Diff line number Diff line
import * as core from '@actions/core'
import * as cache from '@actions/cache'
import * as path from 'path'
import * as fs from 'fs'
import * as os from 'os'

import * as core from '@actions/core'
import * as cache from '@actions/cache'

import * as github from './github-utils'

const WRAPPER_CACHE_KEY = 'WRAPPER_CACHE_KEY'
const WRAPPER_CACHE_PATH = 'WRAPPER_CACHE_PATH'
const WRAPPER_CACHE_RESULT = 'WRAPPER_CACHE_RESULT'
@@ -11,6 +14,7 @@ const WRAPPER_CACHE_RESULT = 'WRAPPER_CACHE_RESULT'
export async function restoreCachedWrapperDist(
    gradlewDirectory: string | null
): Promise<void> {
    if (isWrapperCacheDisabled()) return
    if (gradlewDirectory == null) return

    const wrapperSlug = extractGradleWrapperSlugFrom(
@@ -48,6 +52,8 @@ export async function restoreCachedWrapperDist(
}

export async function cacheWrapperDist(): Promise<void> {
    if (isWrapperCacheDisabled()) return

    const cacheKey = core.getState(WRAPPER_CACHE_KEY)
    const cachePath = core.getState(WRAPPER_CACHE_PATH)
    const cacheResult = core.getState(WRAPPER_CACHE_RESULT)
@@ -97,3 +103,7 @@ export function extractGradleWrapperSlugFromDistUri(
    const match = distUri.match(regex)
    return match ? match[1] : null
}

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