Compare commits

...

1 Commits

Author SHA1 Message Date
Peng Xiao
343cc68d8f
fix: add arch to cached path 2023-08-30 00:36:04 +08:00
3 changed files with 2288 additions and 2282 deletions

View File

@ -11,7 +11,11 @@ describe('cache-restore', () => {
if (!process.env.RUNNER_OS) {
process.env.RUNNER_OS = 'Linux';
}
if (!process.env.RUNNER_ARCH) {
process.env.RUNNER_ARCH = 'X64';
}
const platform = process.env.RUNNER_OS;
const arch = process.env.RUNNER_ARCH;
const commonPath = '/some/random/path';
const npmCachePath = `${commonPath}/npm`;
const pnpmCachePath = `${commonPath}/pnpm`;
@ -135,7 +139,7 @@ describe('cache-restore', () => {
await restoreCache(packageManager, '');
expect(hashFilesSpy).toHaveBeenCalled();
expect(infoSpy).toHaveBeenCalledWith(
`Cache restored from key: node-cache-${platform}-${packageManager}-${fileHash}`
`Cache restored from key: node-cache-${platform}-${arch}-${packageManager}-${fileHash}`
);
expect(infoSpy).not.toHaveBeenCalledWith(
`${packageManager} cache is not found`

4561
dist/setup/index.js vendored

File diff suppressed because it is too large Load Diff

View File

@ -21,6 +21,7 @@ export const restoreCache = async (
throw new Error(`Caching for '${packageManager}' is not supported`);
}
const platform = process.env.RUNNER_OS;
const arch = process.env.RUNNER_ARCH;
const cachePaths = await getCacheDirectories(
packageManagerInfo,
@ -38,7 +39,7 @@ export const restoreCache = async (
);
}
const keyPrefix = `node-cache-${platform}-${packageManager}`;
const keyPrefix = `node-cache-${platform}-${arch}-${packageManager}`;
const primaryKey = `${keyPrefix}-${fileHash}`;
core.debug(`primary key is ${primaryKey}`);