You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can we have an option to fail on cache miss? The current behaviour is:
cache hit: restore, exit successfully
cache miss: do not restore, exit successfully
Much of the time, the above makes sense. But there can be workflows where you might want to fail if cache miss. For example, 2 jobs that depend on each other and use cache to move ephemeral artifacts around. We don't want them as formal artifacts, but a cache miss should cause the job to stop.
Right now, you can do it with a little convolution:
- name: update from cacheid: cacheuses: actions/cache@v3with:
path: fookey: some-key
- name: Fail if cache missuses: actions/github-script@v6if: steps.cache.outputs.cache-hit != 'true'with:
script: core.setFailed('Cache hit failed')
That gets unwieldy, especially if it has to be done in a few jobs. The following would be much easier:
- name: update from cacheid: cacheuses: actions/cache@v3with:
path: fookey: some-keyfail_on_miss: true # this, or some similar key
Hi there @deitch, we are planning some changes for users to have granular controls over cache. More info to follow once we have the plan finalised. Thank you for creating this issue, will keep it open for tracking currently.
This looks more like a registry (npm registry/maven repository) pattern, where if the dependency is present in the registry with a required version, the build would succeed, else it would fail saying the version doesn't exist.
Not quite @kotewar , although now that you describe it, the parallels are obvious.
In my use case, we have a long build process that creates output artifacts. These are used in multiple downstream jobs. The build is expensive, so we do it once, then cache, then pull the cache for the many downstream jobs. If they are missing, that is an issue that I want to catch and fail the job there and then, rather than waiting for some "missing artifact" error in the actual job execution.
I looked at using workflow artifacts for this, which would work, but it is a mismatch. These are temporary outputs, useful only within the scope of the workflow. When all of the downstream jobs are done, they should go away.
This is something I've been looking for as well. I know multiple projects which have split dependency install and tests. In one workflow example the pattern is used more than 10 times. It would be awesome if a config setting could be added. That would simplify the jobs a bit.
After spending a couple months and trying to accommodate the asks from multiple users. We have released two new actions that allow users to use restore and save actions individually.
However to also ensure that lot of configuration is not in place, as said by other users in #94 we are trying to avoid use cases that can be handled by the outputs of our current cache action. We still recommend you to continue using the cache-hit output for evaluating the same.
However to also ensure that lot of configuration is not in place, as said by other users in #94 we are trying to avoid use cases that can be handled by the outputs of our current cache action. We still recommend you to continue using the cache-hit output for evaluating the same.
I would disagree. Just skipped through #94 and the way I read it is that users want sensible defaults. I.e. at best just add uses: actions/cache@v3 and everything should work. That was already implemented by a lot of setup-xxx actions. For example the setup-python actions has the cache: "pip" option to do just that. https://github.com/actions/setup-python#caching-packages-dependencies
This doesn't mean though, that advanced use cases can't be made easier as well. In this particular case, users wouldn't need to look at / use exit-on-cache-miss unless they want to, since it would provide a default value which works in most cases.
Activity
lvpx commentedon Oct 13, 2022
Hi there @deitch, we are planning some changes for users to have granular controls over cache. More info to follow once we have the plan finalised. Thank you for creating this issue, will keep it open for tracking currently.
deitch commentedon Oct 13, 2022
That sounds interesting. I rather am looking forward to that.
kotewar commentedon Oct 28, 2022
Hi @deitch ,
This looks more like a registry (npm registry/maven repository) pattern, where if the dependency is present in the registry with a required version, the build would succeed, else it would fail saying the version doesn't exist.
Is that what you are looking for?
deitch commentedon Oct 28, 2022
Not quite @kotewar , although now that you describe it, the parallels are obvious.
In my use case, we have a long build process that creates output artifacts. These are used in multiple downstream jobs. The build is expensive, so we do it once, then cache, then pull the cache for the many downstream jobs. If they are missing, that is an issue that I want to catch and fail the job there and then, rather than waiting for some "missing artifact" error in the actual job execution.
I looked at using workflow artifacts for this, which would work, but it is a mismatch. These are temporary outputs, useful only within the scope of the workflow. When all of the downstream jobs are done, they should go away.
cdce8p commentedon Nov 1, 2022
This is something I've been looking for as well. I know multiple projects which have split dependency install and tests. In one workflow example the pattern is used more than 10 times. It would be awesome if a config setting could be added. That would simplify the jobs a bit.
kotewar commentedon Dec 22, 2022
Hey there 👋🏽
After spending a couple months and trying to accommodate the asks from multiple users. We have released two new actions that allow users to use restore and save actions individually.
However to also ensure that lot of configuration is not in place, as said by other users in #94 we are trying to avoid use cases that can be handled by the outputs of our current cache action. We still recommend you to continue using the
cache-hitoutput for evaluating the same.cdce8p commentedon Dec 22, 2022
Thanks for the update @kotewar!
I would disagree. Just skipped through #94 and the way I read it is that users want sensible defaults. I.e. at best just add
uses: actions/cache@v3and everything should work. That was already implemented by a lot ofsetup-xxxactions. For example thesetup-pythonactions has thecache: "pip"option to do just that. https://github.com/actions/setup-python#caching-packages-dependenciesThis doesn't mean though, that advanced use cases can't be made easier as well. In this particular case, users wouldn't need to look at / use
exit-on-cache-missunless they want to, since it would provide a default value which works in most cases.kotewar commentedon Dec 22, 2022
Hmm, I'll change the category for now to take a better look at such asks. :)
cdce8p commentedon Jan 30, 2023
v3.2.4was just released which adds a new optionto
actions/cacheandactions/cache/restore:fail-on-cache-miss.https://github.com/actions/cache/blob/main/restore/README.md#exit-workflow-on-cache-miss
deitch commentedon Jan 30, 2023
Excellent! Thank you @cdce8p and @kotewar .
Do I need to do anything in actions to ensure it gets this? Or will all
actions/cache/restore@v3invoked after now automatically inherit this?kotewar commentedon Jan 30, 2023
@deitch ,
actions/cache/restore@v3can use this feature using the inputfail-on-cache-miss