Merge pull request #3232 from github/kaspersv/unique-overlay-base-keys

Ensure uniqueness of overlay-base database cache keys
This commit is contained in:
Kasper Svendsen
2025-10-27 08:36:12 +01:00
committed by GitHub
3 changed files with 83 additions and 7 deletions
+14 -3
View File
@@ -91070,7 +91070,8 @@ async function uploadOverlayBaseDatabaseToCache(codeql, config, logger) {
const cacheSaveKey = await getCacheSaveKey(
config,
codeQlVersion,
checkoutPath
checkoutPath,
logger
);
logger.info(
`Uploading overlay-base database to Actions cache with key ${cacheSaveKey}`
@@ -91095,13 +91096,23 @@ async function uploadOverlayBaseDatabaseToCache(codeql, config, logger) {
logger.info(`Successfully uploaded overlay-base database from ${dbLocation}`);
return true;
}
async function getCacheSaveKey(config, codeQlVersion, checkoutPath) {
async function getCacheSaveKey(config, codeQlVersion, checkoutPath, logger) {
let runId = 1;
let attemptId = 1;
try {
runId = getWorkflowRunID();
attemptId = getWorkflowRunAttempt();
} catch (e) {
logger.warning(
`Failed to get workflow run ID or attempt ID. Reason: ${getErrorMessage(e)}`
);
}
const sha = await getCommitOid(checkoutPath);
const restoreKeyPrefix = await getCacheRestoreKeyPrefix(
config,
codeQlVersion
);
return `${restoreKeyPrefix}${sha}`;
return `${restoreKeyPrefix}${sha}-${runId}-${attemptId}`;
}
async function getCacheRestoreKeyPrefix(config, codeQlVersion) {
const languages = [...config.languages].sort().join("_");