-
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
Add option to re-evaluate cache key during post action #673
base: main
Are you sure you want to change the base?
Conversation
ab72bcf
to
996530d
Compare
Hi @TimoRoth
|
No, it would just store the cache under a different key than the one it downloaded initially.
This option only really makes sense in combination with a sensible restore-key. As long as nothing changes, the list of files will be the same, and the same cache key will be generated, and nothing will be uploaded. If you do not have a restore-key, you might never get a cache hit and the whole thing is pointless. |
To elaborate a bit on why we need that: So we need a way to update the cache whenever the set of files it downloaded changed, but we only know that after it has finished running. Re-Evaluating the cache key at post is the easiest way I found to achieve that. |
Thank you for the context. As you understand, this is not a very common use case. The action might behave in unexpected ways if the cache key changes within the same workflow. Today, the cache key used while restoring the cache is explicitly saved in the state to be used again in the post action step as you see in the comment here. This makes me skeptical of re-evaluating the cache key. I will try to gather more context about the importance of keeping the cache key same throughout the workflow and get back to you if I learn anything more. Based on my understanding so far, I am not sure if we should go ahead with this change. |
On 07.10.2022 15:04, Aparna Ravindra wrote:
Thank you for the context. As you understand, this is not a very common
use case. The action might behave in unexpected ways if the cache key
changes within the same workflow. Today, the cache key used while
restoring the cache is explicitly saved in the state to be used again in
the post action step as you see in the comment here
<https://github.com/actions/cache/blob/a3f5edc2378b2e43203912210dc88effa160f032/src/save.ts#L29>.
It doesn't seem that unusual to me really.
There's a lot of situations where you want to cache something that's not
already known before you run your build.
This makes me skeptical of re-evaluating the cache key. I will try to
gather more context about the importance of keeping the cache key same
throughout the workflow and get back to you if I learn anything more.
Based on my understanding so far, I am not sure if we should go ahead
with this change.
At least in our case, we've been using the action with this PR applies
for a rather long time now (even before the PR was created) and never
had any issues.
So it's at least not completely broken.
I could see there being some corner cases where it misbehaves, but
catching those and throwing an error should be possible.
|
Being able to make a key based on the contents of the cache would be very valuable. Docs change: #1283 |
We're having a situation where we don't know in advance which files will need cached.
As in, the list of files is only known once the files are actually there.
This change adds an optional option which explicitly re-evaluates the Cache-Key in the post action, so it can get the latest hash, or whatever else determines the key.
Update of actions/core was done to get access to getBooleanInput().