Skip to content

Commit fe37d8c

Browse files
committed
fix: remove the OS name from cache key
1 parent 3a3331b commit fe37d8c

3 files changed

Lines changed: 17 additions & 13 deletions

File tree

dist/cleanup/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64536,7 +64536,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
6453664536
return (mod && mod.__esModule) ? mod : { "default": mod };
6453764537
};
6453864538
Object.defineProperty(exports, "__esModule", { value: true });
64539-
exports.save = exports.restore = void 0;
64539+
exports.save = exports.restore = exports.computeCacheKey = exports.findPackageManager = void 0;
6454064540
const path_1 = __webpack_require__(622);
6454164541
const os_1 = __importDefault(__webpack_require__(87));
6454264542
const cache = __importStar(__webpack_require__(692));
@@ -64566,18 +64566,20 @@ function findPackageManager(id) {
6456664566
}
6456764567
return packageManager;
6456864568
}
64569+
exports.findPackageManager = findPackageManager;
6456964570
/**
6457064571
* A function that generates a cache key to use.
64571-
* Format of the generated key will be "${{ platform }}-${{ id }}-${{ fileHash }}"".
64572+
* Format of the generated key will be "setup-java-${{ id }}-${{ fileHash }}"".
6457264573
* If there is no file matched to {@link PackageManager.path}, the generated key ends with a dash (-).
6457364574
* @see {@link https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#matching-a-cache-key|spec of cache key}
6457464575
*/
6457564576
function computeCacheKey(packageManager) {
6457664577
return __awaiter(this, void 0, void 0, function* () {
6457764578
const hash = yield glob.hashFiles(packageManager.pattern.join('\n'));
64578-
return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${packageManager.id}-${hash}`;
64579+
return `${CACHE_KEY_PREFIX}-${packageManager.id}-${hash}`;
6457964580
});
6458064581
}
64582+
exports.computeCacheKey = computeCacheKey;
6458164583
/**
6458264584
* Restore the dependency cache
6458364585
* @param id ID of the package manager, should be "maven" or "gradle"
@@ -64592,7 +64594,7 @@ function restore(id) {
6459264594
throw new Error(`No file in ${process.cwd()} matched to [${packageManager.pattern}], make sure you have checked out the target repository`);
6459364595
}
6459464596
const matchedKey = yield cache.restoreCache(packageManager.path, primaryKey, [
64595-
`${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${id}`
64597+
`${CACHE_KEY_PREFIX}-${id}`
6459664598
]);
6459764599
if (matchedKey) {
6459864600
core.saveState(CACHE_MATCHED_KEY, matchedKey);

dist/setup/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18923,7 +18923,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
1892318923
return (mod && mod.__esModule) ? mod : { "default": mod };
1892418924
};
1892518925
Object.defineProperty(exports, "__esModule", { value: true });
18926-
exports.save = exports.restore = void 0;
18926+
exports.save = exports.restore = exports.computeCacheKey = exports.findPackageManager = void 0;
1892718927
const path_1 = __webpack_require__(622);
1892818928
const os_1 = __importDefault(__webpack_require__(87));
1892918929
const cache = __importStar(__webpack_require__(692));
@@ -18953,18 +18953,20 @@ function findPackageManager(id) {
1895318953
}
1895418954
return packageManager;
1895518955
}
18956+
exports.findPackageManager = findPackageManager;
1895618957
/**
1895718958
* A function that generates a cache key to use.
18958-
* Format of the generated key will be "${{ platform }}-${{ id }}-${{ fileHash }}"".
18959+
* Format of the generated key will be "setup-java-${{ id }}-${{ fileHash }}"".
1895918960
* If there is no file matched to {@link PackageManager.path}, the generated key ends with a dash (-).
1896018961
* @see {@link https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#matching-a-cache-key|spec of cache key}
1896118962
*/
1896218963
function computeCacheKey(packageManager) {
1896318964
return __awaiter(this, void 0, void 0, function* () {
1896418965
const hash = yield glob.hashFiles(packageManager.pattern.join('\n'));
18965-
return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${packageManager.id}-${hash}`;
18966+
return `${CACHE_KEY_PREFIX}-${packageManager.id}-${hash}`;
1896618967
});
1896718968
}
18969+
exports.computeCacheKey = computeCacheKey;
1896818970
/**
1896918971
* Restore the dependency cache
1897018972
* @param id ID of the package manager, should be "maven" or "gradle"
@@ -18979,7 +18981,7 @@ function restore(id) {
1897918981
throw new Error(`No file in ${process.cwd()} matched to [${packageManager.pattern}], make sure you have checked out the target repository`);
1898018982
}
1898118983
const matchedKey = yield cache.restoreCache(packageManager.path, primaryKey, [
18982-
`${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${id}`
18984+
`${CACHE_KEY_PREFIX}-${id}`
1898318985
]);
1898418986
if (matchedKey) {
1898518987
core.saveState(CACHE_MATCHED_KEY, matchedKey);

src/cache.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const supportedPackageManager: PackageManager[] = [
3535
}
3636
];
3737

38-
function findPackageManager(id: string): PackageManager {
38+
export function findPackageManager(id: string): PackageManager {
3939
const packageManager = supportedPackageManager.find(packageManager => packageManager.id === id);
4040
if (packageManager === undefined) {
4141
throw new Error(`unknown package manager specified: ${id}`);
@@ -45,13 +45,13 @@ function findPackageManager(id: string): PackageManager {
4545

4646
/**
4747
* A function that generates a cache key to use.
48-
* Format of the generated key will be "${{ platform }}-${{ id }}-${{ fileHash }}"".
48+
* Format of the generated key will be "setup-java-${{ id }}-${{ fileHash }}"".
4949
* If there is no file matched to {@link PackageManager.path}, the generated key ends with a dash (-).
5050
* @see {@link https://docs.github.com/en/actions/guides/caching-dependencies-to-speed-up-workflows#matching-a-cache-key|spec of cache key}
5151
*/
52-
async function computeCacheKey(packageManager: PackageManager) {
52+
export async function computeCacheKey(packageManager: PackageManager) {
5353
const hash = await glob.hashFiles(packageManager.pattern.join('\n'));
54-
return `${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${packageManager.id}-${hash}`;
54+
return `${CACHE_KEY_PREFIX}-${packageManager.id}-${hash}`;
5555
}
5656

5757
/**
@@ -73,7 +73,7 @@ export async function restore(id: string) {
7373
}
7474

7575
const matchedKey = await cache.restoreCache(packageManager.path, primaryKey, [
76-
`${CACHE_KEY_PREFIX}-${process.env['RUNNER_OS']}-${id}`
76+
`${CACHE_KEY_PREFIX}-${id}`
7777
]);
7878
if (matchedKey) {
7979
core.saveState(CACHE_MATCHED_KEY, matchedKey);

0 commit comments

Comments
 (0)