From 3238536a48bfc94aa1be336fef0d93ad1725d57e Mon Sep 17 00:00:00 2001 From: ELHoussineT Date: Thu, 22 Sep 2022 10:50:41 +0200 Subject: [PATCH 1/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 252d03b71..5ba3924e5 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 68d96986b532923ef04d50de9cbaef6241839806 Mon Sep 17 00:00:00 2001 From: Vipul Date: Mon, 3 Oct 2022 06:39:10 +0000 Subject: [PATCH 2/3] 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 d36ac5845..c8e579ae6 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 6c020829e..e9a505b0c 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 c8c999e1a..0dd8a2500 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 0fbc6d406..34e4c7ac2 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 034df1958..dacd3a652 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 3/3] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5ba3924e5..b53321fab 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)