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>
|
@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
This PR contains the following updates: | Package | Update | Change | |---|---|---| | [actions/cache](https://github.com/actions/cache) | major | `v4` → `v5.0.5` | --- ### Release Notes <details> <summary>actions/cache (actions/cache)</summary> ### [`v5.0.5`](https://github.com/actions/cache/releases/tag/v5.0.5) [Compare Source](actions/cache@v5.0.4...v5.0.5) #### What's Changed - Update ts-http-runtime dependency by [@​yacaovsnc](https://github.com/yacaovsnc) in [#​1747](actions/cache#1747) **Full Changelog**: <actions/cache@v5...v5.0.5> ### [`v5.0.4`](https://github.com/actions/cache/releases/tag/v5.0.4) [Compare Source](actions/cache@v5.0.3...v5.0.4) #### What's Changed - Add release instructions and update maintainer docs by [@​Link-](https://github.com/Link-) in [#​1696](actions/cache#1696) - Potential fix for code scanning alert no. 52: Workflow does not contain permissions by [@​Link-](https://github.com/Link-) in [#​1697](actions/cache#1697) - Fix workflow permissions and cleanup workflow names / formatting by [@​Link-](https://github.com/Link-) in [#​1699](actions/cache#1699) - docs: Update examples to use the latest version by [@​XZTDean](https://github.com/XZTDean) in [#​1690](actions/cache#1690) - Fix proxy integration tests by [@​Link-](https://github.com/Link-) in [#​1701](actions/cache#1701) - Fix cache key in examples.md for bun.lock by [@​RyPeck](https://github.com/RyPeck) in [#​1722](actions/cache#1722) - Update dependencies & patch security vulnerabilities by [@​Link-](https://github.com/Link-) in [#​1738](actions/cache#1738) #### New Contributors - [@​XZTDean](https://github.com/XZTDean) made their first contribution in [#​1690](actions/cache#1690) - [@​RyPeck](https://github.com/RyPeck) made their first contribution in [#​1722](actions/cache#1722) **Full Changelog**: <actions/cache@v5...v5.0.4> ### [`v5.0.3`](https://github.com/actions/cache/releases/tag/v5.0.3) [Compare Source](actions/cache@v5.0.2...v5.0.3) #### What's Changed - Bump `@actions/cache` to v5.0.5 (Resolves: <https://github.com/actions/cache/security/dependabot/33>) - Bump `@actions/core` to v2.0.3 **Full Changelog**: <actions/cache@v5...v5.0.3> ### [`v5.0.2`](https://github.com/actions/cache/releases/tag/v5.0.2): v.5.0.2 [Compare Source](actions/cache@v5.0.1...v5.0.2) ### v5.0.2 #### What's Changed When creating cache entries, 429s returned from the cache service will not be retried. ### [`v5.0.1`](https://github.com/actions/cache/releases/tag/v5.0.1) [Compare Source](actions/cache@v5...v5.0.1) > \[!IMPORTANT] > **`actions/cache@v5` runs on the Node.js 24 runtime and requires a minimum Actions Runner version of `2.327.1`.** > > If you are using self-hosted runners, ensure they are updated before upgrading. *** ### v5.0.1 #### What's Changed - fix: update [@​actions/cache](https://github.com/actions/cache) for Node.js 24 punycode deprecation by [@​salmanmkc](https://github.com/salmanmkc) in [#​1685](actions/cache#1685) - prepare release v5.0.1 by [@​salmanmkc](https://github.com/salmanmkc) in [#​1686](actions/cache#1686) ### v5.0.0 #### What's Changed - Upgrade to use node24 by [@​salmanmkc](https://github.com/salmanmkc) in [#​1630](actions/cache#1630) - Prepare v5.0.0 release by [@​salmanmkc](https://github.com/salmanmkc) in [#​1684](actions/cache#1684) **Full Changelog**: <actions/cache@v5...v5.0.1> ### [`v5.0.0`](https://github.com/actions/cache/releases/tag/v5.0.0) [Compare Source](actions/cache@v5...v5) > \[!IMPORTANT] > **`actions/cache@v5` runs on the Node.js 24 runtime and requires a minimum Actions Runner version of `2.327.1`.** > > If you are using self-hosted runners, ensure they are updated before upgrading. *** #### What's Changed - Upgrade to use node24 by [@​salmanmkc](https://github.com/salmanmkc) in [#​1630](actions/cache#1630) - Prepare v5.0.0 release by [@​salmanmkc](https://github.com/salmanmkc) in [#​1684](actions/cache#1684) **Full Changelog**: <actions/cache@v4.3.0...v5.0.0> ### [`v5`](actions/cache@v4.3.0...v5) [Compare Source](actions/cache@v4.3.0...v5) ### [`v4.3.0`](https://github.com/actions/cache/releases/tag/v4.3.0) [Compare Source](actions/cache@v4.2.4...v4.3.0) #### What's Changed - Add note on runner versions by [@​GhadimiR](https://github.com/GhadimiR) in [#​1642](actions/cache#1642) - Prepare `v4.3.0` release by [@​Link-](https://github.com/Link-) in [#​1655](actions/cache#1655) #### New Contributors - [@​GhadimiR](https://github.com/GhadimiR) made their first contribution in [#​1642](actions/cache#1642) **Full Changelog**: <actions/cache@v4...v4.3.0> ### [`v4.2.4`](https://github.com/actions/cache/releases/tag/v4.2.4) [Compare Source](actions/cache@v4.2.3...v4.2.4) #### What's Changed - Update README.md by [@​nebuk89](https://github.com/nebuk89) in [#​1620](actions/cache#1620) - Upgrade `@actions/cache` to `4.0.5` and move `@protobuf-ts/plugin` to dev depdencies by [@​Link-](https://github.com/Link-) in [#​1634](actions/cache#1634) - Prepare release `4.2.4` by [@​Link-](https://github.com/Link-) in [#​1636](actions/cache#1636) #### New Contributors - [@​nebuk89](https://github.com/nebuk89) made their first contribution in [#​1620](actions/cache#1620) **Full Changelog**: <actions/cache@v4...v4.2.4> ### [`v4.2.3`](https://github.com/actions/cache/releases/tag/v4.2.3) [Compare Source](actions/cache@v4.2.2...v4.2.3) #### What's Changed - Update to use [@​actions/cache](https://github.com/actions/cache) 4.0.3 package & prepare for new release by [@​salmanmkc](https://github.com/salmanmkc) in [#​1577](actions/cache#1577) (SAS tokens for cache entries are now masked in debug logs) #### New Contributors - [@​salmanmkc](https://github.com/salmanmkc) made their first contribution in [#​1577](actions/cache#1577) **Full Changelog**: <actions/cache@v4.2.2...v4.2.3> ### [`v4.2.2`](https://github.com/actions/cache/releases/tag/v4.2.2) [Compare Source](actions/cache@v4.2.1...v4.2.2) #### What's Changed > \[!IMPORTANT] > As a reminder, there were important backend changes to release v4.2.0, see [those release notes](https://github.com/actions/cache/releases/tag/v4.2.0) and [the announcement](actions/cache#1510) for more details. - Bump [@​actions/cache](https://github.com/actions/cache) to v4.0.2 by [@​robherley](https://github.com/robherley) in [#​1560](actions/cache#1560) **Full Changelog**: <actions/cache@v4.2.1...v4.2.2> ### [`v4.2.1`](https://github.com/actions/cache/releases/tag/v4.2.1) [Compare Source](actions/cache@v4.2.0...v4.2.1) #### What's Changed > \[!IMPORTANT] > As a reminder, there were important backend changes to release v4.2.0, see [those release notes](https://github.com/actions/cache/releases/tag/v4.2.0) and [the announcement](actions/cache#1510) for more details. - docs: GitHub is spelled incorrectly in caching-strategies.md by [@​janco-absa](https://github.com/janco-absa) in [#​1526](actions/cache#1526) - docs: Make the "always save prime numbers" example more clear by [@​Tobbe](https://github.com/Tobbe) in [#​1525](actions/cache#1525) - Update force deletion docs due a recent deprecation by [@​sebbalex](https://github.com/sebbalex) in [#​1500](actions/cache#1500) - Bump [@​actions/cache](https://github.com/actions/cache) to v4.0.1 by [@​robherley](https://github.com/robherley) in [#​1554](actions/cache#1554) #### New Contributors - [@​janco-absa](https://github.com/janco-absa) made their first contribution in [#​1526](actions/cache#1526) - [@​Tobbe](https://github.com/Tobbe) made their first contribution in [#​1525](actions/cache#1525) - [@​sebbalex](https://github.com/sebbalex) made their first contribution in [#​1500](actions/cache#1500) **Full Changelog**: <actions/cache@v4.2.0...v4.2.1> ### [`v4.2.0`](https://github.com/actions/cache/releases/tag/v4.2.0) [Compare Source](actions/cache@v4.1.2...v4.2.0) ####⚠️ Important Changes The cache backend service has been rewritten from the ground up for improved performance and reliability. [actions/cache](https://github.com/actions/cache) now integrates with the new cache service (v2) APIs. The new service will gradually roll out as of **February 1st, 2025**. The legacy service will also be sunset on the same date. Changes in these release are **fully backward compatible**. **We are deprecating some versions of this action**. We recommend upgrading to version `v4` or `v3` as soon as possible before **February 1st, 2025.** (Upgrade instructions below). If you are using pinned SHAs, please use the SHAs of versions `v4.2.0` or `v3.4.0` If you do not upgrade, all workflow runs using any of the deprecated [actions/cache](https://github.com/actions/cache) will fail. Upgrading to the recommended versions will not break your workflows. Read more about the change & access the migration guide: [reference to the announcement](actions/cache#1510). ##### Minor changes Minor and patch version updates for these dependencies: - [@​actions/core](https://github.com/actions/core): `1.11.1` - [@​actions/io](https://github.com/actions/io): `1.1.3` - [@​vercel/ncc](https://github.com/vercel/ncc): `0.38.3` **Full Changelog**: <actions/cache@v4.1.2...v4.2.0> ### [`v4.1.2`](https://github.com/actions/cache/releases/tag/v4.1.2) [Compare Source](actions/cache@v4.1.1...v4.1.2) #### What's Changed - Add Bun example by [@​idleberg](https://github.com/idleberg) in [#​1456](actions/cache#1456) - Revise `isGhes` logic by [@​jww3](https://github.com/jww3) in [#​1474](actions/cache#1474) - Bump braces from 3.0.2 to 3.0.3 by [@​dependabot](https://github.com/dependabot) in [#​1475](actions/cache#1475) - Add dependabot.yml to enable automatic dependency upgrades by [@​Link-](https://github.com/Link-) in [#​1476](actions/cache#1476) - Bump actions/checkout from 3 to 4 by [@​dependabot](https://github.com/dependabot) in [#​1478](actions/cache#1478) - Bump actions/stale from 3 to 9 by [@​dependabot](https://github.com/dependabot) in [#​1479](actions/cache#1479) - Bump github/codeql-action from 2 to 3 by [@​dependabot](https://github.com/dependabot) in [#​1483](actions/cache#1483) - Bump actions/setup-node from 3 to 4 by [@​dependabot](https://github.com/dependabot) in [#​1481](actions/cache#1481) - Prepare `4.1.2` release by [@​Link-](https://github.com/Link-) in [#​1477](actions/cache#1477) #### New Contributors - [@​idleberg](https://github.com/idleberg) made their first contribution in [#​1456](actions/cache#1456) - [@​jww3](https://github.com/jww3) made their first contribution in [#​1474](actions/cache#1474) - [@​Link-](https://github.com/Link-) made their first contribution in [#​1476](actions/cache#1476) **Full Changelog**: <actions/cache@v4.1.1...v4.1.2> ### [`v4.1.1`](https://github.com/actions/cache/releases/tag/v4.1.1) [Compare Source](actions/cache@v4.1.0...v4.1.1) #### What's Changed - Restore original behavior of `cache-hit` output by [@​joshmgross](https://github.com/joshmgross) in [#​1467](actions/cache#1467) **Full Changelog**: <actions/cache@v4.1.0...v4.1.1> ### [`v4.1.0`](https://github.com/actions/cache/releases/tag/v4.1.0) [Compare Source](actions/cache@v4.0.2...v4.1.0) #### What's Changed - Fix cache-hit output when cache missed by [@​fchimpan](https://github.com/fchimpan) in [#​1404](actions/cache#1404) - Deprecate `save-always` input by [@​joshmgross](https://github.com/joshmgross) in [#​1452](actions/cache#1452) #### New Contributors - [@​ottlinger](https://github.com/ottlinger) made their first contribution in [#​1437](actions/cache#1437) - [@​Olegt0rr](https://github.com/Olegt0rr) made their first contribution in [#​1377](actions/cache#1377) - [@​fchimpan](https://github.com/fchimpan) made their first contribution in [#​1404](actions/cache#1404) - [@​x612skm](https://github.com/x612skm) made their first contribution in [#​1434](actions/cache#1434) - [@​todgru](https://github.com/todgru) made their first contribution in [#​1311](actions/cache#1311) - [@​Jcambass](https://github.com/Jcambass) made their first contribution in [#​1463](actions/cache#1463) - [@​mackey0225](https://github.com/mackey0225) made their first contribution in [#​1462](actions/cache#1462) - [@​quatquatt](https://github.com/quatquatt) made their first contribution in [#​1445](actions/cache#1445) **Full Changelog**: <actions/cache@v4.0.2...v4.1.0> ### [`v4.0.2`](https://github.com/actions/cache/releases/tag/v4.0.2) [Compare Source](actions/cache@v4.0.1...v4.0.2) #### What's Changed - Fix `fail-on-cache-miss` not working by [@​cdce8p](https://github.com/cdce8p) in [#​1327](actions/cache#1327) **Full Changelog**: <actions/cache@v4.0.1...v4.0.2> ### [`v4.0.1`](https://github.com/actions/cache/releases/tag/v4.0.1) [Compare Source](actions/cache@v4...v4.0.1) #### What's Changed - Update README.md by [@​yacaovsnc](https://github.com/yacaovsnc) in [#​1304](actions/cache#1304) - Update examples by [@​yacaovsnc](https://github.com/yacaovsnc) in [#​1305](actions/cache#1305) - Update actions/cache publish flow by [@​bethanyj28](https://github.com/bethanyj28) in [#​1340](actions/cache#1340) - Update [@​actions/cache](https://github.com/actions/cache) by [@​bethanyj28](https://github.com/bethanyj28) in [#​1341](actions/cache#1341) #### New Contributors - [@​yacaovsnc](https://github.com/yacaovsnc) made their first contribution in [#​1304](actions/cache#1304) **Full Changelog**: <actions/cache@v4...v4.0.1> </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At any time (no schedule defined) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yMTQuNCIsInVwZGF0ZWRJblZlciI6IjQzLjIxNC40IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJkZXBlbmRlbmNpZXMiLCJ0ZW1wbGF0ZSJdfQ==--> Reviewed-on: https://git.lx.e6a.app/tools/cookie-py/pulls/86
Description
process.exitoverwrites the exit code set bycore.setFailed, e.g. the workflow would continue even thoughfail-on-cache-missis 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.0the workflow continues, with this PR it fails as expected (withfail-on-cache-missset).Screenshots (if appropriate):
Types of changes
Checklist: