-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add skip-save feature #571
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
Conversation
@dhadka Please take a look at this. It implements the "skip-save" idea that you had. Testing is here: https://github.com/eyal0/test-cache/runs/2406514627?check_suite_focus=true If you look at the log of the CI, you'll see that
and
This should fix up a lot of the issues that were filed. One thing that it won't fix is forcing a save even when CI fails. That was the request in #92. It had 72 users that want this feature so, you know, kind of popular! What to do about this? My #498 could partially solve this because it has the "always/never" mechanic where you can specify that you want to force a save, even if there is a failure! We would just remove the What are your thoughts? Seems like it would be important to get this right the first time, rather than modify the API to caching many more times! |
The skip-save option allows users to force the cache to skip saving the cache. skip-save can be set to a constant or to an expression that will be evaluated at the end of the CI job, such as an environment variable. This is for actions#498
Maybe skip-save should have no default value and the code can detect this and perform the default behavior. And when skip-save is false then it will always save, like was wanted in #92? And when true, then it'll skip the save, like the other issues requested. That makes skip-save a tri-state variable, though: true, false, and default. What's worse, it has a sort of negative logic where true means don't save and false means "do save. So true means no and false means yes. 😞 This is going to be confusing for people, I'm certain. Anyway, we could leave it as-is and have the default for What do you think is the best solution? |
@eyal0 Thanks for putting this together! I'm out this week but CC'ing @konradpabjan for review. |
I vote for |
This fixes #272 |
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.
Thanks for the PR @eyal0 !
I really like the direction of this PR!
A few things
- What's up with
package-lock.json
having so many changes? - Documentation would be great! A few updates to
README.md
would go a long way in terms of documenting how to use this
In terms of naming, I think skip-save
is good 👍
action.yml
Outdated
description: 'The chunk size used to split up large files during upload, in bytes' | ||
required: false | ||
skip-save: | ||
description: 'Whether or not to skip the saving of the cache. If this is set to "true", the cache will not be saved. It can also be set to an evironment variable such as "\$\{\{ env.MY_SKIP_SAVE \}\}". If the MY_SKIP_SAVE environment variable is "true" by the end of the CI, caching will be skipped. Default is to update if and only if there was no primary-key exact cache hit.' |
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.
Since this comment is really long, can you use >
to split it up so it's more readable.
Here is an example: https://github.com/actions/checkout/blob/25a956c84d5dd820d28caab9f86b8d183aeeff3d/action.yml#L12-L24
It's some npm thing I guess? I don't know much about node.js package management. I think that when I typed Documentation is a good idea, for sure. I'll do that. What do you think about #571 (comment) and #92? this is a place where it probably doesn't make sense to have an incremental solution. We don't want to release a new parameter, modifying the API, and then have to do it again! Better to get it right the first time. The concerns in #92 seem totally reasonable and this PR will definitely not address them. I think that a better way to think about this PR is not just how to fix the problem but rather, to think about: How do we want the API to behave? |
I think this is because |
It looks like eyal0 is using NPM 7, which has upgraded the package-lock.json to "lockfileVersion: 2" format. The installed package versions are the same as the ones in the current lock file. The PR doesn't modify the package.json, so it should be safe to discard the changes to package-lock.json. |
Co-authored-by: David Hadka <[email protected]>
I think that I've addressed all comments. In order to keep the commit history, I haven't rebased. If you want, rebase and squash. |
(I still worry about #92 . That is a reasonable request and we haven't left room to fix it here.) |
Just thinking of options to unify this and #92... If we offered separate save and restore steps, we could essentially move the Always save cache:
Skip saving if env var set (or any other valid expression):
Other useful scenarios I can think of are:
@eyal0 thoughts on this approach? (We'd of course continue to offer the current action in its current form for those that just need the default behavior. This approach has some downsides like needing to specify the path / key in both steps, maintaining multiple actions, more burden on users to figure out the correct setup, etc. There are also some implementation details we'd need to think about...the Action currently passes some info from the restore to the save step using state variables, and we'd need to see if and how that's affected when the Action is split into separate steps.) |
The recent surge in misuse of actions by malicious third parties has highlighted the importance of a security first approach to actions, as has been described by the GitHub Security Lab in Keeping your GitHub Actions and workflows secure: Untrusted input:
The simple and convenient read + write nature of |
@dhadka Small edit to your first example to add multiple restore keys:
I think splitting the action up would make the key configuration clearer. The restore action would have a simple list of keys to try in order, while the save action only has a single key. Perhaps actions/cache-restore would need to output the matched key so that actions/cache-save could be skipped when the key didn't change. |
I dunno... For me, I just need somewhere to store and load files, you know? If the action cache were just an FTP server where I could upload and download files and it had a some quota on how many files each user project could store, that'd be fine. All this discussion about how to skip saving or force saving or the inability to overweight files, it's all just users that want to get basic stuff that a file server could do but access is difficult because actions/cache is an API to a file server that is very opinionated about how things should be stored, with primary keys and restore keys and no overwriting and the like. So if the interface is going to change, just make the action behave like an FTP server where every project gets a little storage. FTP is already well understood and tested. And if people have a strong opinion about how to implement caching on top of an FTP server, cool. Let them right their own actions on top of it. Anyway, my two cents. I get that there might be all sorts of business reasons why GitHub didn't just say: "Hey, here's an FTP server that you can use for you project, up to 5GB. Go ahead and build your own stuff on top of it, like a cache or whatever." Maybe there's a good reason why it isn't like that. |
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.
Looking forward to have this PR merged. Is there anything I can do to help get this in action:main ?
Hey, |
Any update on this pull request? |
Nothing changed, I had to fork and made development for myself |
Related to #795 |
I prefer the other way with the update-env-variable so I'll close this one and instead work on this: #498 I think that it's better. |
Hey all, 👋🏽 We have created a discussion with a proposal that will solve this problem, do let us know your feedback, thanks 😊 |
The skip-save option allows users to force the cache to skip saving the cache. skip-save can be set to a constant or to an expression that will be evaluated at the end of the CI job, such as an environment variable.
This is for #498