-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fix fail-on-cache-miss
not working
#1327
Conversation
fail-on-cache-miss
not workingfail-on-cache-miss
not working
/CC @bethanyj28 Would you mind taking a look at this one? It fixes a bug which was just recently introduced. |
@cdce8p - thanks for the contribution! This seems reasonable to me. Could you add a test case in https://github.com/actions/cache/blob/main/__tests__/restoreImpl.test.ts to validate? Thank you! |
I thought about that but I'm not really sure how to do it. The only thing not tested is I already looked at #1217 which first introduced the |
👋🏻 @cdce8p - sorry for the delay! While the initial change might've not had tests, it would be really nice to validate in the future that we don't regress here. I believe mocking test("restore failure with earlyExit should call process exit", async () => {
// mock `process.exit`
const processExitMock = jest.spyOn(process, "exit").mockImplementation();
// simulate a failure
testUtils.setInput(Inputs.Path, "node_modules");
const failedMock = jest.spyOn(core, "setFailed");
const restoreCacheMock = jest.spyOn(cache, "restoreCache");
// set true for `earlyExit`
await restoreImpl(new StateProvider(), true);
expect(restoreCacheMock).toHaveBeenCalledTimes(0);
expect(failedMock).toHaveBeenCalledWith(
"Input required and not supplied: key"
);
// validate `process.exit` called
expect(processExitMock).toHaveBeenCalledWith(1);
}); Thank you! |
Co-authored-by: Bethany <bethanyj28@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
@bethanyj28 Would you mind tagging the |
Definitely! I appreciate you updating the version 🙏🏻 |
actions/cache#1265 shoudl be fixed by actions/cache#1327
Fix `fail-on-cache-miss` not working
CACHING ACTION |
Mainly to fix the fact that fail-on-cache-miss doesn't work, see actions/cache#1327
Mainly to fix the fact that fail-on-cache-miss doesn't work, see actions/cache#1327
Mainly to fix the fact that fail-on-cache-miss doesn't work, see actions/cache#1327
Fixes build slowness (AllYarnsAreBeautiful#702). Also fixes fail-on-cache-miss having no effect, see actions/cache#1327
Fixes build slowness (#702). Also fixes fail-on-cache-miss having no effect, see actions/cache#1327
Description
process.exit
overwrites the exit code set bycore.setFailed
, e.g. the workflow would continue even thoughfail-on-cache-miss
is set and no cache is found.Originally introduced in
/CC @kgrzebien
Motivation and Context
Fixes #1265
How Has This Been Tested?
Created a workflow which should restore a non-existing cache. With
v4.0.0
the workflow continues, with this PR it fails as expected (withfail-on-cache-miss
set).Screenshots (if appropriate):
Types of changes
Checklist: