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 1/5] 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 9ad3784..d4b4aa8 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 183df9e..18d930b 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); From 49582f64768fe5808736e4f6d4a39b55b1d0ee52 Mon Sep 17 00:00:00 2001 From: Joel Ambass Date: Wed, 11 Sep 2024 10:43:06 +0200 Subject: [PATCH 2/5] Add workflow file for publishing releases to immutable action package This workflow file publishes new action releases to the immutable action package of the same name as this repo. This is part of the Immutable Actions project which is not yet fully released to the public. First party actions like this one are part of our initial testing of this feature. --- .../workflows/publish-immutable-actions.yml | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/publish-immutable-actions.yml diff --git a/.github/workflows/publish-immutable-actions.yml b/.github/workflows/publish-immutable-actions.yml new file mode 100644 index 0000000..1e02a3a --- /dev/null +++ b/.github/workflows/publish-immutable-actions.yml @@ -0,0 +1,22 @@ +name: 'Publish Immutable Action Version' + +on: + release: + types: [created] + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + packages: write + + steps: + - name: Checking out + uses: actions/checkout@v4 + - name: Publish + id: publish + uses: actions/publish-immutable-action@0.0.1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} From e09f57f6a9dc1a4c326dfc2aaf66b49f6c56f9f8 Mon Sep 17 00:00:00 2001 From: Joel Ambass Date: Mon, 16 Sep 2024 17:20:25 +0200 Subject: [PATCH 3/5] Upgrade IA Publish --- .github/workflows/publish-immutable-actions.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish-immutable-actions.yml b/.github/workflows/publish-immutable-actions.yml index 1e02a3a..87c0207 100644 --- a/.github/workflows/publish-immutable-actions.yml +++ b/.github/workflows/publish-immutable-actions.yml @@ -2,7 +2,7 @@ name: 'Publish Immutable Action Version' on: release: - types: [created] + types: [published] jobs: publish: @@ -17,6 +17,4 @@ jobs: uses: actions/checkout@v4 - name: Publish id: publish - uses: actions/publish-immutable-action@0.0.1 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} + uses: actions/publish-immutable-action@0.0.3 From 941977282cd715ac8e0b3adc8555bef6dc794b7e Mon Sep 17 00:00:00 2001 From: John Wesley Walker III <81404201+jww3@users.noreply.github.com> Date: Mon, 21 Oct 2024 18:56:08 +0200 Subject: [PATCH 4/5] Revise `isGhes` logic (#511) * Revise `isGhes` logic * ran `npm run format` * added unit test * tweaked unit test * ran `npm run format` --- __tests__/cache-utils.test.ts | 38 +++++++++++++++++++++++++++++++++++ dist/cache-save/index.js | 6 +++++- dist/setup/index.js | 6 +++++- src/cache-utils.ts | 8 +++++++- 4 files changed, 55 insertions(+), 3 deletions(-) diff --git a/__tests__/cache-utils.test.ts b/__tests__/cache-utils.test.ts index 695c561..c848c37 100644 --- a/__tests__/cache-utils.test.ts +++ b/__tests__/cache-utils.test.ts @@ -209,3 +209,41 @@ describe('isCacheFeatureAvailable', () => { expect(warningSpy).toHaveBeenCalledWith(warningMessage); }); }); + +describe('isGhes', () => { + const pristineEnv = process.env; + + beforeEach(() => { + jest.resetModules(); + process.env = {...pristineEnv}; + }); + + afterAll(() => { + process.env = pristineEnv; + }); + + it('returns false when the GITHUB_SERVER_URL environment variable is not defined', async () => { + delete process.env['GITHUB_SERVER_URL']; + expect(cacheUtils.isGhes()).toBeFalsy(); + }); + + it('returns false when the GITHUB_SERVER_URL environment variable is set to github.com', async () => { + process.env['GITHUB_SERVER_URL'] = 'https://github.com'; + expect(cacheUtils.isGhes()).toBeFalsy(); + }); + + it('returns false when the GITHUB_SERVER_URL environment variable is set to a GitHub Enterprise Cloud-style URL', async () => { + process.env['GITHUB_SERVER_URL'] = 'https://contoso.ghe.com'; + expect(cacheUtils.isGhes()).toBeFalsy(); + }); + + it('returns false when the GITHUB_SERVER_URL environment variable has a .localhost suffix', async () => { + process.env['GITHUB_SERVER_URL'] = 'https://mock-github.localhost'; + expect(cacheUtils.isGhes()).toBeFalsy(); + }); + + it('returns true when the GITHUB_SERVER_URL environment variable is set to some other URL', async () => { + process.env['GITHUB_SERVER_URL'] = 'https://src.onpremise.fabrikam.com'; + expect(cacheUtils.isGhes()).toBeTruthy(); + }); +}); diff --git a/dist/cache-save/index.js b/dist/cache-save/index.js index 595ce84..1936c6b 100644 --- a/dist/cache-save/index.js +++ b/dist/cache-save/index.js @@ -81175,7 +81175,11 @@ const getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, exports.getCacheDirectoryPath = getCacheDirectoryPath; function isGhes() { const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); - return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; + const hostname = ghUrl.hostname.trimEnd().toUpperCase(); + const isGitHubHost = hostname === 'GITHUB.COM'; + const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM'); + const isLocalHost = hostname.endsWith('.LOCALHOST'); + return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost; } exports.isGhes = isGhes; function isCacheFeatureAvailable() { diff --git a/dist/setup/index.js b/dist/setup/index.js index d4b4aa8..f21396a 100644 --- a/dist/setup/index.js +++ b/dist/setup/index.js @@ -88165,7 +88165,11 @@ const getCacheDirectoryPath = (packageManagerInfo) => __awaiter(void 0, void 0, exports.getCacheDirectoryPath = getCacheDirectoryPath; function isGhes() { const ghUrl = new URL(process.env['GITHUB_SERVER_URL'] || 'https://github.com'); - return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; + const hostname = ghUrl.hostname.trimEnd().toUpperCase(); + const isGitHubHost = hostname === 'GITHUB.COM'; + const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM'); + const isLocalHost = hostname.endsWith('.LOCALHOST'); + return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost; } exports.isGhes = isGhes; function isCacheFeatureAvailable() { diff --git a/src/cache-utils.ts b/src/cache-utils.ts index 545c97a..41f8b32 100644 --- a/src/cache-utils.ts +++ b/src/cache-utils.ts @@ -63,7 +63,13 @@ export function isGhes(): boolean { const ghUrl = new URL( process.env['GITHUB_SERVER_URL'] || 'https://github.com' ); - return ghUrl.hostname.toUpperCase() !== 'GITHUB.COM'; + + const hostname = ghUrl.hostname.trimEnd().toUpperCase(); + const isGitHubHost = hostname === 'GITHUB.COM'; + const isGitHubEnterpriseCloudHost = hostname.endsWith('.GHE.COM'); + const isLocalHost = hostname.endsWith('.LOCALHOST'); + + return !isGitHubHost && !isGitHubEnterpriseCloudHost && !isLocalHost; } export function isCacheFeatureAvailable(): boolean { From 41dfa10bad2bb2ae585af6ee5bb4d7d973ad74ed Mon Sep 17 00:00:00 2001 From: Priya Gupta <147705955+priyagupta108@users.noreply.github.com> Date: Thu, 24 Oct 2024 09:09:31 +0530 Subject: [PATCH 5/5] Enhance workflows and Upgrade micromatch Dependency (#510) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update workflows and bump dependencies * Add test for Go 1.22 and 1.23 * Update Go versions in local-cache setup and include macos-latest with ARM64 architecture --- .../workflows/release-new-action-version.yml | 2 +- .github/workflows/versions.yml | 51 ++++++++++++------- package-lock.json | 8 +-- 3 files changed, 38 insertions(+), 23 deletions(-) diff --git a/.github/workflows/release-new-action-version.yml b/.github/workflows/release-new-action-version.yml index d8171ef..7e5de34 100644 --- a/.github/workflows/release-new-action-version.yml +++ b/.github/workflows/release-new-action-version.yml @@ -22,7 +22,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Update the ${{ env.TAG_NAME }} tag - uses: actions/publish-action@v0.2.2 + uses: actions/publish-action@v0.3.0 with: source-tag: ${{ env.TAG_NAME }} slack-webhook: ${{ secrets.SLACK_WEBHOOK }} diff --git a/.github/workflows/versions.yml b/.github/workflows/versions.yml index 76fcead..8c718c5 100644 --- a/.github/workflows/versions.yml +++ b/.github/workflows/versions.yml @@ -18,7 +18,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest, macos-latest] + os: [ubuntu-latest, windows-latest, macos-latest, macos-13] steps: - uses: actions/checkout@v4 - name: Setup Go Stable @@ -33,7 +33,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest, macos-latest] + os: [ubuntu-latest, windows-latest, macos-latest, macos-13] steps: - uses: actions/checkout@v4 - name: Setup Go oldStable @@ -48,12 +48,14 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest, macos-latest] + os: [ubuntu-latest, windows-latest, macos-latest, macos-13] version: [stable, oldstable] architecture: [x64, x32] exclude: - os: macos-latest architecture: x32 + - os: macos-13 + architecture: x32 steps: - uses: actions/checkout@v4 - name: Setup Go ${{ matrix.version }} ${{ matrix.architecture }} @@ -70,8 +72,14 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-latest, windows-latest, ubuntu-latest] - go: [1.20.14, 1.21.10, 1.22.3] + os: [macos-latest, windows-latest, ubuntu-latest, macos-13] + go: [1.21.13, 1.22.8, 1.23.2] + include: + - os: windows-latest + go: 1.20.14 + exclude: + - os: windows-latest + go: 1.23.2 steps: - name: Checkout uses: actions/checkout@v4 @@ -90,8 +98,8 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - go-version: [1.20.14, 1.21] + os: [ubuntu-latest, windows-latest, macos-latest, macos-13] + go-version: ['1.20', '1.21', '1.22', '1.23'] steps: - uses: actions/checkout@v4 - name: Setup Go and check latest @@ -107,7 +115,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest, macos-latest] + os: [ubuntu-latest, windows-latest, macos-latest, macos-13] steps: - uses: actions/checkout@v4 - name: Setup Go and check latest @@ -123,7 +131,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest, macos-latest] + os: [ubuntu-latest, windows-latest, macos-latest, macos-13] steps: - uses: actions/checkout@v4 - name: Setup Go and check latest @@ -135,13 +143,12 @@ jobs: shell: bash setup-versions-from-manifest: - name: Setup ${{ matrix.go }} ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - os: [macos-latest, windows-latest, ubuntu-latest] - go: [1.20.14, 1.21.10, 1.22.3] + os: [macos-latest, windows-latest, ubuntu-latest, macos-13] + go: [1.20.14, 1.21.10, 1.22.8, 1.23.2] steps: - name: Checkout uses: actions/checkout@v4 @@ -156,13 +163,12 @@ jobs: shell: bash setup-versions-from-dist: - name: Setup ${{ matrix.go }} ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: - os: [macos-latest, windows-latest, ubuntu-latest] - go: [1.20.14, 1.21] + os: [windows-latest, ubuntu-latest, macos-13] + go: [1.11.12] steps: - name: Checkout uses: actions/checkout@v4 @@ -181,14 +187,23 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - go-version: [1.20.14, 1.21] + os: [ubuntu-latest, windows-latest, macos-latest, macos-13] + go-version: [1.20.14, 1.21, 1.22, 1.23] + include: + - os: macos-latest + architecture: arm64 + - os: ubuntu-latest + architecture: x64 + - os: windows-latest + architecture: x64 + - os: macos-13 + architecture: x64 steps: - uses: actions/checkout@v4 - name: Setup Go and check latest uses: ./ with: go-version: ${{ matrix.go-version }} - architecture: x64 + architecture: ${{ matrix.architecture }} - name: Verify Go run: go version diff --git a/package-lock.json b/package-lock.json index 5cb8fbf..c51f97c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4559,12 +4559,12 @@ } }, "node_modules/micromatch": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", - "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", + "integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==", "dev": true, "dependencies": { - "braces": "^3.0.2", + "braces": "^3.0.3", "picomatch": "^2.3.1" }, "engines": {