From 3ec743e66d720ca0666791cb3ccf66547d1e34fe 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 ff4bec264..f22c64272 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -73046,8 +73046,9 @@ const 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 7f761da44..6ddb59252 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) {