From 92e01f4797c1062d1c83e7070df2d96069d05b8f Mon Sep 17 00:00:00 2001 From: Vipul Date: Wed, 14 Sep 2022 09:27:02 +0000 Subject: [PATCH 01/21] Add anuragc617 to assignees --- .github/auto_assign.yml | 1 + .github/workflows/auto-assign-issues.yml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/auto_assign.yml b/.github/auto_assign.yml index bf91479..6f0bf79 100644 --- a/.github/auto_assign.yml +++ b/.github/auto_assign.yml @@ -6,6 +6,7 @@ addAssignees: false # A list of reviewers to be added to pull requests (GitHub user name) reviewers: + - anuragc617 - pallavx - pdotl - phantsure diff --git a/.github/workflows/auto-assign-issues.yml b/.github/workflows/auto-assign-issues.yml index ffd5926..32c72f8 100644 --- a/.github/workflows/auto-assign-issues.yml +++ b/.github/workflows/auto-assign-issues.yml @@ -11,5 +11,5 @@ jobs: - name: 'Auto-assign issue' uses: pozil/auto-assign-issue@v1.4.0 with: - assignees: pallavx,pdotl,phantsure,kotewar,tiwarishub,aparna-ravindra,vsvipul,bishal-pdmsft + assignees: anuragc617,pallavx,pdotl,phantsure,kotewar,tiwarishub,aparna-ravindra,vsvipul,bishal-pdmsft numOfAssignee: 1 From 1a78ace1311f934d8a2b1bc050fa0c40b7207833 Mon Sep 17 00:00:00 2001 From: Shubham Tiwari <64764738+tiwarishub@users.noreply.github.com> Date: Tue, 20 Sep 2022 10:47:27 +0530 Subject: [PATCH 02/21] Updated the GHES warning message (#925) * changed the error message * format * review comment --- __tests__/actionUtils.test.ts | 4 ++-- dist/restore/index.js | 3 ++- dist/save/index.js | 3 ++- src/utils/actionUtils.ts | 3 ++- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/__tests__/actionUtils.test.ts b/__tests__/actionUtils.test.ts index 19425f5..d36ac58 100644 --- a/__tests__/actionUtils.test.ts +++ b/__tests__/actionUtils.test.ts @@ -277,8 +277,8 @@ test("isCacheFeatureAvailable for ac enabled", () => { test("isCacheFeatureAvailable for ac disabled on GHES", () => { jest.spyOn(cache, "isFeatureAvailable").mockImplementation(() => false); - const message = - "Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not."; + const message = `Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not. +Otherwise please upgrade to GHES version >= 3.5 and If you are also using Github Connect, please unretire the actions/cache namespace before upgrade (see https://docs.github.com/en/enterprise-server@3.5/admin/github-actions/managing-access-to-actions-from-githubcom/enabling-automatic-access-to-githubcom-actions-using-github-connect#automatic-retirement-of-namespaces-for-actions-accessed-on-githubcom)`; const infoMock = jest.spyOn(core, "info"); try { diff --git a/dist/restore/index.js b/dist/restore/index.js index 25bd663..c8c999e 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -38452,7 +38452,8 @@ exports.getInputAsInt = getInputAsInt; function isCacheFeatureAvailable() { if (!cache.isFeatureAvailable()) { if (isGhes()) { - logWarning("Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not."); + logWarning(`Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not. +Otherwise please upgrade to GHES version >= 3.5 and If you are also using Github Connect, please unretire the actions/cache namespace before upgrade (see https://docs.github.com/en/enterprise-server@3.5/admin/github-actions/managing-access-to-actions-from-githubcom/enabling-automatic-access-to-githubcom-actions-using-github-connect#automatic-retirement-of-namespaces-for-actions-accessed-on-githubcom)`); } else { logWarning("An internal error has occurred in cache backend. Please check https://www.githubstatus.com/ for any ongoing issue in actions."); diff --git a/dist/save/index.js b/dist/save/index.js index c8435da..0fbc6d4 100644 --- a/dist/save/index.js +++ b/dist/save/index.js @@ -38452,7 +38452,8 @@ exports.getInputAsInt = getInputAsInt; function isCacheFeatureAvailable() { if (!cache.isFeatureAvailable()) { if (isGhes()) { - logWarning("Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not."); + logWarning(`Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not. +Otherwise please upgrade to GHES version >= 3.5 and If you are also using Github Connect, please unretire the actions/cache namespace before upgrade (see https://docs.github.com/en/enterprise-server@3.5/admin/github-actions/managing-access-to-actions-from-githubcom/enabling-automatic-access-to-githubcom-actions-using-github-connect#automatic-retirement-of-namespaces-for-actions-accessed-on-githubcom)`); } else { logWarning("An internal error has occurred in cache backend. Please check https://www.githubstatus.com/ for any ongoing issue in actions."); diff --git a/src/utils/actionUtils.ts b/src/utils/actionUtils.ts index 46c5ec1..034df19 100644 --- a/src/utils/actionUtils.ts +++ b/src/utils/actionUtils.ts @@ -81,7 +81,8 @@ export function isCacheFeatureAvailable(): boolean { if (!cache.isFeatureAvailable()) { if (isGhes()) { logWarning( - "Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not." + `Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not. +Otherwise please upgrade to GHES version >= 3.5 and If you are also using Github Connect, please unretire the actions/cache namespace before upgrade (see https://docs.github.com/en/enterprise-server@3.5/admin/github-actions/managing-access-to-actions-from-githubcom/enabling-automatic-access-to-githubcom-actions-using-github-connect#automatic-retirement-of-namespaces-for-actions-accessed-on-githubcom)` ); } else { logWarning( From 3238536a48bfc94aa1be336fef0d93ad1725d57e Mon Sep 17 00:00:00 2001 From: ELHoussineT Date: Thu, 22 Sep 2022 10:50:41 +0200 Subject: [PATCH 03/21] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 252d03b..5ba3924 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ If you are using this inside a container, a POSIX-compliant `tar` needs to be in * `path` - A list of files, directories, and wildcard patterns to cache and restore. See [`@actions/glob`](https://github.com/actions/toolkit/tree/main/packages/glob) for supported patterns. * `key` - An explicit key for restoring and saving the cache * `restore-keys` - An ordered list of keys to use for restoring stale cache if no cache hit occurred for key. Note -`cache-hit` returns false in this case. +`cache-hit` returns false in this case. When a key doesn't match directly, the action searches for keys prefixed with the restore key. #### Environment Variables * `SEGMENT_DOWNLOAD_TIMEOUT_MIN` - Segment download timeout (in minutes, default `60`) to abort download of the segment if not completed in the defined number of minutes. [Read more](#cache-segment-restore-timeout) From 12681847c623a9274356751fdf0a63576ff3f846 Mon Sep 17 00:00:00 2001 From: Aparna Ravindra <82894348+aparna-ravindra@users.noreply.github.com> Date: Fri, 23 Sep 2022 17:15:41 +0530 Subject: [PATCH 04/21] Update README.md (#936) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 252d03b..b0e5549 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This action allows caching dependencies and build outputs to improve workflow ex ## Documentation -See ["Caching dependencies to speed up workflows"](https://help.github.com/github/automating-your-workflow-with-github-actions/caching-dependencies-to-speed-up-workflows). +See ["Caching dependencies to speed up workflows"](https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows). ## What's New ### v3 From 0ff05979343fa0bc49c99a4fea5dae9f0964e94f Mon Sep 17 00:00:00 2001 From: ysato <56924527+ysato@users.noreply.github.com> Date: Thu, 29 Sep 2022 13:57:49 +0900 Subject: [PATCH 05/21] Update examples.md (#920) --- examples.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples.md b/examples.md index fca1f8c..5a38585 100644 --- a/examples.md +++ b/examples.md @@ -332,7 +332,7 @@ If using `npm config` to retrieve the cache directory, ensure you run [actions/s - name: restore lerna uses: actions/cache@v3 with: - path: **/node_modules + path: '**/node_modules' key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock') }} ``` From ac8075791e805656e71b4ba23325ace9e3421120 Mon Sep 17 00:00:00 2001 From: Shubham Tiwari <64764738+tiwarishub@users.noreply.github.com> Date: Fri, 30 Sep 2022 10:47:16 +0530 Subject: [PATCH 06/21] Actions/cache release 3.0.9 (#930) * Release * Update RELEASES.md Co-authored-by: Lovepreet Singh --- RELEASES.md | 5 ++++- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index cf12dab..5090b3f 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -28,4 +28,7 @@ ### 3.0.8 - 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_MIN`. Default is 60 minutes. \ No newline at end of file +- Allowing users to provide a custom timeout as input for aborting download of a cache segment using an environment variable `SEGMENT_DOWNLOAD_TIMEOUT_MIN`. Default is 60 minutes. + +### 3.0.9 +- Enhanced the warning message for cache unavailablity in case of GHES. diff --git a/package-lock.json b/package-lock.json index 479ede1..2c65f05 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cache", - "version": "3.0.8", + "version": "3.0.9", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "cache", - "version": "3.0.8", + "version": "3.0.9", "license": "MIT", "dependencies": { "@actions/cache": "^3.0.4", diff --git a/package.json b/package.json index 53be697..dd91655 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cache", - "version": "3.0.8", + "version": "3.0.9", "private": true, "description": "Cache dependencies and build outputs", "main": "dist/restore/index.js", From 68d96986b532923ef04d50de9cbaef6241839806 Mon Sep 17 00:00:00 2001 From: Vipul Date: Mon, 3 Oct 2022 06:39:10 +0000 Subject: [PATCH 07/21] Remove sort logic from inputs --- __tests__/actionUtils.test.ts | 23 +++-------------------- __tests__/restore.test.ts | 2 +- dist/restore/index.js | 3 +-- dist/save/index.js | 3 +-- src/utils/actionUtils.ts | 3 +-- 5 files changed, 7 insertions(+), 27 deletions(-) diff --git a/__tests__/actionUtils.test.ts b/__tests__/actionUtils.test.ts index d36ac58..c8e579a 100644 --- a/__tests__/actionUtils.test.ts +++ b/__tests__/actionUtils.test.ts @@ -215,23 +215,6 @@ test("getInputAsArray handles empty lines correctly", () => { expect(actionUtils.getInputAsArray("foo")).toEqual(["bar", "baz"]); }); -test("getInputAsArray sorts files correctly", () => { - testUtils.setInput( - "foo", - "bar\n!baz\nwaldo\nqux\nquux\ncorge\ngrault\ngarply" - ); - expect(actionUtils.getInputAsArray("foo")).toEqual([ - "!baz", - "bar", - "corge", - "garply", - "grault", - "quux", - "qux", - "waldo" - ]); -}); - test("getInputAsArray removes spaces after ! at the beginning", () => { testUtils.setInput( "foo", @@ -240,11 +223,11 @@ test("getInputAsArray removes spaces after ! at the beginning", () => { expect(actionUtils.getInputAsArray("foo")).toEqual([ "!bar", "!baz", - "!quux", "!qux", - "!waldo", + "!quux", "corge", - "grault! garply" + "grault! garply", + "!waldo" ]); }); diff --git a/__tests__/restore.test.ts b/__tests__/restore.test.ts index 6c02082..e9a505b 100644 --- a/__tests__/restore.test.ts +++ b/__tests__/restore.test.ts @@ -147,7 +147,7 @@ test("restore with no key", async () => { test("restore with too many keys should fail", async () => { const path = "node_modules"; const key = "node-test"; - const restoreKeys = [...Array(20).keys()].map(x => x.toString()).sort(); + const restoreKeys = [...Array(20).keys()].map(x => x.toString()); testUtils.setInputs({ path: path, key, diff --git a/dist/restore/index.js b/dist/restore/index.js index c8c999e..0dd8a25 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -38437,8 +38437,7 @@ function getInputAsArray(name, options) { .getInput(name, options) .split("\n") .map(s => s.replace(/^!\s+/, "!").trim()) - .filter(x => x !== "") - .sort(); + .filter(x => x !== ""); } exports.getInputAsArray = getInputAsArray; function getInputAsInt(name, options) { diff --git a/dist/save/index.js b/dist/save/index.js index 0fbc6d4..34e4c7a 100644 --- a/dist/save/index.js +++ b/dist/save/index.js @@ -38437,8 +38437,7 @@ function getInputAsArray(name, options) { .getInput(name, options) .split("\n") .map(s => s.replace(/^!\s+/, "!").trim()) - .filter(x => x !== "") - .sort(); + .filter(x => x !== ""); } exports.getInputAsArray = getInputAsArray; function getInputAsInt(name, options) { diff --git a/src/utils/actionUtils.ts b/src/utils/actionUtils.ts index 034df19..dacd3a6 100644 --- a/src/utils/actionUtils.ts +++ b/src/utils/actionUtils.ts @@ -62,8 +62,7 @@ export function getInputAsArray( .getInput(name, options) .split("\n") .map(s => s.replace(/^!\s+/, "!").trim()) - .filter(x => x !== "") - .sort(); + .filter(x => x !== ""); } export function getInputAsInt( From 98044e486f42920b65b6a2c2d0031e6e19dd0879 Mon Sep 17 00:00:00 2001 From: ELHoussineT Date: Mon, 3 Oct 2022 10:15:54 +0200 Subject: [PATCH 08/21] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5ba3924..b53321f 100644 --- a/README.md +++ b/README.md @@ -34,8 +34,8 @@ If you are using this inside a container, a POSIX-compliant `tar` needs to be in * `path` - A list of files, directories, and wildcard patterns to cache and restore. See [`@actions/glob`](https://github.com/actions/toolkit/tree/main/packages/glob) for supported patterns. * `key` - An explicit key for restoring and saving the cache -* `restore-keys` - An ordered list of keys to use for restoring stale cache if no cache hit occurred for key. Note -`cache-hit` returns false in this case. When a key doesn't match directly, the action searches for keys prefixed with the restore key. +* `restore-keys` - An ordered list of prefix-matched keys to use for restoring stale cache if no cache hit occurred for key. Note +`cache-hit` returns false in this case. #### Environment Variables * `SEGMENT_DOWNLOAD_TIMEOUT_MIN` - Segment download timeout (in minutes, default `60`) to abort download of the segment if not completed in the defined number of minutes. [Read more](#cache-segment-restore-timeout) From 50a4a3a126349b0c48e6b4492e413ae35e431896 Mon Sep 17 00:00:00 2001 From: Vipul Date: Tue, 4 Oct 2022 06:47:17 +0000 Subject: [PATCH 09/21] Create new release 3.0.10 --- 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 5090b3f..85ba1b5 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -32,3 +32,7 @@ ### 3.0.9 - Enhanced the warning message for cache unavailablity in case of GHES. + +### 3.0.10 +- Fix a bug with sorting inputs. +- Update definition for restore-keys in README.md diff --git a/package-lock.json b/package-lock.json index 2c65f05..5db399f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cache", - "version": "3.0.9", + "version": "3.0.10", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "cache", - "version": "3.0.9", + "version": "3.0.10", "license": "MIT", "dependencies": { "@actions/cache": "^3.0.4", diff --git a/package.json b/package.json index dd91655..c5183e2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cache", - "version": "3.0.9", + "version": "3.0.10", "private": true, "description": "Cache dependencies and build outputs", "main": "dist/restore/index.js", From 862fc14188ec4c465f9396a35945acdbed89df66 Mon Sep 17 00:00:00 2001 From: Sampark Sharma Date: Tue, 4 Oct 2022 15:10:37 +0530 Subject: [PATCH 10/21] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3f7322e..408fd2e 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ jobs: run: /primes.sh -d prime-numbers ``` -> Note: You must use the `cache` action in your workflow before you need to use the files that might be restored from the cache. If the provided `key` doesn't match an existing cache, a new cache is automatically created if the job completes successfully. +> Note: You must use the `cache` action in your workflow before you need to use the files that might be restored from the cache. If the provided `key` matches an existing cache, a new cache is not created and if the provided `key` doesn't match an existing cache, a new cache is automatically created provided the job completes successfully. ## Implementation Examples From b9c8bfe4426d1b96548309ee742254ebf1a4f21c Mon Sep 17 00:00:00 2001 From: Francesco Renzi Date: Wed, 5 Oct 2022 17:50:52 +0100 Subject: [PATCH 11/21] Update @actions/core to 1.10.0 --- dist/restore/index.js | 57 +++++++++++++++++++++++++++---------------- dist/save/index.js | 57 +++++++++++++++++++++++++++---------------- package-lock.json | 14 +++++------ package.json | 4 +-- 4 files changed, 81 insertions(+), 51 deletions(-) diff --git a/dist/restore/index.js b/dist/restore/index.js index 0dd8a25..a840efa 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -2954,13 +2954,14 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.issueCommand = void 0; +exports.prepareKeyValueMessage = exports.issueFileCommand = void 0; // We use any as a valid input type /* eslint-disable @typescript-eslint/no-explicit-any */ const fs = __importStar(__webpack_require__(747)); const os = __importStar(__webpack_require__(87)); +const uuid_1 = __webpack_require__(25); const utils_1 = __webpack_require__(82); -function issueCommand(command, message) { +function issueFileCommand(command, message) { const filePath = process.env[`GITHUB_${command}`]; if (!filePath) { throw new Error(`Unable to find environment variable for file command ${command}`); @@ -2972,7 +2973,22 @@ function issueCommand(command, message) { encoding: 'utf8' }); } -exports.issueCommand = issueCommand; +exports.issueFileCommand = issueFileCommand; +function prepareKeyValueMessage(key, value) { + const delimiter = `ghadelimiter_${uuid_1.v4()}`; + const convertedValue = utils_1.toCommandValue(value); + // These should realistically never happen, but just in case someone finds a + // way to exploit uuid generation let's not allow keys or values that contain + // the delimiter. + if (key.includes(delimiter)) { + throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`); + } + if (convertedValue.includes(delimiter)) { + throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`); + } + return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`; +} +exports.prepareKeyValueMessage = prepareKeyValueMessage; //# sourceMappingURL=file-command.js.map /***/ }), @@ -40551,7 +40567,6 @@ const file_command_1 = __webpack_require__(102); const utils_1 = __webpack_require__(82); const os = __importStar(__webpack_require__(87)); const path = __importStar(__webpack_require__(622)); -const uuid_1 = __webpack_require__(25); const oidc_utils_1 = __webpack_require__(742); /** * The code to exit an action @@ -40581,20 +40596,9 @@ function exportVariable(name, val) { process.env[name] = convertedVal; const filePath = process.env['GITHUB_ENV'] || ''; if (filePath) { - const delimiter = `ghadelimiter_${uuid_1.v4()}`; - // These should realistically never happen, but just in case someone finds a way to exploit uuid generation let's not allow keys or values that contain the delimiter. - if (name.includes(delimiter)) { - throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`); - } - if (convertedVal.includes(delimiter)) { - throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`); - } - const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`; - file_command_1.issueCommand('ENV', commandValue); - } - else { - command_1.issueCommand('set-env', { name }, convertedVal); + return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val)); } + command_1.issueCommand('set-env', { name }, convertedVal); } exports.exportVariable = exportVariable; /** @@ -40612,7 +40616,7 @@ exports.setSecret = setSecret; function addPath(inputPath) { const filePath = process.env['GITHUB_PATH'] || ''; if (filePath) { - file_command_1.issueCommand('PATH', inputPath); + file_command_1.issueFileCommand('PATH', inputPath); } else { command_1.issueCommand('add-path', {}, inputPath); @@ -40652,7 +40656,10 @@ function getMultilineInput(name, options) { const inputs = getInput(name, options) .split('\n') .filter(x => x !== ''); - return inputs; + if (options && options.trimWhitespace === false) { + return inputs; + } + return inputs.map(input => input.trim()); } exports.getMultilineInput = getMultilineInput; /** @@ -40685,8 +40692,12 @@ exports.getBooleanInput = getBooleanInput; */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function setOutput(name, value) { + const filePath = process.env['GITHUB_OUTPUT'] || ''; + if (filePath) { + return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value)); + } process.stdout.write(os.EOL); - command_1.issueCommand('set-output', { name }, value); + command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value)); } exports.setOutput = setOutput; /** @@ -40815,7 +40826,11 @@ exports.group = group; */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function saveState(name, value) { - command_1.issueCommand('save-state', { name }, value); + const filePath = process.env['GITHUB_STATE'] || ''; + if (filePath) { + return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value)); + } + command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value)); } exports.saveState = saveState; /** diff --git a/dist/save/index.js b/dist/save/index.js index 34e4c7a..bd9f422 100644 --- a/dist/save/index.js +++ b/dist/save/index.js @@ -2954,13 +2954,14 @@ var __importStar = (this && this.__importStar) || function (mod) { return result; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.issueCommand = void 0; +exports.prepareKeyValueMessage = exports.issueFileCommand = void 0; // We use any as a valid input type /* eslint-disable @typescript-eslint/no-explicit-any */ const fs = __importStar(__webpack_require__(747)); const os = __importStar(__webpack_require__(87)); +const uuid_1 = __webpack_require__(25); const utils_1 = __webpack_require__(82); -function issueCommand(command, message) { +function issueFileCommand(command, message) { const filePath = process.env[`GITHUB_${command}`]; if (!filePath) { throw new Error(`Unable to find environment variable for file command ${command}`); @@ -2972,7 +2973,22 @@ function issueCommand(command, message) { encoding: 'utf8' }); } -exports.issueCommand = issueCommand; +exports.issueFileCommand = issueFileCommand; +function prepareKeyValueMessage(key, value) { + const delimiter = `ghadelimiter_${uuid_1.v4()}`; + const convertedValue = utils_1.toCommandValue(value); + // These should realistically never happen, but just in case someone finds a + // way to exploit uuid generation let's not allow keys or values that contain + // the delimiter. + if (key.includes(delimiter)) { + throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`); + } + if (convertedValue.includes(delimiter)) { + throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`); + } + return `${key}<<${delimiter}${os.EOL}${convertedValue}${os.EOL}${delimiter}`; +} +exports.prepareKeyValueMessage = prepareKeyValueMessage; //# sourceMappingURL=file-command.js.map /***/ }), @@ -40551,7 +40567,6 @@ const file_command_1 = __webpack_require__(102); const utils_1 = __webpack_require__(82); const os = __importStar(__webpack_require__(87)); const path = __importStar(__webpack_require__(622)); -const uuid_1 = __webpack_require__(25); const oidc_utils_1 = __webpack_require__(742); /** * The code to exit an action @@ -40581,20 +40596,9 @@ function exportVariable(name, val) { process.env[name] = convertedVal; const filePath = process.env['GITHUB_ENV'] || ''; if (filePath) { - const delimiter = `ghadelimiter_${uuid_1.v4()}`; - // These should realistically never happen, but just in case someone finds a way to exploit uuid generation let's not allow keys or values that contain the delimiter. - if (name.includes(delimiter)) { - throw new Error(`Unexpected input: name should not contain the delimiter "${delimiter}"`); - } - if (convertedVal.includes(delimiter)) { - throw new Error(`Unexpected input: value should not contain the delimiter "${delimiter}"`); - } - const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`; - file_command_1.issueCommand('ENV', commandValue); - } - else { - command_1.issueCommand('set-env', { name }, convertedVal); + return file_command_1.issueFileCommand('ENV', file_command_1.prepareKeyValueMessage(name, val)); } + command_1.issueCommand('set-env', { name }, convertedVal); } exports.exportVariable = exportVariable; /** @@ -40612,7 +40616,7 @@ exports.setSecret = setSecret; function addPath(inputPath) { const filePath = process.env['GITHUB_PATH'] || ''; if (filePath) { - file_command_1.issueCommand('PATH', inputPath); + file_command_1.issueFileCommand('PATH', inputPath); } else { command_1.issueCommand('add-path', {}, inputPath); @@ -40652,7 +40656,10 @@ function getMultilineInput(name, options) { const inputs = getInput(name, options) .split('\n') .filter(x => x !== ''); - return inputs; + if (options && options.trimWhitespace === false) { + return inputs; + } + return inputs.map(input => input.trim()); } exports.getMultilineInput = getMultilineInput; /** @@ -40685,8 +40692,12 @@ exports.getBooleanInput = getBooleanInput; */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function setOutput(name, value) { + const filePath = process.env['GITHUB_OUTPUT'] || ''; + if (filePath) { + return file_command_1.issueFileCommand('OUTPUT', file_command_1.prepareKeyValueMessage(name, value)); + } process.stdout.write(os.EOL); - command_1.issueCommand('set-output', { name }, value); + command_1.issueCommand('set-output', { name }, utils_1.toCommandValue(value)); } exports.setOutput = setOutput; /** @@ -40815,7 +40826,11 @@ exports.group = group; */ // eslint-disable-next-line @typescript-eslint/no-explicit-any function saveState(name, value) { - command_1.issueCommand('save-state', { name }, value); + const filePath = process.env['GITHUB_STATE'] || ''; + if (filePath) { + return file_command_1.issueFileCommand('STATE', file_command_1.prepareKeyValueMessage(name, value)); + } + command_1.issueCommand('save-state', { name }, utils_1.toCommandValue(value)); } exports.saveState = saveState; /** diff --git a/package-lock.json b/package-lock.json index 5db399f..cdcbb19 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "MIT", "dependencies": { "@actions/cache": "^3.0.4", - "@actions/core": "^1.9.1", + "@actions/core": "^1.10.0", "@actions/exec": "^1.1.1", "@actions/io": "^1.1.2" }, @@ -52,9 +52,9 @@ } }, "node_modules/@actions/core": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.9.1.tgz", - "integrity": "sha512-5ad+U2YGrmmiw6du20AQW5XuWo7UKN2052FjSV7MX+Wfjf8sCqcsZe62NfgHys4QI4/Y+vQvLKYL8jWtA1ZBTA==", + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz", + "integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==", "dependencies": { "@actions/http-client": "^2.0.1", "uuid": "^8.3.2" @@ -9550,9 +9550,9 @@ } }, "@actions/core": { - "version": "1.9.1", - "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.9.1.tgz", - "integrity": "sha512-5ad+U2YGrmmiw6du20AQW5XuWo7UKN2052FjSV7MX+Wfjf8sCqcsZe62NfgHys4QI4/Y+vQvLKYL8jWtA1ZBTA==", + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz", + "integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==", "requires": { "@actions/http-client": "^2.0.1", "uuid": "^8.3.2" diff --git a/package.json b/package.json index c5183e2..9c42e31 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "license": "MIT", "dependencies": { "@actions/cache": "^3.0.4", - "@actions/core": "^1.9.1", + "@actions/core": "^1.10.0", "@actions/exec": "^1.1.1", "@actions/io": "^1.1.2" }, @@ -48,4 +48,4 @@ "ts-jest": "^28.0.2", "typescript": "^4.6.4" } -} \ No newline at end of file +} From 831ee695a5fa6fdf53fae3e5202e72dfade90a5d Mon Sep 17 00:00:00 2001 From: Francesco Renzi Date: Thu, 6 Oct 2022 10:44:39 +0100 Subject: [PATCH 12/21] Update licenses --- .licenses/npm/@actions/core.dep.yml | Bin 1303 -> 1304 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/.licenses/npm/@actions/core.dep.yml b/.licenses/npm/@actions/core.dep.yml index 2e0762e41b02be6564d88601b850e7b653993aa7..a2682b834ca92e59bdad37339d721e67eb0cb076 100644 GIT binary patch delta 15 WcmbQvHG^w{DvP0kp20?q_bdP-WCVx+ delta 14 VcmbQiHJxjMDzl}Y;YQ8(EC3)N1YrOG From 1c73980b09e7aea7201f325a7aa3ad00beddcdda Mon Sep 17 00:00:00 2001 From: Lovepreet Singh Date: Thu, 13 Oct 2022 09:02:55 +0000 Subject: [PATCH 13/21] 3.0.11 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index cdcbb19..8288379 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "cache", - "version": "3.0.10", + "version": "3.0.11", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package.json b/package.json index 9c42e31..333763e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cache", - "version": "3.0.10", + "version": "3.0.11", "private": true, "description": "Cache dependencies and build outputs", "main": "dist/restore/index.js", From 43428ea05659d8e1bae90d9528e4dc23b1d270f3 Mon Sep 17 00:00:00 2001 From: Lovepreet Singh Date: Thu, 13 Oct 2022 10:34:22 +0000 Subject: [PATCH 14/21] toolkit versioon update and version bump for cache --- package-lock.json | 20 ++++++++++---------- package.json | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8288379..fe28d4f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,10 +6,10 @@ "packages": { "": { "name": "cache", - "version": "3.0.10", + "version": "3.0.11", "license": "MIT", "dependencies": { - "@actions/cache": "^3.0.4", + "@actions/cache": "^3.0.5", "@actions/core": "^1.10.0", "@actions/exec": "^1.1.1", "@actions/io": "^1.1.2" @@ -36,11 +36,11 @@ } }, "node_modules/@actions/cache": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.0.4.tgz", - "integrity": "sha512-9RwVL8/ISJoYWFNH1wR/C26E+M3HDkGPWmbFJMMCKwTkjbNZJreMT4XaR/EB1bheIvN4PREQxEQQVJ18IPnf/Q==", + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.0.5.tgz", + "integrity": "sha512-0WpPmwnRPkn5k5ASmjoX8bY8NrZEPTwN+64nGYJmR/bHjEVgC8svdf5K956wi67tNJBGJky2+UfvNbUOtHmMHg==", "dependencies": { - "@actions/core": "^1.2.6", + "@actions/core": "^1.10.0", "@actions/exec": "^1.0.1", "@actions/glob": "^0.1.0", "@actions/http-client": "^2.0.1", @@ -9534,11 +9534,11 @@ }, "dependencies": { "@actions/cache": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.0.4.tgz", - "integrity": "sha512-9RwVL8/ISJoYWFNH1wR/C26E+M3HDkGPWmbFJMMCKwTkjbNZJreMT4XaR/EB1bheIvN4PREQxEQQVJ18IPnf/Q==", + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/@actions/cache/-/cache-3.0.5.tgz", + "integrity": "sha512-0WpPmwnRPkn5k5ASmjoX8bY8NrZEPTwN+64nGYJmR/bHjEVgC8svdf5K956wi67tNJBGJky2+UfvNbUOtHmMHg==", "requires": { - "@actions/core": "^1.2.6", + "@actions/core": "^1.10.0", "@actions/exec": "^1.0.1", "@actions/glob": "^0.1.0", "@actions/http-client": "^2.0.1", diff --git a/package.json b/package.json index 333763e..f1cdd16 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "author": "GitHub", "license": "MIT", "dependencies": { - "@actions/cache": "^3.0.4", + "@actions/cache": "^3.0.5", "@actions/core": "^1.10.0", "@actions/exec": "^1.1.1", "@actions/io": "^1.1.2" From 3e383cd9c3a28c11844c2b3b85adffb0d0e6e1f2 Mon Sep 17 00:00:00 2001 From: Lovepreet Singh Date: Thu, 13 Oct 2022 10:36:33 +0000 Subject: [PATCH 15/21] Update RELEASES --- RELEASES.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/RELEASES.md b/RELEASES.md index 85ba1b5..e158bfc 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -36,3 +36,7 @@ ### 3.0.10 - 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` From 18103f63fea3fcdd0d49433c3280892998aa2ada Mon Sep 17 00:00:00 2001 From: Lovepreet Singh Date: Thu, 13 Oct 2022 11:01:53 +0000 Subject: [PATCH 16/21] Fix licensed status error --- .licenses/npm/@actions/cache.dep.yml | Bin 1242 -> 1242 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/.licenses/npm/@actions/cache.dep.yml b/.licenses/npm/@actions/cache.dep.yml index 2cf3e93a3938daef79bc6783815557ce9dea5467..453e8be34438218237e6dd73217e19fad51e2394 100644 GIT binary patch delta 12 Tcmcb`d5d#`2BYal&5bMo9>@el delta 12 Tcmcb`d5d#`2BXPF&5bMo9>WAf From 2b04a41915d2fed6cec2aa74821ba81689ff0816 Mon Sep 17 00:00:00 2001 From: Rong Rong Date: Mon, 17 Oct 2022 22:26:49 -0700 Subject: [PATCH 17/21] timeout env var key is not correct in README.md (#959) --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 408fd2e..abe42b0 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ See ["Caching dependencies to speed up workflows"](https://docs.github.com/en/ac * Fixed cache not working with github workspace directory or current directory. * Fixed the download stuck problem by introducing a timeout of 1 hour for cache downloads. * Fix zstd not working for windows on gnu tar in issues. -* Allowing users to provide a custom timeout as input for aborting download of a cache segment using an environment variable `SEGMENT_DOWNLOAD_TIMEOUT_MIN`. Default is 60 minutes. +* 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. Refer [here](https://github.com/actions/cache/blob/v2/README.md) for previous versions @@ -38,7 +38,7 @@ If you are using this inside a container, a POSIX-compliant `tar` needs to be in `cache-hit` returns false in this case. #### Environment Variables -* `SEGMENT_DOWNLOAD_TIMEOUT_MIN` - Segment download timeout (in minutes, default `60`) to abort download of the segment if not completed in the defined number of minutes. [Read more](#cache-segment-restore-timeout) +* `SEGMENT_DOWNLOAD_TIMEOUT_MINS` - Segment download timeout (in minutes, default `60`) to abort download of the segment if not completed in the defined number of minutes. [Read more](#cache-segment-restore-timeout) ### Outputs From 4fe9c4bd54cc7f1a32249072c2256c718ea68a5b Mon Sep 17 00:00:00 2001 From: Sankalp Kotewar <98868223+kotewar@users.noreply.github.com> Date: Tue, 18 Oct 2022 12:45:50 +0530 Subject: [PATCH 18/21] Updated release file with correct env variable (#960) --- RELEASES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASES.md b/RELEASES.md index e158bfc..507c9bd 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -28,7 +28,7 @@ ### 3.0.8 - 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_MIN`. Default is 60 minutes. +- 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. ### 3.0.9 - Enhanced the warning message for cache unavailablity in case of GHES. From 5294b3f306918b313ba159be1aa3173e6049dfb9 Mon Sep 17 00:00:00 2001 From: Sankalp Kotewar Date: Wed, 19 Oct 2022 00:41:06 +0530 Subject: [PATCH 19/21] Update README.md --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index abe42b0..cbf27b4 100644 --- a/README.md +++ b/README.md @@ -34,17 +34,18 @@ If you are using this inside a container, a POSIX-compliant `tar` needs to be in * `path` - A list of files, directories, and wildcard patterns to cache and restore. See [`@actions/glob`](https://github.com/actions/toolkit/tree/main/packages/glob) for supported patterns. * `key` - An explicit key for restoring and saving the cache -* `restore-keys` - An ordered list of prefix-matched keys to use for restoring stale cache if no cache hit occurred for key. Note -`cache-hit` returns false in this case. +* `restore-keys` - An ordered list of prefix-matched keys to use for restoring stale cache if no cache hit occurred for key. #### Environment Variables * `SEGMENT_DOWNLOAD_TIMEOUT_MINS` - Segment download timeout (in minutes, default `60`) to abort download of the segment if not completed in the defined number of minutes. [Read more](#cache-segment-restore-timeout) ### Outputs -* `cache-hit` - A boolean value to indicate an exact match was found for the key +* `cache-hit` - A boolean value to indicate an exact match was found for the key. -> See [Skipping steps based on cache-hit](#Skipping-steps-based-on-cache-hit) for info on using this output +> Note: `cache-hit` will be set to `true` only when cache hit occurs for the exact `key` match. For a partial key match via `restore-keys` or a cache miss, it will be set to `false`. It is recommended to install the missing/updated dependencies in case of a partial key match when the key is dependent on the `hash` of the package file. + +See [Skipping steps based on cache-hit](#skipping-steps-based-on-cache-hit) for info on using this output ### Cache scopes The cache is scoped to the key and branch. The default branch cache is available to other branches. From 76639bb4e517ef889f653f786e0622f788a7f546 Mon Sep 17 00:00:00 2001 From: Lovepreet Singh Date: Fri, 21 Oct 2022 20:38:51 +0530 Subject: [PATCH 20/21] Create pull_request_template.md Adding a PR template would certainly increase clarity on the PRs and also help us better review changes. This is a starter template. Please feel free to suggest changes, add/remove sections that are not relevant. --- .github/pull_request_template.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/pull_request_template.md diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..ec22705 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,32 @@ + + +## Description + + +## Motivation and Context + + + +## How Has This Been Tested? + + + + +## Screenshots (if appropriate): + +## Types of changes + +- [ ] Bug fix (non-breaking change which fixes an issue) +- [ ] New feature (non-breaking change which adds functionality) +- [ ] Breaking change (fix or feature that would cause existing functionality to change) +- [ ] Documentation (add or update README or docs) + +## Checklist: + + +- [ ] My code follows the code style of this project. +- [ ] My change requires a change to the documentation. +- [ ] I have updated the documentation accordingly. +- [ ] I have read the **CONTRIBUTING** document. +- [ ] I have added tests to cover my changes. +- [ ] All new and existing tests passed. From 14f2d18ea2a8de1085ccf3aedfeb86ef1f4b7bdd Mon Sep 17 00:00:00 2001 From: Sankalp Kotewar <98868223+kotewar@users.noreply.github.com> Date: Wed, 26 Oct 2022 11:15:05 +0000 Subject: [PATCH 21/21] Moved recommendation to skipping steps section --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cbf27b4..4247617 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ If you are using this inside a container, a POSIX-compliant `tar` needs to be in * `cache-hit` - A boolean value to indicate an exact match was found for the key. -> Note: `cache-hit` will be set to `true` only when cache hit occurs for the exact `key` match. For a partial key match via `restore-keys` or a cache miss, it will be set to `false`. It is recommended to install the missing/updated dependencies in case of a partial key match when the key is dependent on the `hash` of the package file. +> Note: `cache-hit` will be set to `true` only when cache hit occurs for the exact `key` match. For a partial key match via `restore-keys` or a cache miss, it will be set to `false`. See [Skipping steps based on cache-hit](#skipping-steps-based-on-cache-hit) for info on using this output @@ -153,7 +153,7 @@ A repository can have up to 10GB of caches. Once the 10GB limit is reached, olde ## Skipping steps based on cache-hit -Using the `cache-hit` output, subsequent steps (such as install or build) can be skipped when a cache hit occurs on the key. +Using the `cache-hit` output, subsequent steps (such as install or build) can be skipped when a cache hit occurs on the key. It is recommended to install the missing/updated dependencies in case of a partial key match when the key is dependent on the `hash` of the package file. Example: ```yaml