Fix incorrect cache-hit check
This commit is contained in:
7
dist/cleanup/index.js
vendored
7
dist/cleanup/index.js
vendored
@@ -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;
|
||||
|
||||
7
dist/setup/index.js
vendored
7
dist/setup/index.js
vendored
@@ -131874,7 +131874,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}`;
|
||||
});
|
||||
}
|
||||
/**
|
||||
@@ -131892,10 +131892,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`);
|
||||
}
|
||||
@@ -131909,7 +131911,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);
|
||||
@@ -131917,7 +131918,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;
|
||||
|
||||
@@ -99,7 +99,7 @@ async function computeCacheKey(
|
||||
`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}`;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -117,9 +117,11 @@ export async function restore(id: string, cacheDependencyPath: string) {
|
||||
const matchedKey = await 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`);
|
||||
}
|
||||
@@ -131,7 +133,6 @@ export async function restore(id: string, cacheDependencyPath: string) {
|
||||
*/
|
||||
export async function save(id: string) {
|
||||
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);
|
||||
@@ -140,7 +141,7 @@ export async function save(id: string) {
|
||||
if (!primaryKey) {
|
||||
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.`
|
||||
|
||||
Reference in New Issue
Block a user