Skip to content

Commit 4cd5bdc

Browse files
authored
feat: add arch to cache key
1 parent 6bd8b7f commit 4cd5bdc

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

__tests__/cache-restore.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe('cache-restore tests', () => {
5050

5151
await restoreCache(lockFilePattern);
5252

53-
const expectedKey = `dotnet-cache-${process.env.RUNNER_OS}-hash`;
53+
const expectedKey = `dotnet-cache-${process.env.RUNNER_OS}-${process.arch}-hash`;
5454
expect(jest.mocked(core.saveState)).toHaveBeenCalledWith(
5555
'CACHE_KEY',
5656
expectedKey
@@ -66,7 +66,7 @@ describe('cache-restore tests', () => {
6666
});
6767

6868
it('calls core.saveState("CACHE_RESULT") when cache.restoreCache() returns key', async () => {
69-
const expectedKey = `dotnet-cache-${process.env.RUNNER_OS}-hash`;
69+
const expectedKey = `dotnet-cache-${process.env.RUNNER_OS}-${process.arch}-hash`;
7070
jest.mocked(glob.hashFiles).mockResolvedValue('hash');
7171
jest.mocked(cache.restoreCache).mockResolvedValue(expectedKey);
7272

dist/setup/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93479,7 +93479,8 @@ const restoreCache = (cacheDependencyPath) => __awaiter(void 0, void 0, void 0,
9347993479
throw new Error('Some specified paths were not resolved, unable to cache dependencies.');
9348093480
}
9348193481
const platform = process.env.RUNNER_OS;
93482-
const primaryKey = `dotnet-cache-${platform}-${fileHash}`;
93482+
const arch = process.arch;
93483+
const primaryKey = `dotnet-cache-${platform}-${arch}-${fileHash}`;
9348393484
core.debug(`primary key is ${primaryKey}`);
9348493485
core.saveState(constants_1.State.CachePrimaryKey, primaryKey);
9348593486
const { 'global-packages': cachePath } = yield (0, cache_utils_1.getNuGetFolderPath)();

src/cache-restore.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ export const restoreCache = async (cacheDependencyPath?: string) => {
1717
}
1818

1919
const platform = process.env.RUNNER_OS;
20-
const primaryKey = `dotnet-cache-${platform}-${fileHash}`;
20+
const arch = process.arch;
21+
const primaryKey = `dotnet-cache-${platform}-${arch}-${fileHash}`;
2122
core.debug(`primary key is ${primaryKey}`);
2223

2324
core.saveState(State.CachePrimaryKey, primaryKey);

0 commit comments

Comments
 (0)