Fix incorrect cache-hit check

This commit is contained in:
rak
2025-03-18 21:53:50 +01:00
parent 555aead9ed
commit 5a1d04e5f3
3 changed files with 12 additions and 9 deletions

View File

@@ -96625,7 +96625,7 @@ function computeCacheKey(packageManager, cacheDependencyPath) {
if (!fileHash) {
throw new Error(`No file in ${process.cwd()} matched to [${pattern}], make sure you have checked out the target repository`);
}
return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-ABC-${process.arch}-${packageManager.id}-${fileHash}`;
return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${process.arch}-${packageManager.id}-${fileHash}`;
});
}
/**
@@ -96643,10 +96643,12 @@ function restore(id, cacheDependencyPath) {
const matchedKey = yield cache.restoreCache(packageManager.path, primaryKey);
if (matchedKey) {
core.saveState(CACHE_MATCHED_KEY, matchedKey);
core.saveState(STATE_CACHE_HIT, true);
core.setOutput('cache-hit', true);
core.info(`Cache restored from key: ${matchedKey}`);
}
else {
core.saveState(STATE_CACHE_HIT, false);
core.setOutput('cache-hit', false);
core.info(`${packageManager.id} cache is not found`);
}
@@ -96660,7 +96662,6 @@ exports.restore = restore;
function save(id) {
return __awaiter(this, void 0, void 0, function* () {
const packageManager = findPackageManager(id);
const matchedKey = core.getState(CACHE_MATCHED_KEY);
// Inputs are re-evaluated before the post action, so we want the original key used for restore
const primaryKey = core.getState(STATE_CACHE_PRIMARY_KEY);
const cacheHit = core.getState(STATE_CACHE_HIT);
@@ -96668,7 +96669,7 @@ function save(id) {
core.warning('Error retrieving key from state.');
return;
}
else if (matchedKey === primaryKey || cacheHit) {
else if (cacheHit) {
// no change in target directories
core.info(`Cache hit occurred on the primary key ${primaryKey}, not saving cache.`);
return;