From a4d10f0ea40982c8b7151dd9d5434b1a090318cc Mon Sep 17 00:00:00 2001 From: Sergey Dolin Date: Tue, 6 Jun 2023 09:27:42 +0200 Subject: [PATCH 1/2] Add imageOS to primaryKey https://github.com/actions/setup-go/issues/368 --- 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 0dcd234..8f52dfd 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -61155,7 +61155,8 @@ const restoreCache = (versionSpec, packageManager, cacheDependencyPath) => __awa if (!fileHash) { throw new Error('Some specified paths were not resolved, unable to cache dependencies.'); } - const primaryKey = `setup-go-${platform}-go-${versionSpec}-${fileHash}`; + const imageOS = process.env.ImageOS || 'self-hosted'; + const primaryKey = `setup-go-${platform}-${imageOS}-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 14f84c4..b3998ea 100644 --- a/src/cache-restore.ts +++ b/src/cache-restore.ts @@ -29,7 +29,8 @@ export const restoreCache = async ( ); } - const primaryKey = `setup-go-${platform}-go-${versionSpec}-${fileHash}`; + const imageOS = process.env.ImageOS || 'self-hosted'; + const primaryKey = `setup-go-${platform}-${imageOS}-go-${versionSpec}-${fileHash}`; core.debug(`primary key is ${primaryKey}`); core.saveState(State.CachePrimaryKey, primaryKey); From 4e0b6c77c6448caafaff5eed51516cad78e7639a Mon Sep 17 00:00:00 2001 From: Sergey Dolin Date: Wed, 7 Jun 2023 08:56:00 +0200 Subject: [PATCH 2/2] Limit to Linux only --- dist/setup/index.js | 4 ++-- src/cache-restore.ts | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 8f52dfd..378197f 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -61155,8 +61155,8 @@ const restoreCache = (versionSpec, packageManager, cacheDependencyPath) => __awa if (!fileHash) { throw new Error('Some specified paths were not resolved, unable to cache dependencies.'); } - const imageOS = process.env.ImageOS || 'self-hosted'; - const primaryKey = `setup-go-${platform}-${imageOS}-go-${versionSpec}-${fileHash}`; + const linuxVersion = process.env.RUNNER_OS === 'Linux' ? `${process.env.ImageOS}-` : ''; + const primaryKey = `setup-go-${platform}-${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 b3998ea..183df9e 100644 --- a/src/cache-restore.ts +++ b/src/cache-restore.ts @@ -29,8 +29,9 @@ export const restoreCache = async ( ); } - const imageOS = process.env.ImageOS || 'self-hosted'; - const primaryKey = `setup-go-${platform}-${imageOS}-go-${versionSpec}-${fileHash}`; + const linuxVersion = + process.env.RUNNER_OS === 'Linux' ? `${process.env.ImageOS}-` : ''; + const primaryKey = `setup-go-${platform}-${linuxVersion}go-${versionSpec}-${fileHash}`; core.debug(`primary key is ${primaryKey}`); core.saveState(State.CachePrimaryKey, primaryKey);