mirror of
https://github.com/gradle/actions
synced 2024-11-23 18:02:13 +00:00
Include Gradle invocation arguments in cache keys (#69)
This permits a new cache entry to be persisted when a subsequent Gradle invocation does more work that an earlier invocation. Fixes #68
This commit is contained in:
parent
a63892c289
commit
e0c2736e35
4 changed files with 20 additions and 12 deletions
2
dist/main/index.js
vendored
2
dist/main/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/post/index.js
vendored
2
dist/post/index.js
vendored
File diff suppressed because one or more lines are too long
|
@ -1,5 +1,5 @@
|
||||||
import path from 'path'
|
import * as path from 'path'
|
||||||
import fs from 'fs'
|
import * as fs from 'fs'
|
||||||
|
|
||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as cache from '@actions/cache'
|
import * as cache from '@actions/cache'
|
||||||
|
@ -32,17 +32,21 @@ export async function restoreCachedConfiguration(
|
||||||
core.saveState(CONFIGURATION_CACHE_PATH, cachePath)
|
core.saveState(CONFIGURATION_CACHE_PATH, cachePath)
|
||||||
|
|
||||||
const inputCacheExact = core.getBooleanInput('configuration-cache-exact')
|
const inputCacheExact = core.getBooleanInput('configuration-cache-exact')
|
||||||
const cacheKeyGlobs = inputCacheKeyGlobs('configuration-cache-key')
|
const cacheKeyPrefix = 'configuration|'
|
||||||
|
|
||||||
|
const args = core.getInput('arguments')
|
||||||
|
const cacheKeyWithArgs = `${cacheKeyPrefix}${args}|`
|
||||||
|
|
||||||
|
const cacheKeyGlobs = inputCacheKeyGlobs('configuration-cache-key')
|
||||||
const hash = await crypto.hashFiles(rootDir, cacheKeyGlobs)
|
const hash = await crypto.hashFiles(rootDir, cacheKeyGlobs)
|
||||||
const cacheKeyPrefix = 'configuration-'
|
const cacheKey = `${cacheKeyWithArgs}${hash}`
|
||||||
const cacheKey = `${cacheKeyPrefix}${hash}`
|
|
||||||
core.saveState(CONFIGURATION_CACHE_KEY, cacheKey)
|
core.saveState(CONFIGURATION_CACHE_KEY, cacheKey)
|
||||||
|
|
||||||
const cacheResult = await cache.restoreCache(
|
const cacheResult = await cache.restoreCache(
|
||||||
[cachePath],
|
[cachePath],
|
||||||
cacheKey,
|
cacheKey,
|
||||||
inputCacheExact ? [] : [cacheKeyPrefix]
|
inputCacheExact ? [] : [cacheKeyWithArgs, cacheKeyPrefix]
|
||||||
)
|
)
|
||||||
|
|
||||||
if (!cacheResult) {
|
if (!cacheResult) {
|
||||||
|
|
|
@ -21,17 +21,21 @@ export async function restoreCachedDependencies(
|
||||||
core.saveState(DEPENDENCIES_CACHE_PATH, cachePath)
|
core.saveState(DEPENDENCIES_CACHE_PATH, cachePath)
|
||||||
|
|
||||||
const inputCacheExact = core.getBooleanInput('dependencies-cache-exact')
|
const inputCacheExact = core.getBooleanInput('dependencies-cache-exact')
|
||||||
const cacheKeyGlobs = inputCacheKeyGlobs('dependencies-cache-key')
|
const cacheKeyPrefix = 'dependencies|'
|
||||||
|
|
||||||
|
const args = core.getInput('arguments')
|
||||||
|
const cacheKeyWithArgs = `${cacheKeyPrefix}${args}|`
|
||||||
|
|
||||||
|
const cacheKeyGlobs = inputCacheKeyGlobs('dependencies-cache-key')
|
||||||
const hash = await crypto.hashFiles(rootDir, cacheKeyGlobs)
|
const hash = await crypto.hashFiles(rootDir, cacheKeyGlobs)
|
||||||
const cacheKeyPrefix = 'dependencies-'
|
const cacheKey = `${cacheKeyWithArgs}${hash}`
|
||||||
const cacheKey = `${cacheKeyPrefix}${hash}`
|
|
||||||
core.saveState(DEPENDENCIES_CACHE_KEY, cacheKey)
|
core.saveState(DEPENDENCIES_CACHE_KEY, cacheKey)
|
||||||
|
|
||||||
const cacheResult = await cache.restoreCache(
|
const cacheResult = await cache.restoreCache(
|
||||||
[cachePath],
|
[cachePath],
|
||||||
cacheKey,
|
cacheKey,
|
||||||
inputCacheExact ? [] : [cacheKeyPrefix]
|
inputCacheExact ? [] : [cacheKeyWithArgs, cacheKeyPrefix]
|
||||||
)
|
)
|
||||||
|
|
||||||
if (!cacheResult) {
|
if (!cacheResult) {
|
||||||
|
|
Loading…
Reference in a new issue