8000 General Availability release for new restore and save actions by kotewar · Pull Request #1035 · actions/cache · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

General Availability release for new restore and save actions #1035

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 111 commits into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
111 commits
Select commit Hold shift + click to select a range
ea5981d
Add example for Haskell Stack
malob Feb 3, 2020
29dbbce
Merge pull request #173 from malob/add-stack-example
Feb 22, 2022
669e753
Revert "Add example for Haskell Stack"
Feb 22, 2022
515d10b
Merge pull request #746 from actions/revert-173-add-stack-example
Feb 22, 2022
69b8227
Basic implementation
kotewar Nov 25, 2022
5fe0b94
Updated variable name
kotewar Nov 29, 2022
0769f2e
Merge branch 'main' into master
Nov 29, 2022
7f45813
Adding wrapper class
kotewar Nov 29, 2022
921c58e
Changed logs to warnings
kotewar Nov 29, 2022
abddc4d
Merge remote-tracking branch 'origin/master' into 700-actionscache-gr…
kotewar Nov 29, 2022
dddd7ce
added debug logs
kotewar Nov 29, 2022
888d454
experimenting
kotewar Nov 29, 2022
71334c5
Test
kotewar Nov 29, 2022
fb4a5dc
test
kotewar Nov 29, 2022
ab0e771
new try
kotewar Nov 29, 2022
af1210e
test
kotewar Nov 29, 2022
f871768
Impl separated
kotewar Nov 29, 2022
a172494
Reverted wrapper changes
kotewar No 10000 v 29, 2022
9c5a42a
Added test cases
kotewar Nov 30, 2022
01d9663
Some cleanup
kotewar Nov 30, 2022
2c9fb32
Merge branch 'main' into 700-actionscache-granular-cache-control
kotewar Nov 30, 2022
6e2c6a5
Formatted document
kotewar Nov 30, 2022
8a88690
Fixed test cases issues
kotewar Nov 30, 2022
19446b1
Slight modification for test cases check
kotewar Nov 30, 2022
56a0133
Merge branch 'main' into 700-actionscache-granular-cache-control
kotewar Nov 30, 2022
4b5f33d
Updated new actions' input descriptions
kotewar Dec 1, 2022
11ab7cc
Reverted custom asks implemented and added wrapper
kotewar Dec 2, 2022
706c369
Merge branch 'main' into 700-actionscache-granular-cache-control
kotewar Dec 5, 2022
d95c048
refactor into a generic outputter
bishal-pdMSFT Dec 5, 2022
020a412
Readme draft for new actions
kotewar Dec 5, 2022
e3d8fb0
Merge pull request #1016 from actions/bishal/outputter
kotewar Dec 5, 2022
cce93fb
Generated dist
kotewar Dec 6, 2022
85ae5bb
Fixed breaking test case
kotewar Dec 6, 2022
e02e511
Removed return type in promise
kotewar Dec 6, 2022
a76826e
Removed commented lines
kotewar Dec 6, 2022
d6e98d9
Calling methods from same file
kotewar Dec 6, 2022
86712a0
dist
kotewar Dec 6, 2022
ac8fc97
update save as well
bishal-pdMSFT Dec 6, 2022
34e917c
Merge branch '700-actionscache-granular-cache-control' into bishal/ou…
bishal-pdMSFT Dec 6, 2022
657c52f
fix merge
bishal-pdMSFT Dec 6, 2022
66ef8a0
Merge pull request #1018 from actions/bishal/outputter
tanuj077 Dec 7, 2022
e4c2242
Changes for beta release
Phantsure Dec 5, 2022
593e91a
Update dist folder
Phantsure Dec 5, 2022
c346bf0
Merge remote-tracking branch 'origin/releases/v3-beta' into 700-actio…
kotewar Dec 8, 2022
6e12d27
Fixed formatting
kotewar Dec 8, 2022
6f77eda
dist
kotewar Dec 8, 2022
d48d034
Add support for gzip fallback for restore of old cache on windows
Phantsure Dec 8, 2022
f33ca90
Merge pull request #1022 from actions/phantsure/v3-beta
Phantsure Dec 8, 2022
782b0bd
Fixed test cases
kotewar Dec 8, 2022
12a1a35
Fixed test cases
kotewar Dec 8, 2022
8ecd00a
Added restore only and save only test cases
kotewar Dec 8, 2022
be72d04
Merge remote-tracking branch 'origin/releases/v3-beta' into 700-actio…
kotewar Dec 9, 2022
f426a0d
Merge remote-tracking branch 'origin/700-actionscache-granular-cache-…
kotewar Dec 9, 2022
804322a
Updated new actions dist files
kotewar Dec 9, 2022
0c2d18e
Merge pull request #1024 from actions/kotewar/save-changes
kotewar Dec 9, 2022
61aa90b
Removed comments
kotewar Dec 9, 2022
d91f5bd
Fixed inputs
kotewar Dec 9, 2022
3d4af52
Renamed variables and added tests
kotewar Dec 11, 2022
5e7f2c1
Fixed breaking test case
kotewar Dec 11, 2022
91d7bd6
Fixed review comments and tests
kotewar Dec 12, 2022
c0cc8dd
added stateprovider changes
kotewar Dec 12, 2022
b660436
Deleted stateprovider tests until added
kotewar Dec 12, 2022
4f42dc5
Added stateprovider test cases
kotewar Dec 12, 2022
ccf90c0
Fixed breaking test case
kotewar Dec 12, 2022
0cc9c1d
Merge remote-tracking branch 'origin/700-actionscache-granular-cache-…
kotewar Dec 12, 2022
00b72c7
Updated outputs of restore action
kotewar Dec 12, 2022
84ea3e1
Changes for beta release
Phantsure Dec 5, 2022
9e9a19b
Update dist folder
Phantsure Dec 5, 2022
5a2b5e5
Add support for gzip fallback for restore of old cache on windows
Phantsure Dec 8, 2022
a2137c6
update for new beta release
Phantsure Dec 12, 2022
0a6e5b0
Update save/action.yml
kotewar Dec 12, 2022
dd740c8
Update restore/action.yml
kotewar Dec 12, 2022
df53d3c
Update restore/action.yml
kotewar Dec 12, 2022
29d6c7a
Update restore/action.yml
kotewar Dec 12, 2022
87a7d01
Update restore/action.yml
kotewar Dec 12, 2022
4070447
Added more assertions as values can't be checked
kotewar Dec 12, 2022
1ddc491
Removed unused code
kotewar Dec 12, 2022
b275c83
Merge remote-tracking branch 'origin/releases/v3-beta' into 700-actio…
kotewar Dec 12, 2022
075ad79
Merged beta branch and resolved conflicts
kotewar Dec 12, 2022
adecab4
Merge remote-tracking branch 'origin/700-actionscache-granular-cache-…
kotewar Dec 12, 2022
9d445b2
Added save readme
kotewar Dec 14, 2022
81aaae0
Updates to save readme
kotewar Dec 14, 2022
c8d01fa
Renamed output
kotewar Dec 14, 2022
8031e40
Merge remote-tracking branch 'origin/700-actionscache-granular-cache-…
kotewar Dec 14, 2022
65057ce
Added cache hit info in readme
kotewar Dec 14, 2022
44df5ab
Update restore/README.md
kotewar Dec 14, 2022
d5c9496
Update restore/README.md
kotewar Dec 14, 2022
c11ac6c
Update restore/README.md
kotewar Dec 14, 2022
fb5b333
Update save/README.md
kotewar Dec 14, 2022
686bf42
Update save/README.md
kotewar Dec 14, 2022
766d825
Removed verbose statements
kotewar Dec 14, 2022
56e9564
Repositioned new actions introduction
kotewar Dec 14, 2022
930f080
Added test case for restore state
kotewar Dec 15, 2022
7a139a9
Addressed review comments
kotewar Dec 15, 2022
da311f7
nit
kotewar Dec 15, 2022
05c9b49
nit: added language to code blocks
kotewar Dec 15, 2022
c30e6dc
Merge pull request #1017 from actions/kotewar/readme-updates-for-gran…
kotewar Dec 15, 2022
6277f55
Updated beta version to 3.2.0-beta.1
kotewar Dec 15, 2022
ed5e94a
Merge pull request #1006 from actions/700-actionscache-granular-cache…
kotewar Dec 15, 2022
770b3a8
Added stateprovider mock implementations
kotewar Dec 19, 2022
3f0eaf4
Linting errors fixed
kotewar Dec 19, 2022
8955114
Merge pull request #1029 from actions/kotewar/test-case-fixes
kotewar Dec 19, 2022
1d114a8
Save-only warning added
kotewar Dec 20, 2022
34faf3a
Updated return ID to -2
kotewar Dec 21, 2022
f9ae5e0
Removed -2 error code
kotewar Dec 21, 2022
b388bca
Removed comment
kotewar Dec 21, 2022
64a59d5
Merge pull request #1034 from actions/kotewar/save-warnings
kotewar Dec 21, 2022
543111c
Updated cache npm lib version
kotewar Dec 21, 2022
09a5bab
Updated license version
kotewar Dec 21, 2022
8abfa12
Updated releases.md
kotewar Dec 21, 2022
48a82d5
Updated readme with the new actions in what's new
kotewar Dec 21, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "Node.js & TypeScript",
"image": "mcr.microsoft.com/devcontainers/typescript-node:16-bullseye",
// Features to add to the dev container. More info: https://containers.dev/implementors/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "npm install"
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
2 changes: 1 addition & 1 deletion .licenses/npm/@actions/cache.dep.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@

This action allows caching dependencies and build outputs to improve workflow execution time.

In addition to this `cache` action, other two actions are also available

[Restore action](./restore/README.md)

[Save action](./save/README.md)

[![Tests](https://github.com/actions/cache/actions/workflows/workflow.yml/badge.svg)](https://github.com/actions/cache/actions/workflows/workflow.yml)

## Documentation

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
* Added support for caching from GHES 3.5.
Expand All @@ -20,6 +27,7 @@ See ["Caching dependencies to speed up workflows"](https://docs.github.com/en/ac
* 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_MINS`. Default is 60 minutes.
* Two new actions available for granular control over caches - [restore](restore/action.yml) and [save](save/action.yml)

Refer [here](https://github.com/actions/cache/blob/v2/README.md) for previous versions

Expand Down
15 changes: 15 additions & 0 deletions RELEASES.md
< F438 tr data-hunk="ca1edde5f546d337b4e525305131cea2800d8e20e8feb9e7d10b1d2ac73ff952" class="show-top-border">
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,18 @@
### 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
79 changes: 1 addition & 78 deletions __tests__/actionUtils.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as cache from "@actions/cache";
import * as core from "@actions/core";

import { Events, Outputs, RefKey, State } from "../src/constants";
import { Events, RefKey } from "../src/constants";
import * as actionUtils from "../src/utils/actionUtils";
import * as testUtils from "../src/utils/testUtils";

Expand Down Expand Up @@ -79,83 +79,6 @@ test("isExactKeyMatch with same key and different casing returns true", () => {
expect(actionUtils.isExactKeyMatch(key, cacheKey)).toBe(true);
});

test("setOutputAndState with undefined entry to set cache-hit output", () => {
const key = "linux-rust";
const cacheKey = undefined;

const setOutputMock = jest.spyOn(core, "setOutput");
const saveStateMock = jest.spyOn(core, "saveState");

actionUtils.setOutputAndState(key, cacheKey);

expect(setOutputMock).toHaveBeenCalledWith(Outputs.CacheHit, "false");
expect(setOutputMock).toHaveBeenCalledTimes(1);

expect(saveStateMock).toHaveBeenCalledTimes(0);
});

test("setOutputAndState with exact match to set cache-hit output and state", () => {
const key = "linux-rust";
const cacheKey = "linux-rust";

const setOutputMock = jest.spyOn(core, "setOutput");
const saveStateMock = jest.spyOn(core, "saveState");

actionUtils.setOutputAndState(key, cacheKey);

expect(setOutputMock).toHaveBeenCalledWith(Outputs.CacheHit, "true");
expect(setOutputMock).toHaveBeenCalledTimes(1);

expect(saveStateMock).toHaveBeenCalledWith(State.CacheMatchedKey, cacheKey);
expect(saveStateMock).toHaveBeenCalledTimes(1);
});

test("setOutputAndState with no exact match to set cache-hit output and state", () => {
const key = "linux-rust";
const cacheKey = "linux-rust-bb828da54c148048dd17899ba9fda624811cfb43";

const setOutputMock = jest.spyOn(core, "setOutput");
const saveStateMock = jest.spyOn(core, "saveState");

actionUtils.setOutputAndState(key, cacheKey);

expect(setOutputMock).toHaveBeenCalledWith(Outputs.CacheHit, "false");
expect(setOutputMock).toHaveBeenCalledTimes(1);

expect(saveStateMock).toHaveBeenCalledWith(State.CacheMatchedKey, cacheKey);
expect(saveStateMock).toHaveBeenCalledTimes(1);
});

test("getCacheState with no state returns undefined", () => {
const getStateMock = jest.spyOn(core, "getState");
getStateMock.mockImplementation(() => {
return "";
});

const state = actionUtils.getCacheState();

expect(state).toBe(undefined);

expect(getStateMock).toHaveBeenCalledWith(State.CacheMatchedKey);
expect(getStateMock).toHaveBeenCalledTimes(1);
});

test("getCacheState with valid state", () => {
const cacheKey = "Linux-node-bb828da54c148048dd17899ba9fda624811cfb43";

const getStateMock = jest.spyOn(core, "getState");
getStateMock.mockImplementation(() => {
return cacheKey;
});

const state = actionUtils.getCacheState();

expect(state).toEqual(cacheKey);

expect(getStateMock).toHaveBeenCalledWith(State.CacheMatchedKey);
expect(getStateMock).toHaveBeenCalledTimes(1);
});

test("logWarning logs a message with a warning prefix", () => {
const message = "A warning occurred.";

Expand Down
173 changes: 15 additions & 158 deletions __tests__/restore.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as cache from "@actions/cache";
import * as core from "@actions/core";

import { Events, Inputs, RefKey } from "../src/constants";
import { Events, RefKey } from "../src/constants";
import run from "../src/restore";
import * as actionUtils from "../src/utils/actionUtils";
import * as testUtils from "../src/utils/testUtils";
Expand Down Expand Up @@ -45,158 +45,6 @@ afterEach(() => {
delete process.env[RefKey];
});

test("restore with invalid event outputs warning", async () => {
const logWarningMock = jest.spyOn(actionUtils, "logWarning");
const failedMock = jest.spyOn(core, "setFailed");
const invalidEvent = "commit_comment";
process.env[Events.Key] = invalidEvent;
delete process.env[RefKey];
await run();
expect(logWarningMock).toHaveBeenCalledWith(
`Event Validation Error: The event type ${invalidEvent} is not supported because it's not tied to a branch or tag ref.`
);
expect(failedMock).toHaveBeenCalledTimes(0);
});

test("restore without AC available should no-op", async () => {
jest.spyOn(actionUtils, "isGhes").mockImplementation(() => false);
jest.spyOn(actionUtils, "isCacheFeatureAvailable").mockImplementation(
() => false
);

const restoreCacheMock = jest.spyOn(cache, "restoreCache");
const setCacheHitOutputMock = jest.spyOn(actionUtils, "setCacheHitOutput");

await run();

expect(restoreCacheMock).toHaveBeenCalledTimes(0);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
expect(setCacheHitOutputMock).toHaveBeenCalledWith(false);
});

test("restore on GHES without AC available should no-op", async () => {
jest.spyOn(actionUtils, "isGhes").mockImplementation(() => true);
jest.spyOn(actionUtils, "isCacheFeatureAvailable").mockImplementation(
() => false
);

const restoreCacheMock = jest.spyOn(cache, "restoreCache");
const setCacheHitOutputMock = jest.spyOn(actionUtils, "setCacheHitOutput");

await run();

expect(restoreCacheMock).toHaveBeenCalledTimes(0);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
expect(setCacheHitOutputMock).toHaveBeenCalledWith(false);
});

test("restore on GHES with AC available ", async () => {
jest.spyOn(actionUtils, "isGhes").mockImplementation(() => true);
const path = "node_modules";
const key = "node-test";
testUtils.setInputs({
path: path,
key
});

const infoMock = jest.spyOn(core, "info");
const failedMock = jest.spyOn(core, "setFailed");
const stateMock = jest.spyOn(core, "saveState");
const setCacheHitOutputMock = jest.spyOn(actionUtils, "setCacheHitOutput");
const restoreCacheMock = jest
.spyOn(cache, "restoreCache")
.mockImplementationOnce(() => {
return Promise.resolve(key);
});

await run();

expect(restoreCacheMock).toHaveBeenCalledTimes(1);
expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []);

expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
expect(setCacheHitOutputMock).toHaveBeenCalledWith(true);

expect(infoMock).toHaveBeenCalledWith(`Cache restored from key: ${key}`);
expect(failedMock).toHaveBeenCalledTimes(0);
});

test("restore with no path should fail", async () => {
const failedMock = jest.spyOn(core, "setFailed");
const restoreCacheMock = jest.spyOn(cache, "restoreCache");
await run();
expect(restoreCacheMock).toHaveBeenCalledTimes(0);
// this input isn't necessary for restore b/c tarball contains entries relative to workspace
expect(failedMock).not.toHaveBeenCalledWith(
"Input required and not supplied: path"
);
});

test("restore with no key", async () => {
testUtils.setInput(Inputs.Path, "node_modules");
const failedMock = jest.spyOn(core, "setFailed");
const restoreCacheMock = jest.spyOn(cache, "restoreCache");
await run();
expect(restoreCacheMock).toHaveBeenCalledTimes(0);
expect(failedMock).toHaveBeenCalledWith(
"Input required and not supplied: key"
);
});

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());
testUtils.setInputs({
path: path,
key,
restoreKeys
});
const failedMock = jest.spyOn(core, "setFailed");
const restoreCacheMock = jest.spyOn(cache, "restoreCache");
await run();
expect(restoreCacheMock).toHaveBeenCalledTimes(1);
expect(restoreCacheMock).toHaveBeenCalledWith([path], key, restoreKeys);
expect(failedMock).toHaveBeenCalledWith(
`Key Validation Error: Keys are limited to a maximum of 10.`
);
});

test("restore with large key should fail", async () => {
const path = "node_modules";
const key = "foo".repeat(512); // Over the 512 character limit
testUtils.setInputs({
path: path,
key
});
const failedMock = jest.spyOn(core, "setFailed");
const restoreCacheMock = jest.spyOn(cache, "restoreCache");
await run();
expect(restoreCacheMock).toHaveBeenCalledTimes(1);
expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []);
expect(failedMock).toHaveBeenCalledWith(
`Key Validation Error: ${key} cannot be larger than 512 characters.`
);
});

test("restore with invalid key should fail", async () => {
const path = "node_modules";
const key = "comma,comma";
testUtils.setInputs({
path: path,
key
});
const failedMock = jest.spyOn(core, "setFailed");
const restoreCacheMock = jest.spyOn(cache, "restoreCache");
await run();
expect(restoreCacheMock).toHaveBeenCalledTimes(1);
expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []);
expect(failedMock).toHaveBeenCalledWith(
`Key Validation Error: ${key} cannot contain commas.`
);
});

test("restore with no cache found", async () => {
const path = "node_modules";
const key = "node-test";
Expand All @@ -220,6 +68,8 @@ test("restore with no cache found", async () => {
expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []);

expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(stateMock).toHaveBeenCalledTimes(1);

expect(failedMock).toHaveBeenCalledTimes(0);

expect(infoMock).toHaveBeenCalledWith(
Expand Down Expand Up @@ -252,6 +102,8 @@ test("restore with restore keys and no cache found", async () => {
expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [restoreKey]);

expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(stateMock).toHaveBeenCalledTimes(1);

expect(failedMock).toHaveBeenCalledTimes(0);

expect(infoMock).toHaveBeenCalledWith(
Expand All @@ -270,7 +122,7 @@ test("restore with cache found for key", async () => {
const infoMock = jest.spyOn(core, "info");
const failedMock = jest.spyOn(core, "setFailed");
const stateMock = jest.spyOn(core, "saveState");
const setCacheHitOutputMock = jest.spyOn(actionUtils, "setCacheHitOutput");
const setCacheHitOutputMock = jest.spyOn(core, "setOutput");
const restoreCacheMock = jest
.spyOn(cache, "restoreCache")
.mockImplementationOnce(() => {
Expand All @@ -283,8 +135,11 @@ test("restore with cache found for key", async () => {
expect(restoreCacheMock).toHaveBeenCalledWith([path], key, []);

expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(stateMock).toHaveBeenCalledWith("CACHE_RESULT", key);
expect(stateMock).toHaveBeenCalledTimes(2);

expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
expect(setCacheHitOutputMock).toHaveBeenCalledWith(true);
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "true");

expect(infoMock).toHaveBeenCalledWith(`Cache restored from key: ${key}`);
expect(failedMock).toHaveBeenCalledTimes(0);
Expand All @@ -303,7 +158,7 @@ test("restore with cache found for restore key", async () => {
const infoMock = jest.spyOn(core, "info");
const failedMock = jest.spyOn(core, "setFailed");
const stateMock = jest.spyOn(core, "saveState");
const setCacheHitOutputMock = jest.spyOn(actionUtils, "setCacheHitOutput");
const setCacheHitOutputMock = jest.spyOn(core, "setOutput");
const restoreCacheMock = jest
.spyOn(cache, "restoreCache")
.mockImplementationOnce(() => {
Expand All @@ -316,9 +171,11 @@ test("restore with cache found for restore key", async () => {
expect(restoreCacheMock).toHaveBeenCalledWith([path], key, [restoreKey]);

expect(stateMock).toHaveBeenCalledWith("CACHE_KEY", key);
expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
expect(setCacheHitOutputMock).toHaveBeenCalledWith(false);
expect(stateMock).toHaveBeenCalledWith("CACHE_RESULT", restoreKey);
expect(stateMock).toHaveBeenCalledTimes(2);

expect(setCacheHitOutputMock).toHaveBeenCalledTimes(1);
expect(setCacheHitOutputMock).toHaveBeenCalledWith("cache-hit", "false");
expect(infoMock).toHaveBeenCalledWith(
`Cache restored from key: ${restoreKey}`
);
Expand Down
Loading
0