From b26d40294f8ad76fcc90b915dac85892322fe62d Mon Sep 17 00:00:00 2001 From: Zxilly <31370133+Zxilly@users.noreply.github.com> Date: Tue, 27 Aug 2024 04:19:57 +0800 Subject: [PATCH] fix: add arch to cache key (#493) --- dist/setup/index.js | 3 ++- src/cache-restore.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 9ad3784ea..d4b4aa8a4 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -88045,6 +88045,7 @@ const cache_utils_1 = __nccwpck_require__(1678); const restoreCache = (versionSpec, packageManager, cacheDependencyPath) => __awaiter(void 0, void 0, void 0, function* () { const packageManagerInfo = yield (0, cache_utils_1.getPackageManagerInfo)(packageManager); const platform = process.env.RUNNER_OS; + const arch = process.arch; const cachePaths = yield (0, cache_utils_1.getCacheDirectoryPath)(packageManagerInfo); const dependencyFilePath = cacheDependencyPath ? cacheDependencyPath @@ -88054,7 +88055,7 @@ const restoreCache = (versionSpec, packageManager, cacheDependencyPath) => __awa throw new Error('Some specified paths were not resolved, unable to cache dependencies.'); } const linuxVersion = process.env.RUNNER_OS === 'Linux' ? `${process.env.ImageOS}-` : ''; - const primaryKey = `setup-go-${platform}-${linuxVersion}go-${versionSpec}-${fileHash}`; + const primaryKey = `setup-go-${platform}-${arch}-${linuxVersion}go-${versionSpec}-${fileHash}`; core.debug(`primary key is ${primaryKey}`); core.saveState(constants_1.State.CachePrimaryKey, primaryKey); const cacheKey = yield cache.restoreCache(cachePaths, primaryKey); diff --git a/src/cache-restore.ts b/src/cache-restore.ts index 183df9ea5..18d930bdf 100644 --- a/src/cache-restore.ts +++ b/src/cache-restore.ts @@ -15,6 +15,7 @@ export const restoreCache = async ( ) => { const packageManagerInfo = await getPackageManagerInfo(packageManager); const platform = process.env.RUNNER_OS; + const arch = process.arch; const cachePaths = await getCacheDirectoryPath(packageManagerInfo); @@ -31,7 +32,7 @@ export const restoreCache = async ( const linuxVersion = process.env.RUNNER_OS === 'Linux' ? `${process.env.ImageOS}-` : ''; - const primaryKey = `setup-go-${platform}-${linuxVersion}go-${versionSpec}-${fileHash}`; + const primaryKey = `setup-go-${platform}-${arch}-${linuxVersion}go-${versionSpec}-${fileHash}`; core.debug(`primary key is ${primaryKey}`); core.saveState(State.CachePrimaryKey, primaryKey);