fix: remove the OS name from cache key

This commit is contained in:
Kengo TODA 2021-09-06 02:14:44 +00:00
parent 7b921a1561
commit 30c9ec6245
3 changed files with 9 additions and 9 deletions

View file

@ -64569,14 +64569,14 @@ function findPackageManager(id) {
exports.findPackageManager = findPackageManager; exports.findPackageManager = findPackageManager;
/** /**
* A function that generates a cache key to use. * A function that generates a cache key to use.
* Format of the generated key will be "${{ platform }}-${{ id }}-${{ fileHash }}"". * Format of the generated key will be "setup-java-${{ id }}-${{ fileHash }}"".
* If there is no file matched to {@link PackageManager.path}, the generated key ends with a dash (-). * If there is no file matched to {@link PackageManager.path}, the generated key ends with a dash (-).
* @see {@link https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#matching-a-cache-key|spec of cache key} * @see {@link https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#matching-a-cache-key|spec of cache key}
*/ */
function computeCacheKey(packageManager) { function computeCacheKey(packageManager) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const hash = yield glob.hashFiles(packageManager.pattern.join('\n')); const hash = yield glob.hashFiles(packageManager.pattern.join('\n'));
return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${packageManager.id}-${hash}`; return `${CACHE_KEY_PREFIX}-${packageManager.id}-${hash}`;
}); });
} }
exports.computeCacheKey = computeCacheKey; exports.computeCacheKey = computeCacheKey;
@ -64594,7 +64594,7 @@ function restore(id) {
throw new Error(`No file in ${process.cwd()} matched to [${packageManager.pattern}], make sure you have checked out the target repository`); throw new Error(`No file in ${process.cwd()} matched to [${packageManager.pattern}], make sure you have checked out the target repository`);
} }
const matchedKey = yield cache.restoreCache(packageManager.path, primaryKey, [ const matchedKey = yield cache.restoreCache(packageManager.path, primaryKey, [
`${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${id}` `${CACHE_KEY_PREFIX}-${id}`
]); ]);
if (matchedKey) { if (matchedKey) {
core.saveState(CACHE_MATCHED_KEY, matchedKey); core.saveState(CACHE_MATCHED_KEY, matchedKey);

6
dist/setup/index.js vendored
View file

@ -18956,14 +18956,14 @@ function findPackageManager(id) {
exports.findPackageManager = findPackageManager; exports.findPackageManager = findPackageManager;
/** /**
* A function that generates a cache key to use. * A function that generates a cache key to use.
* Format of the generated key will be "${{ platform }}-${{ id }}-${{ fileHash }}"". * Format of the generated key will be "setup-java-${{ id }}-${{ fileHash }}"".
* If there is no file matched to {@link PackageManager.path}, the generated key ends with a dash (-). * If there is no file matched to {@link PackageManager.path}, the generated key ends with a dash (-).
* @see {@link https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#matching-a-cache-key|spec of cache key} * @see {@link https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#matching-a-cache-key|spec of cache key}
*/ */
function computeCacheKey(packageManager) { function computeCacheKey(packageManager) {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
const hash = yield glob.hashFiles(packageManager.pattern.join('\n')); const hash = yield glob.hashFiles(packageManager.pattern.join('\n'));
return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${packageManager.id}-${hash}`; return `${CACHE_KEY_PREFIX}-${packageManager.id}-${hash}`;
}); });
} }
exports.computeCacheKey = computeCacheKey; exports.computeCacheKey = computeCacheKey;
@ -18981,7 +18981,7 @@ function restore(id) {
throw new Error(`No file in ${process.cwd()} matched to [${packageManager.pattern}], make sure you have checked out the target repository`); throw new Error(`No file in ${process.cwd()} matched to [${packageManager.pattern}], make sure you have checked out the target repository`);
} }
const matchedKey = yield cache.restoreCache(packageManager.path, primaryKey, [ const matchedKey = yield cache.restoreCache(packageManager.path, primaryKey, [
`${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${id}` `${CACHE_KEY_PREFIX}-${id}`
]); ]);
if (matchedKey) { if (matchedKey) {
core.saveState(CACHE_MATCHED_KEY, matchedKey); core.saveState(CACHE_MATCHED_KEY, matchedKey);

View file

@ -45,13 +45,13 @@ export function findPackageManager(id: string): PackageManager {
/** /**
* A function that generates a cache key to use. * A function that generates a cache key to use.
* Format of the generated key will be "${{ platform }}-${{ id }}-${{ fileHash }}"". * Format of the generated key will be "setup-java-${{ id }}-${{ fileHash }}"".
* If there is no file matched to {@link PackageManager.path}, the generated key ends with a dash (-). * If there is no file matched to {@link PackageManager.path}, the generated key ends with a dash (-).
* @see {@link https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#matching-a-cache-key|spec of cache key} * @see {@link https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#matching-a-cache-key|spec of cache key}
*/ */
export async function computeCacheKey(packageManager: PackageManager) { export async function computeCacheKey(packageManager: PackageManager) {
const hash = await glob.hashFiles(packageManager.pattern.join('\n')); const hash = await glob.hashFiles(packageManager.pattern.join('\n'));
return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${packageManager.id}-${hash}`; return `${CACHE_KEY_PREFIX}-${packageManager.id}-${hash}`;
} }
/** /**
@ -73,7 +73,7 @@ export async function restore(id: string) {
} }
const matchedKey = await cache.restoreCache(packageManager.path, primaryKey, [ const matchedKey = await cache.restoreCache(packageManager.path, primaryKey, [
`${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${id}` `${CACHE_KEY_PREFIX}-${id}`
]); ]);
if (matchedKey) { if (matchedKey) {
core.saveState(CACHE_MATCHED_KEY, matchedKey); core.saveState(CACHE_MATCHED_KEY, matchedKey);