Skip to content

Commit

Permalink
apply fixes to restoreCache
Browse files Browse the repository at this point in the history
  • Loading branch information
deemp committed Jul 17, 2023
1 parent eefa7c9 commit 93041f2
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 11 deletions.
4 changes: 3 additions & 1 deletion dist/restore-only/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47804,7 +47804,9 @@ function restoreImpl(stateProvider) {
const enableCrossOsArchive = utils.getInputAsBool(constants_1.Inputs.EnableCrossOsArchive);
const failOnCacheMiss = utils.getInputAsBool(constants_1.Inputs.FailOnCacheMiss);
const lookupOnly = utils.getInputAsBool(constants_1.Inputs.LookupOnly);
const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys, { lookupOnly: lookupOnly }, enableCrossOsArchive);
const cacheKey = yield cache.restoreCache(
// https://github.com/actions/toolkit/pull/1378#issuecomment-1478388929
cachePaths.slice(), primaryKey, restoreKeys, { lookupOnly: lookupOnly }, enableCrossOsArchive);
if (!cacheKey) {
if (failOnCacheMiss) {
throw new Error(`Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${primaryKey}`);
Expand Down
4 changes: 3 additions & 1 deletion dist/restore/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47804,7 +47804,9 @@ function restoreImpl(stateProvider) {
const enableCrossOsArchive = utils.getInputAsBool(constants_1.Inputs.EnableCrossOsArchive);
const failOnCacheMiss = utils.getInputAsBool(constants_1.Inputs.FailOnCacheMiss);
const lookupOnly = utils.getInputAsBool(constants_1.Inputs.LookupOnly);
const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys, { lookupOnly: lookupOnly }, enableCrossOsArchive);
const cacheKey = yield cache.restoreCache(
// https://github.com/actions/toolkit/pull/1378#issuecomment-1478388929
cachePaths.slice(), primaryKey, restoreKeys, { lookupOnly: lookupOnly }, enableCrossOsArchive);
if (!cacheKey) {
if (failOnCacheMiss) {
throw new Error(`Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${primaryKey}`);
Expand Down
2 changes: 1 addition & 1 deletion dist/save-only/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37970,7 +37970,7 @@ function saveImpl(stateProvider) {
const enableCrossOsArchive = utils.getInputAsBool(constants_1.Inputs.EnableCrossOsArchive);
// If matched restore key is same as primary key, then do not save cache
// NO-OP in case of SaveOnly action
const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys, { lookupOnly: true }, enableCrossOsArchive);
const cacheKey = yield cache.restoreCache(cachePaths.slice(), primaryKey, restoreKeys, { lookupOnly: true }, enableCrossOsArchive);
core.info(`Primary key: ${primaryKey}`);
core.info(`Existing cache key: ${cacheKey}`);
const restoredKey = cacheKey;
Expand Down
2 changes: 1 addition & 1 deletion dist/save/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37914,7 +37914,7 @@ function saveImpl(stateProvider) {
const enableCrossOsArchive = utils.getInputAsBool(constants_1.Inputs.EnableCrossOsArchive);
// If matched restore key is same as primary key, then do not save cache
// NO-OP in case of SaveOnly action
const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys, { lookupOnly: true }, enableCrossOsArchive);
const cacheKey = yield cache.restoreCache(cachePaths.slice(), primaryKey, restoreKeys, { lookupOnly: true }, enableCrossOsArchive);
core.info(`Primary key: ${primaryKey}`);
core.info(`Existing cache key: ${cacheKey}`);
const restoredKey = cacheKey;
Expand Down
3 changes: 2 additions & 1 deletion src/restoreImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ async function restoreImpl(
const lookupOnly = utils.getInputAsBool(Inputs.LookupOnly);

const cacheKey = await cache.restoreCache(
cachePaths,
// https://github.com/actions/toolkit/pull/1378#issuecomment-1478388929
cachePaths.slice(),
primaryKey,
restoreKeys,
{ lookupOnly: lookupOnly },
Expand Down
10 changes: 4 additions & 6 deletions src/saveImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ async function saveImpl(stateProvider: IStateProvider): Promise<number | void> {
return;
}


const cachePaths = utils.getInputAsArray(Inputs.Path, {
required: false
});
Expand All @@ -53,16 +52,16 @@ async function saveImpl(stateProvider: IStateProvider): Promise<number | void> {
// If matched restore key is same as primary key, then do not save cache
// NO-OP in case of SaveOnly action
const cacheKey = await cache.restoreCache(
cachePaths,
cachePaths.slice(),
primaryKey,
restoreKeys,
{ lookupOnly: true },
enableCrossOsArchive
);

core.info(`Primary key: ${primaryKey}`)
core.info(`Existing cache key: ${cacheKey}`)
core.info(`Primary key: ${primaryKey}`);
core.info(`Existing cache key: ${cacheKey}`);

const restoredKey = cacheKey;

if (utils.isExactKeyMatch(primaryKey, restoredKey)) {
Expand All @@ -72,7 +71,6 @@ async function saveImpl(stateProvider: IStateProvider): Promise<number | void> {
return;
}


await exec("bash", ["-c", "sudo rm -rf /nix/.[!.]* /nix/..?*"]);

const gcEnabled = utils.getInputAsBool(
Expand Down

0 comments on commit 93041f2

Please sign in to comment.