Remove custom option for cache-read-timeout

Now that `@actions/cache` provides a env var override, we can remove our
custom configuration for setting the timeout on cache restore operations.

If the env var is NOT set, we continue to override the 60min default with 10mins.
This commit is contained in:
Daz DeBoer 2022-08-22 13:07:12 -06:00
parent 84bc83e639
commit 8a386f6915
No known key found for this signature in database
GPG Key ID: DD6B9F0B06683D5D
2 changed files with 7 additions and 12 deletions

View File

@ -66,10 +66,6 @@ inputs:
description: When 'true', the action will not attempt to restore the Gradle User Home entries from other Jobs. description: When 'true', the action will not attempt to restore the Gradle User Home entries from other Jobs.
required: false required: false
default: false default: false
cache-read-timeout:
description: A timeout value in seconds for cache reads. Requests taking longer that this will be aborted.
required: true
default: 600
workflow-job-context: workflow-job-context:
description: Used to uniquely identify the current job invocation. Defaults to the matrix values for this job; this should not be overridden by users (INTERNAL). description: Used to uniquely identify the current job invocation. Defaults to the matrix values for this job; this should not be overridden by users (INTERNAL).
required: false required: false

View File

@ -15,7 +15,6 @@ const JOB_CONTEXT_PARAMETER = 'workflow-job-context'
const CACHE_DISABLED_PARAMETER = 'cache-disabled' const CACHE_DISABLED_PARAMETER = 'cache-disabled'
const CACHE_READONLY_PARAMETER = 'cache-read-only' const CACHE_READONLY_PARAMETER = 'cache-read-only'
const CACHE_WRITEONLY_PARAMETER = 'cache-write-only' const CACHE_WRITEONLY_PARAMETER = 'cache-write-only'
const CACHE_TIMEOUT_PARAMETER = 'cache-read-timeout'
const STRICT_CACHE_MATCH_PARAMETER = 'gradle-home-cache-strict-match' const STRICT_CACHE_MATCH_PARAMETER = 'gradle-home-cache-strict-match'
const CACHE_DEBUG_VAR = 'GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED' const CACHE_DEBUG_VAR = 'GRADLE_BUILD_ACTION_CACHE_DEBUG_ENABLED'
@ -25,6 +24,8 @@ const CACHE_KEY_JOB_VAR = 'GRADLE_BUILD_ACTION_CACHE_KEY_JOB'
const CACHE_KEY_JOB_INSTANCE_VAR = 'GRADLE_BUILD_ACTION_CACHE_KEY_JOB_INSTANCE' const CACHE_KEY_JOB_INSTANCE_VAR = 'GRADLE_BUILD_ACTION_CACHE_KEY_JOB_INSTANCE'
const CACHE_KEY_JOB_EXECUTION_VAR = 'GRADLE_BUILD_ACTION_CACHE_KEY_JOB_EXECUTION' const CACHE_KEY_JOB_EXECUTION_VAR = 'GRADLE_BUILD_ACTION_CACHE_KEY_JOB_EXECUTION'
const SEGMENT_DOWNLOAD_TIMEOUT_DEFAULT = 10 * 60 * 1000 // 10 minutes
export function isCacheDisabled(): boolean { export function isCacheDisabled(): boolean {
if (!cache.isFeatureAvailable()) { if (!cache.isFeatureAvailable()) {
return true return true
@ -44,10 +45,6 @@ export function isCacheDebuggingEnabled(): boolean {
return process.env[CACHE_DEBUG_VAR] ? true : false return process.env[CACHE_DEBUG_VAR] ? true : false
} }
function getCacheReadTimeoutMs(): number {
return parseInt(core.getInput(CACHE_TIMEOUT_PARAMETER)) * 1000
}
/** /**
* Represents a key used to restore a cache entry. * Represents a key used to restore a cache entry.
* The Github Actions cache will first try for an exact match on the key. * The Github Actions cache will first try for an exact match on the key.
@ -153,9 +150,11 @@ export async function restoreCache(
): Promise<cache.CacheEntry | undefined> { ): Promise<cache.CacheEntry | undefined> {
listener.markRequested(cacheKey, cacheRestoreKeys) listener.markRequested(cacheKey, cacheRestoreKeys)
try { try {
const restoredEntry = await cache.restoreCache(cachePath, cacheKey, cacheRestoreKeys, { // Only override the read timeout if the SEGMENT_DOWNLOAD_TIMEOUT_MINS env var has NOT been set
segmentTimeoutInMs: getCacheReadTimeoutMs() const cacheRestoreOptions = process.env['SEGMENT_DOWNLOAD_TIMEOUT_MINS']
}) ? {}
: {segmentTimeoutInMs: SEGMENT_DOWNLOAD_TIMEOUT_DEFAULT}
const restoredEntry = await cache.restoreCache(cachePath, cacheKey, cacheRestoreKeys, cacheRestoreOptions)
if (restoredEntry !== undefined) { if (restoredEntry !== undefined) {
listener.markRestored(restoredEntry.key, restoredEntry.size) listener.markRestored(restoredEntry.key, restoredEntry.size)
} }