@@ -73030,7 +73030,7 @@ const path_1 = __importDefault(__nccwpck_require__(1017));
73030
73030
const fs_1 = __importDefault(__nccwpck_require__(7147));
73031
73031
const constants_1 = __nccwpck_require__(9042);
73032
73032
const cache_utils_1 = __nccwpck_require__(1678);
73033
- const restoreCache = (packageManager, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () {
73033
+ const restoreCache = (packageManager, cacheDependencyPath, cacheInvalidateAfterDays ) => __awaiter(void 0, void 0, void 0, function* () {
73034
73034
const packageManagerInfo = yield cache_utils_1.getPackageManagerInfo(packageManager);
73035
73035
if (!packageManagerInfo) {
73036
73036
throw new Error(`Caching for '${packageManager}' is not supported`);
@@ -73044,9 +73044,15 @@ const restoreCache = (packageManager, cacheDependencyPath) => __awaiter(void 0,
73044
73044
if (!fileHash) {
73045
73045
throw new Error('Some specified paths were not resolved, unable to cache dependencies.');
73046
73046
}
73047
- const keyPrefix = `${platform}-setup-node-`;
73047
+ const numericCacheInvalidateAfterDays = cacheInvalidateAfterDays && cacheInvalidateAfterDays === '0'
73048
+ ? 0
73049
+ : (parseInt(cacheInvalidateAfterDays || '', 10) || 120);
73050
+ const timedInvalidationPrefix = numericCacheInvalidateAfterDays
73051
+ ? Math.floor(Date.now() / (1000 * 60 * 60 * 24 * numericCacheInvalidateAfterDays)) % 1000 // % 1000 to get a rolling prefix between 0 and 999 rather than a possibly infinitely large
73052
+ : 0;
73053
+ const keyPrefix = `${platform}-${timedInvalidationPrefix}-setup-node-`;
73048
73054
const primaryKey = `${keyPrefix}${packageManager}-${fileHash}`;
73049
- const restoreKeys = [`${keyPrefix}${packageManager}-`, keyPrefix ];
73055
+ const restoreKeys = [`${keyPrefix}${packageManager}-`];
73050
73056
core.debug(`primary key is ${primaryKey}`);
73051
73057
core.saveState(constants_1.State.CachePrimaryKey, primaryKey);
73052
73058
const cacheKey = yield cache.restoreCache([cachePath], primaryKey, restoreKeys);
@@ -73981,7 +73987,8 @@ function run() {
73981
73987
}
73982
73988
if (cache && cache_utils_1.isCacheFeatureAvailable()) {
73983
73989
const cacheDependencyPath = core.getInput('cache-dependency-path');
73984
- yield cache_restore_1.restoreCache(cache, cacheDependencyPath);
73990
+ const cacheInvalidateAfterDays = core.getInput('cache-invalidate-after-days');
73991
+ yield cache_restore_1.restoreCache(cache, cacheDependencyPath, cacheInvalidateAfterDays);
73985
73992
}
73986
73993
const matchersPath = path.join(__dirname, '../..', '.github');
73987
73994
core.info(`##[add-matcher]${path.join(matchersPath, 'tsc.json')}`);
0 commit comments