From bd6483add60213c255e1f5297f6394ed26df706c Mon Sep 17 00:00:00 2001 From: Neil Gentleman Date: Wed, 8 Dec 2021 09:57:24 -0800 Subject: [PATCH] provide fallback cache keys it's a lot faster to start from a 90% correct cache than an empty one re: https://github.com/actions/setup-node/issues/286 re: https://github.com/actions/setup-node/pull/323 re: https://github.com/actions/setup-node/issues/328 --- dist/setup/index.js | 3 ++- src/cache-restore.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 1dc2f2f5e..3c26f480c 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -38975,8 +38975,9 @@ exports.restoreCache = (packageManager, cacheDependencyPath) => __awaiter(void 0 } const primaryKey = `node-cache-${platform}-${packageManager}-${fileHash}`; core.debug(`primary key is ${primaryKey}`); + const restoreKeys = [`node-cache-${platform}-${packageManager}-`]; core.saveState(constants_1.State.CachePrimaryKey, primaryKey); - const cacheKey = yield cache.restoreCache([cachePath], primaryKey); + const cacheKey = yield cache.restoreCache([cachePath], primaryKey, restoreKeys); core.setOutput('cache-hit', Boolean(cacheKey)); if (!cacheKey) { core.info(`${packageManager} cache is not found`); diff --git a/src/cache-restore.ts b/src/cache-restore.ts index d49b27fc5..ce1ecb122 100644 --- a/src/cache-restore.ts +++ b/src/cache-restore.ts @@ -38,10 +38,11 @@ export const restoreCache = async ( const primaryKey = `node-cache-${platform}-${packageManager}-${fileHash}`; core.debug(`primary key is ${primaryKey}`); + const restoreKeys = [`node-cache-${platform}-${packageManager}-`]; core.saveState(State.CachePrimaryKey, primaryKey); - const cacheKey = await cache.restoreCache([cachePath], primaryKey); + const cacheKey = await cache.restoreCache([cachePath], primaryKey, restoreKeys); core.setOutput('cache-hit', Boolean(cacheKey)); if (!cacheKey) {