From a18323f50430a57f9094db3ce508dc1e3a25d4a2 Mon Sep 17 00:00:00 2001 From: Bethany Date: Thu, 29 Feb 2024 09:43:02 -0500 Subject: [PATCH 1/9] add release action --- .../workflows/release-new-action-version.yml | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/release-new-action-version.yml diff --git a/.github/workflows/release-new-action-version.yml b/.github/workflows/release-new-action-version.yml new file mode 100644 index 0000000..0b64c97 --- /dev/null +++ b/.github/workflows/release-new-action-version.yml @@ -0,0 +1,28 @@ +name: Release new action version +on: + release: + types: [released] + workflow_dispatch: + inputs: + TAG_NAME: + description: 'Tag name that the major tag will point to' + required: true + +env: + TAG_NAME: ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }} +permissions: + contents: write + +jobs: + update_tag: + name: Update the major tag to include the ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }} changes + environment: + name: releaseNewActionVersion + runs-on: ubuntu-latest + steps: + - name: Update the ${{ env.TAG_NAME }} tag + id: update-major-tag + uses: actions/publish-action@v0.3.0 + with: + source-tag: ${{ env.TAG_NAME }} + slack-webhook: ${{ secrets.SLACK_WEBHOOK }} From d2c84da363007d814e47d50565ba3794c1a84c56 Mon Sep 17 00:00:00 2001 From: bethanyj28 Date: Thu, 29 Feb 2024 13:11:38 -0500 Subject: [PATCH 2/9] update @actions/cache --- RELEASES.md | 150 +++++++++++++++++++------------------ dist/restore-only/index.js | 5 +- dist/restore/index.js | 5 +- dist/save-only/index.js | 5 +- dist/save/index.js | 5 +- package-lock.json | 16 ++-- package.json | 2 +- 7 files changed, 102 insertions(+), 86 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index e81cb3e..4674c44 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,77 +1,50 @@ # Releases -### 3.0.0 +### 4.0.1 -- Updated minimum runner version support from node 12 -> node 16 +- Updated `isGhes` check -### 3.0.1 +### 4.0.0 -- Added support for caching from GHES 3.5. -- Fixed download issue for files > 2GB during restore. +- Updated minimum runner version support from node 12 -> node 20 -### 3.0.2 +### 3.3.3 -- Added support for dynamic cache size cap on GHES. +- Updates @actions/cache to v3.2.3 to fix accidental mutated path arguments to `getCacheVersion` [actions/toolkit#1378](https://github.com/actions/toolkit/pull/1378) +- Additional audit fixes of npm package(s) -### 3.0.3 +### 3.3.2 -- Fixed avoiding empty cache save when no files are available for caching. ([issue](https://github.com/actions/cache/issues/624)) +- Fixes bug with Azure SDK causing blob downloads to get stuck. -### 3.0.4 +### 3.3.1 -- Fixed tar creation error while trying to create tar with path as `~/` home folder on `ubuntu-latest`. ([issue](https://github.com/actions/cache/issues/689)) +- Reduced segment size to 128MB and segment timeout to 10 minutes to fail fast in case the cache download is stuck. -### 3.0.5 +### 3.3.0 -- Removed error handling by consuming actions/cache 3.0 toolkit, Now cache server error handling will be done by toolkit. ([PR](https://github.com/actions/cache/pull/834)) +- Added option to lookup cache without downloading it. -### 3.0.6 +### 3.2.6 -- Fixed [#809](https://github.com/actions/cache/issues/809) - zstd -d: no such file or directory error -- Fixed [#833](https://github.com/actions/cache/issues/833) - cache doesn't work with github workspace directory +- Fix zstd not being used after zstd version upgrade to 1.5.4 on hosted runners. -### 3.0.7 +### 3.2.5 -- Fixed [#810](https://github.com/actions/cache/issues/810) - download stuck issue. A new timeout is introduced in the download process to abort the download if it gets stuck and doesn't finish within an hour. +- Added fix to prevent from setting MYSYS environment variable globally. -### 3.0.8 +### 3.2.4 -- Fix zstd not working for windows on gnu tar in issues [#888](https://github.com/actions/cache/issues/888) and [#891](https://github.com/actions/cache/issues/891). -- Allowing users to provide a custom timeout as input for aborting download of a cache segment using an environment variable `SEGMENT_DOWNLOAD_TIMEOUT_MINS`. Default is 60 minutes. +- Added option to fail job on cache miss. -### 3.0.9 +### 3.2.3 -- Enhanced the warning message for cache unavailablity in case of GHES. +- Support cross os caching on Windows as an opt-in feature. +- Fix issue with symlink restoration on Windows for cross-os caches. -### 3.0.10 +### 3.2.2 -- Fix a bug with sorting inputs. -- Update definition for restore-keys in README.md - -### 3.0.11 - -- Update toolkit version to 3.0.5 to include `@actions/core@^1.10.0` -- Update `@actions/cache` to use updated `saveState` and `setOutput` functions from `@actions/core@^1.10.0` - -### 3.1.0-beta.1 - -- Update `@actions/cache` on windows to use gnu tar and zstd by default and fallback to bsdtar and zstd if gnu tar is not available. ([issue](https://github.com/actions/cache/issues/984)) - -### 3.1.0-beta.2 - -- Added support for fallback to gzip to restore old caches on windows. - -### 3.1.0-beta.3 - -- Bug fixes for bsdtar fallback if gnutar not available and gzip fallback if cache saved using old cache action on windows. - -### 3.2.0-beta.1 - -- Added two new actions - [restore](restore/action.yml) and [save](save/action.yml) for granular control on cache. - -### 3.2.0 - -- Released the two new actions - [restore](restore/action.yml) and [save](save/action.yml) for granular control on cache +- Reverted the changes made in 3.2.1 to use gnu tar and zstd by default on windows. ### 3.2.1 @@ -79,44 +52,75 @@ - Added support for fallback to gzip to restore old caches on windows. - Added logs for cache version in case of a cache miss. -### 3.2.2 +### 3.2.0 -- Reverted the changes made in 3.2.1 to use gnu tar and zstd by default on windows. +- Released the two new actions - [restore](restore/action.yml) and [save](save/action.yml) for granular control on cache -### 3.2.3 +### 3.2.0-beta.1 -- Support cross os caching on Windows as an opt-in feature. -- Fix issue with symlink restoration on Windows for cross-os caches. +- Added two new actions - [restore](restore/action.yml) and [save](save/action.yml) for granular control on cache. -### 3.2.4 +### 3.1.0-beta.3 -- Added option to fail job on cache miss. +- Bug fixes for bsdtar fallback if gnutar not available and gzip fallback if cache saved using old cache action on windows. -### 3.2.5 +### 3.1.0-beta.2 -- Added fix to prevent from setting MYSYS environment variable globally. +- Added support for fallback to gzip to restore old caches on windows. -### 3.2.6 +### 3.1.0-beta.1 -- Fix zstd not being used after zstd version upgrade to 1.5.4 on hosted runners. +- Update `@actions/cache` on windows to use gnu tar and zstd by default and fallback to bsdtar and zstd if gnu tar is not available. ([issue](https://github.com/actions/cache/issues/984)) -### 3.3.0 +### 3.0.11 -- Added option to lookup cache without downloading it. +- Update toolkit version to 3.0.5 to include `@actions/core@^1.10.0` +- Update `@actions/cache` to use updated `saveState` and `setOutput` functions from `@actions/core@^1.10.0` -### 3.3.1 +### 3.0.10 -- Reduced segment size to 128MB and segment timeout to 10 minutes to fail fast in case the cache download is stuck. +- Fix a bug with sorting inputs. +- Update definition for restore-keys in README.md -### 3.3.2 +### 3.0.9 -- Fixes bug with Azure SDK causing blob downloads to get stuck. +- Enhanced the warning message for cache unavailablity in case of GHES. -### 3.3.3 +### 3.0.8 -- Updates @actions/cache to v3.2.3 to fix accidental mutated path arguments to `getCacheVersion` [actions/toolkit#1378](https://github.com/actions/toolkit/pull/1378) -- Additional audit fixes of npm package(s) +- Fix zstd not working for windows on gnu tar in issues [#888](https://github.com/actions/cache/issues/888) and [#891](https://github.com/actions/cache/issues/891). +- Allowing users to provide a custom timeout as input for aborting download of a cache segment using an environment variable `SEGMENT_DOWNLOAD_TIMEOUT_MINS`. Default is 60 minutes. -### 4.0.0 +### 3.0.7 -- Updated minimum runner version support from node 12 -> node 20 +- Fixed [#810](https://github.com/actions/cache/issues/810) - download stuck issue. A new timeout is introduced in the download process to abort the download if it gets stuck and doesn't finish within an hour. + +### 3.0.6 + +- Fixed [#809](https://github.com/actions/cache/issues/809) - zstd -d: no such file or directory error +- Fixed [#833](https://github.com/actions/cache/issues/833) - cache doesn't work with github workspace directory + +### 3.0.5 + +- Removed error handling by consuming actions/cache 3.0 toolkit, Now cache server error handling will be done by toolkit. ([PR](https://github.com/actions/cache/pull/834)) + +### 3.0.4 + +- Fixed tar creation error while trying to create tar with path as `~/` home folder on `ubuntu-latest`. ([issue](https://github.com/actions/cache/issues/689)) + +### 3.0.3 + +- Fixed avoiding empty cache save when no files are available for caching. ([issue](https://github.com/actions/cache/issues/624)) + +### 3.0.2 + +- Added support for dynamic cache size cap on GHES. + +### 3.0.1 + +- Added support for caching from GHES 3.5. +- Fixed download issue for files > 2GB during restore. + +### 3.0.0 + +- Updated minimum runner version support from node 12 -> node 16 diff --git a/dist/restore-only/index.js b/dist/restore-only/index.js index d1695d2..e8148ee 100644 --- a/dist/restore-only/index.js +++ b/dist/restore-only/index.js @@ -707,7 +707,10 @@ function assertDefined(name, value) { exports.assertDefined = assertDefined; 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 isGheHost = hostname.endsWith('.GHE.COM') || hostname.endsWith('.GHE.LOCALHOST'); + return !isGitHubHost && !isGheHost; } exports.isGhes = isGhes; //# sourceMappingURL=cacheUtils.js.map diff --git a/dist/restore/index.js b/dist/restore/index.js index f32c494..9995844 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -707,7 +707,10 @@ function assertDefined(name, value) { exports.assertDefined = assertDefined; 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 isGheHost = hostname.endsWith('.GHE.COM') || hostname.endsWith('.GHE.LOCALHOST'); + return !isGitHubHost && !isGheHost; } exports.isGhes = isGhes; //# sourceMappingURL=cacheUtils.js.map diff --git a/dist/save-only/index.js b/dist/save-only/index.js index e590b47..f542b2c 100644 --- a/dist/save-only/index.js +++ b/dist/save-only/index.js @@ -707,7 +707,10 @@ function assertDefined(name, value) { exports.assertDefined = assertDefined; 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 isGheHost = hostname.endsWith('.GHE.COM') || hostname.endsWith('.GHE.LOCALHOST'); + return !isGitHubHost && !isGheHost; } exports.isGhes = isGhes; //# sourceMappingURL=cacheUtils.js.map diff --git a/dist/save/index.js b/dist/save/index.js index c27f5f8..f137655 100644 --- a/dist/save/index.js +++ b/dist/save/index.js @@ -707,7 +707,10 @@ function assertDefined(name, value) { exports.assertDefined = assertDefined; 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 isGheHost = hostname.endsWith('.GHE.COM') || hostname.endsWith('.GHE.LOCALHOST'); + return !isGitHubHost && !isGheHost; } exports.isGhes = isGhes; //# sourceMappingURL=cacheUtils.js.map diff --git a/package-lock.json b/package-lock.json index 3a3b441..0780399 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cache", - "version": "4.0.0", + "version": "4.0.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "cache", - "version": "4.0.0", + "version": "4.0.1", "license": "MIT", "dependencies": { "@actions/cache": "^3.2.3", @@ -36,9 +36,9 @@ } }, "node_modules/@actions/cache": { - "version": "3.2.3", - "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.2.3.tgz", - "integrity": "sha512-m8KvmcD+JxSLOfNUXuBF2jL0Lp+co/Fhbf0NTt0M9lz61WnXRdqpIGrOvTRZmKIl+7HaHil6kGE3fkEfrKQCQA==", + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.2.4.tgz", + "integrity": "sha512-RuHnwfcDagtX+37s0ZWy7clbOfnZ7AlDJQ7k/9rzt2W4Gnwde3fa/qjSjVuz4vLcLIpc7fUob27CMrqiWZytYA==", "dependencies": { "@actions/core": "^1.10.0", "@actions/exec": "^1.0.1", @@ -9533,9 +9533,9 @@ }, "dependencies": { "@actions/cache": { - "version": "3.2.3", - "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.2.3.tgz", - "integrity": "sha512-m8KvmcD+JxSLOfNUXuBF2jL0Lp+co/Fhbf0NTt0M9lz61WnXRdqpIGrOvTRZmKIl+7HaHil6kGE3fkEfrKQCQA==", + "version": "3.2.4", + "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.2.4.tgz", + "integrity": "sha512-RuHnwfcDagtX+37s0ZWy7clbOfnZ7AlDJQ7k/9rzt2W4Gnwde3fa/qjSjVuz4vLcLIpc7fUob27CMrqiWZytYA==", "requires": { "@actions/core": "^1.10.0", "@actions/exec": "^1.0.1", diff --git a/package.json b/package.json index 2a4391e..fc29a4d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cache", - "version": "4.0.0", + "version": "4.0.1", "private": true, "description": "Cache dependencies and build outputs", "main": "dist/restore/index.js", From 89c7d86c71006451e399dfcc588eed8e392e0dcf Mon Sep 17 00:00:00 2001 From: bethanyj28 Date: Thu, 29 Feb 2024 13:17:11 -0500 Subject: [PATCH 3/9] licensed cache --- .licenses/npm/@actions/cache.dep.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.licenses/npm/@actions/cache.dep.yml b/.licenses/npm/@actions/cache.dep.yml index ffc3360..b37997f 100644 --- a/.licenses/npm/@actions/cache.dep.yml +++ b/.licenses/npm/@actions/cache.dep.yml @@ -1,6 +1,6 @@ --- name: "@actions/cache" -version: 3.2.3 +version: 3.2.4 type: npm summary: Actions cache lib homepage: https://github.com/actions/toolkit/tree/main/packages/cache From e29dad3e36390db18fc19fb666cb1302f4929002 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Thu, 15 Feb 2024 21:58:25 +0100 Subject: [PATCH 4/9] Fix fail-on-cache-miss not working --- dist/restore-only/index.js | 15 +++++---------- dist/restore/index.js | 15 +++++---------- src/restoreImpl.ts | 15 ++++++--------- 3 files changed, 16 insertions(+), 29 deletions(-) diff --git a/dist/restore-only/index.js b/dist/restore-only/index.js index e8148ee..9a59ac0 100644 --- a/dist/restore-only/index.js +++ b/dist/restore-only/index.js @@ -59392,7 +59392,7 @@ const core = __importStar(__nccwpck_require__(2186)); const constants_1 = __nccwpck_require__(9042); const stateProvider_1 = __nccwpck_require__(1527); const utils = __importStar(__nccwpck_require__(6850)); -function restoreImpl(stateProvider) { +function restoreImpl(stateProvider, earlyExit) { return __awaiter(this, void 0, void 0, function* () { try { if (!utils.isCacheFeatureAvailable()) { @@ -59438,21 +59438,16 @@ function restoreImpl(stateProvider) { } catch (error) { core.setFailed(error.message); + if (earlyExit) { + process.exit(1); + } } }); } exports.restoreImpl = restoreImpl; function run(stateProvider, earlyExit) { return __awaiter(this, void 0, void 0, function* () { - try { - yield restoreImpl(stateProvider); - } - catch (err) { - console.error(err); - if (earlyExit) { - process.exit(1); - } - } + yield restoreImpl(stateProvider, earlyExit); // node will stay alive if any promises are not resolved, // which is a possibility if HTTP requests are dangling // due to retries or timeouts. We know that if we got here diff --git a/dist/restore/index.js b/dist/restore/index.js index 9995844..03a12b5 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -59392,7 +59392,7 @@ const core = __importStar(__nccwpck_require__(2186)); const constants_1 = __nccwpck_require__(9042); const stateProvider_1 = __nccwpck_require__(1527); const utils = __importStar(__nccwpck_require__(6850)); -function restoreImpl(stateProvider) { +function restoreImpl(stateProvider, earlyExit) { return __awaiter(this, void 0, void 0, function* () { try { if (!utils.isCacheFeatureAvailable()) { @@ -59438,21 +59438,16 @@ function restoreImpl(stateProvider) { } catch (error) { core.setFailed(error.message); + if (earlyExit) { + process.exit(1); + } } }); } exports.restoreImpl = restoreImpl; function run(stateProvider, earlyExit) { return __awaiter(this, void 0, void 0, function* () { - try { - yield restoreImpl(stateProvider); - } - catch (err) { - console.error(err); - if (earlyExit) { - process.exit(1); - } - } + yield restoreImpl(stateProvider, earlyExit); // node will stay alive if any promises are not resolved, // which is a possibility if HTTP requests are dangling // due to retries or timeouts. We know that if we got here diff --git a/src/restoreImpl.ts b/src/restoreImpl.ts index 0aff57a..74a366d 100644 --- a/src/restoreImpl.ts +++ b/src/restoreImpl.ts @@ -10,7 +10,8 @@ import { import * as utils from "./utils/actionUtils"; export async function restoreImpl( - stateProvider: IStateProvider + stateProvider: IStateProvider, + earlyExit?: boolean | undefined ): Promise { try { if (!utils.isCacheFeatureAvailable()) { @@ -83,6 +84,9 @@ export async function restoreImpl( return cacheKey; } catch (error: unknown) { core.setFailed((error as Error).message); + if (earlyExit) { + process.exit(1); + } } } @@ -90,14 +94,7 @@ async function run( stateProvider: IStateProvider, earlyExit: boolean | undefined ): Promise { - try { - await restoreImpl(stateProvider); - } catch (err) { - console.error(err); - if (earlyExit) { - process.exit(1); - } - } + await restoreImpl(stateProvider, earlyExit); // node will stay alive if any promises are not resolved, // which is a possibility if HTTP requests are dangling From 3884cace147bdf9307fcc52a277f421af7b30798 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Thu, 15 Feb 2024 22:17:45 +0100 Subject: [PATCH 5/9] Bump version --- RELEASES.md | 4 ++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index 4674c44..e70823e 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,5 +1,9 @@ # Releases +### 4.0.2 + +- Fixed restore `fail-on-cache-miss` not working. + ### 4.0.1 - Updated `isGhes` check diff --git a/package-lock.json b/package-lock.json index 0780399..a232507 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cache", - "version": "4.0.1", + "version": "4.0.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "cache", - "version": "4.0.1", + "version": "4.0.2", "license": "MIT", "dependencies": { "@actions/cache": "^3.2.3", diff --git a/package.json b/package.json index fc29a4d..7468af5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cache", - "version": "4.0.1", + "version": "4.0.2", "private": true, "description": "Cache dependencies and build outputs", "main": "dist/restore/index.js", From 8a55f839aa4b4578e47bdc8a52828637cbb9a454 Mon Sep 17 00:00:00 2001 From: Marc Mueller <30130371+cdce8p@users.noreply.github.com> Date: Tue, 19 Mar 2024 09:28:12 +0100 Subject: [PATCH 6/9] Add test case for process exit Co-authored-by: Bethany --- __tests__/restoreImpl.test.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/__tests__/restoreImpl.test.ts b/__tests__/restoreImpl.test.ts index 8bab894..16f5f72 100644 --- a/__tests__/restoreImpl.test.ts +++ b/__tests__/restoreImpl.test.ts @@ -449,3 +449,19 @@ test("restore with lookup-only set", async () => { ); expect(failedMock).toHaveBeenCalledTimes(0); }); + +test("restore failure with earlyExit should call process exit", async () => { + testUtils.setInput(Inputs.Path, "node_modules"); + const failedMock = jest.spyOn(core, "setFailed"); + const restoreCacheMock = jest.spyOn(cache, "restoreCache"); + const processExitMock = jest.spyOn(process, "exit").mockImplementation(); + + // call restoreImpl with `earlyExit` set to true + await restoreImpl(new StateProvider(), true); + + expect(restoreCacheMock).toHaveBeenCalledTimes(0); + expect(failedMock).toHaveBeenCalledWith( + "Input required and not supplied: key" + ); + expect(processExitMock).toHaveBeenCalledWith(1); +}); From 4a28cbc0544512425977dda4ce81a9b6f0f34ad9 Mon Sep 17 00:00:00 2001 From: "P. Ottlinger" Date: Mon, 29 Jul 2024 22:07:30 +0200 Subject: [PATCH 7/9] Update README.md and use v4 of checkout action (#1437) Update examples to use latest available checkout action v4. --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index d1d2aef..3da1ae0 100644 --- a/README.md +++ b/README.md @@ -91,7 +91,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Cache Primes id: cache-primes @@ -122,7 +122,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Restore cached Primes id: cache-primes-restore @@ -229,7 +229,7 @@ Example: ```yaml steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: actions/cache@v4 id: cache @@ -259,7 +259,7 @@ jobs: build-linux: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Cache Primes id: cache-primes @@ -286,7 +286,7 @@ jobs: build-windows: runs-on: windows-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Cache Primes id: cache-primes From e47d9f9ec8be3ac771b0b03c8e50f86e1c2fdea8 Mon Sep 17 00:00:00 2001 From: "Oleg A." Date: Wed, 31 Jul 2024 19:52:21 +0300 Subject: [PATCH 8/9] Explicit use bash for Windows (#1377) Co-authored-by: Josh Gross --- examples.md | 1 + 1 file changed, 1 insertion(+) diff --git a/examples.md b/examples.md index 1bcde91..2a49996 100644 --- a/examples.md +++ b/examples.md @@ -513,6 +513,7 @@ jobs: ```yaml - name: Get pip cache dir id: pip-cache + shell: bash run: | echo "dir=$(pip cache dir)" >> $GITHUB_OUTPUT From 40c3b67b2955d93d83b27ed164edd0756bc24049 Mon Sep 17 00:00:00 2001 From: r4mimu <52129983+fchimpan@users.noreply.github.com> Date: Thu, 1 Aug 2024 01:56:48 +0900 Subject: [PATCH 9/9] Fix cache-hit output when cache missed (#1404) * fix: cache-hit output * fix: Output chache hit timing * fix: Output chache hit timing --------- Co-authored-by: Josh Gross --- __tests__/restore.test.ts | 2 +- __tests__/restoreOnly.test.ts | 3 ++- dist/restore-only/index.js | 1 + dist/restore/index.js | 1 + src/restoreImpl.ts | 2 +- 5 files changed, 6 insertions(+), 3 deletions(-) diff --git a/__tests__/restore.test.ts b/__tests__/restore.test.ts index 250f7ef..9b066eb 100644 --- a/__tests__/restore.test.ts +++ b/__tests__/restore.test.ts @@ -260,7 +260,7 @@ test("Fail restore when fail on cache miss is enabled and primary + restore keys ); expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key); - expect(setCacheHitOutputMock).toHaveBeenCalledTimes(0); + expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1); expect(failedMock).toHaveBeenCalledWith( `Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${key}` diff --git a/__tests__/restoreOnly.test.ts b/__tests__/restoreOnly.test.ts index 81e5bca..840307d 100644 --- a/__tests__/restoreOnly.test.ts +++ b/__tests__/restoreOnly.test.ts @@ -86,7 +86,8 @@ test("restore with no cache found", async () => { ); expect(outputMock).toHaveBeenCalledWith("cache-primary-key", key); - expect(outputMock).toHaveBeenCalledTimes(1); + expect(outputMock).toHaveBeenCalledWith("cache-hit", "false"); + expect(outputMock).toHaveBeenCalledTimes(2); expect(failedMock).toHaveBeenCalledTimes(0); expect(infoMock).toHaveBeenCalledWith( diff --git a/dist/restore-only/index.js b/dist/restore-only/index.js index 9a59ac0..d2f3631 100644 --- a/dist/restore-only/index.js +++ b/dist/restore-only/index.js @@ -59415,6 +59415,7 @@ function restoreImpl(stateProvider, earlyExit) { const lookupOnly = utils.getInputAsBool(constants_1.Inputs.LookupOnly); const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys, { lookupOnly: lookupOnly }, enableCrossOsArchive); if (!cacheKey) { + core.setOutput(constants_1.Outputs.CacheHit, false.toString()); if (failOnCacheMiss) { throw new Error(`Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${primaryKey}`); } diff --git a/dist/restore/index.js b/dist/restore/index.js index 03a12b5..842eaa6 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -59415,6 +59415,7 @@ function restoreImpl(stateProvider, earlyExit) { const lookupOnly = utils.getInputAsBool(constants_1.Inputs.LookupOnly); const cacheKey = yield cache.restoreCache(cachePaths, primaryKey, restoreKeys, { lookupOnly: lookupOnly }, enableCrossOsArchive); if (!cacheKey) { + core.setOutput(constants_1.Outputs.CacheHit, false.toString()); if (failOnCacheMiss) { throw new Error(`Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${primaryKey}`); } diff --git a/src/restoreImpl.ts b/src/restoreImpl.ts index 74a366d..bb302ac 100644 --- a/src/restoreImpl.ts +++ b/src/restoreImpl.ts @@ -51,6 +51,7 @@ export async function restoreImpl( ); if (!cacheKey) { + core.setOutput(Outputs.CacheHit, false.toString()); if (failOnCacheMiss) { throw new Error( `Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: ${primaryKey}` @@ -62,7 +63,6 @@ export async function restoreImpl( ...restoreKeys ].join(", ")}` ); - return; }