mirror of
https://github.com/gradle/gradle-build-action.git
synced 2025-05-01 12:38:08 +02:00
Allow entries with same Job ID to match in different workflows
Previously, the workflow name was always included when matching a cache entry for the current job. This can be overly restrictive when job definitions are shared between different workflows. The workflow name is still encoded in the cache entry key, but not in the restore key searching for entries with a matching job. Fixes #1017
This commit is contained in:
parent
270f30ba56
commit
32bab5b15a
7 changed files with 19 additions and 80 deletions
26
dist/post/index.js
vendored
26
dist/post/index.js
vendored
|
@ -136958,7 +136958,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
exports.tryDelete = exports.handleCacheFailure = exports.cacheDebug = exports.saveCache = exports.restoreCache = exports.hashStrings = exports.hashFileNames = exports.getUniqueLabelForJobInstanceValues = exports.getUniqueLabelForJobInstance = exports.getCacheKeyForJob = exports.getCacheKeyPrefix = exports.generateCacheKey = exports.CacheKey = exports.isCacheCleanupEnabled = exports.isCacheDebuggingEnabled = exports.isCacheOverwriteExisting = exports.isCacheWriteOnly = exports.isCacheReadOnly = exports.isCacheDisabled = void 0;
|
||||
exports.tryDelete = exports.handleCacheFailure = exports.cacheDebug = exports.saveCache = exports.restoreCache = exports.hashStrings = exports.hashFileNames = exports.getCacheKeyPrefix = exports.generateCacheKey = exports.CacheKey = exports.isCacheCleanupEnabled = exports.isCacheDebuggingEnabled = exports.isCacheOverwriteExisting = exports.isCacheWriteOnly = exports.isCacheReadOnly = exports.isCacheDisabled = void 0;
|
||||
const core = __importStar(__nccwpck_require__(42186));
|
||||
const cache = __importStar(__nccwpck_require__(27799));
|
||||
const github = __importStar(__nccwpck_require__(95438));
|
||||
|
@ -137030,34 +137030,16 @@ function getCacheKeyEnvironment() {
|
|||
return process.env[CACHE_KEY_OS_VAR] || runnerOs;
|
||||
}
|
||||
function getCacheKeyJob() {
|
||||
return process.env[CACHE_KEY_JOB_VAR] || getCacheKeyForJob(github.context.workflow, github.context.job);
|
||||
return process.env[CACHE_KEY_JOB_VAR] || github.context.job;
|
||||
}
|
||||
function getCacheKeyForJob(workflowName, jobId) {
|
||||
const sanitizedWorkflow = workflowName.replace(/,/g, '').toLowerCase();
|
||||
return `${sanitizedWorkflow}-${jobId}`;
|
||||
}
|
||||
exports.getCacheKeyForJob = getCacheKeyForJob;
|
||||
function getCacheKeyJobInstance() {
|
||||
const override = process.env[CACHE_KEY_JOB_INSTANCE_VAR];
|
||||
if (override) {
|
||||
return override;
|
||||
}
|
||||
const workflowName = github.context.workflow;
|
||||
const workflowJobContext = params.getJobMatrix();
|
||||
return hashStrings([workflowJobContext]);
|
||||
}
|
||||
function getUniqueLabelForJobInstance() {
|
||||
return getUniqueLabelForJobInstanceValues(github.context.workflow, github.context.job, params.getJobMatrix());
|
||||
}
|
||||
exports.getUniqueLabelForJobInstance = getUniqueLabelForJobInstance;
|
||||
function getUniqueLabelForJobInstanceValues(workflow, jobId, matrixJson) {
|
||||
const matrix = JSON.parse(matrixJson);
|
||||
const matrixString = Object.values(matrix).join('-');
|
||||
const label = matrixString ? `${workflow}-${jobId}-${matrixString}` : `${workflow}-${jobId}`;
|
||||
return sanitize(label);
|
||||
}
|
||||
exports.getUniqueLabelForJobInstanceValues = getUniqueLabelForJobInstanceValues;
|
||||
function sanitize(value) {
|
||||
return value.replace(/[^a-zA-Z0-9_-]/g, '').toLowerCase();
|
||||
return hashStrings([workflowName, workflowJobContext]);
|
||||
}
|
||||
function getCacheKeyJobExecution() {
|
||||
return process.env[CACHE_KEY_JOB_EXECUTION_VAR] || github.context.sha;
|
||||
|
|
2
dist/post/index.js.map
vendored
2
dist/post/index.js.map
vendored
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue