-
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
Allow optionally refreshing existing cache entries. #1096
base: main
Are you sure you want to change the base?
Conversation
Due to the conflict in README., I just noticed I haven't updated the granular save action, will fix that now. |
b5d67da
to
ea4b956
Compare
Personally, I'd love this option. However, just from working the the cache API myself I noticed permission issues with deleting cache entries. For example the normal Unfortunately, that might be a dealbreaker with that approach. |
I have tested it from a EDIT: You can see exactly that outcome in here: https://github.com/Lord-Kamina/actions-cache-update/actions/runs/4144733484/jobs/7168158463 Now... there are few scenarios I can think of when you would want an external PR to be able to manipulate your existing cache. The main one would be a project developer doing work on their personal fork and then submitting it as a PR. In this scenario, the limitation could likely be circumvented by using a PAT instead, no? |
ea4b956
to
351dc22
Compare
I have rebased this on main, as well as corrected a couple errors and added a way to update an existing cache even if using the granular save action (uses a lookup to see if the key exists) |
351dc22
to
7755eb5
Compare
Signed-off-by: Gregorio Litenstein <g.litenstein@gmail.com>
Signed-off-by: Gregorio Litenstein <g.litenstein@gmail.com>
7755eb5
to
6e0386c
Compare
Hey everyone... I've been using this branch pretty much since I posted it way back when, without many issues. I recently realized there was a bug in my logic and have corrected it, as well as updated and rebased it. Is there any chance this could get merged now? |
6e0386c
to
a25a486
Compare
Signed-off-by: Gregorio Litenstein <g.litenstein@gmail.com>
And rebuild. Signed-off-by: Gregorio Litenstein <g.litenstein@gmail.com>
a25a486
to
4043ab8
Compare
Note: CI runs on my fork are all good except for some reason prettier is complaining but only on windows, which I can't reproduce because I'm on mac. The workflow logs don't really give details either as to what the issue actually is. |
Description
By enabling an optional input, this feature allows users to update existing cache keys. The way this can be done is by using Octokit to send a request to the Github API to delete the matched cache. This then allows the key to be reused and the save step to operate as if there hadn't been a match in the first place.
Motivation and Context
Pretty much since forever, people have been asking for a way to update existing cache entries. As of now, the best alternative is to just create a slightly different key each time, which would rapidly consume space.
#1093
How Has This Been Tested?
I have written tests to test the functionality. They:
Test the
deleteCacheByKey
function in three scenarios: A successful and an unsucessful request (using MSW to mock the Github API), as well as a real request to the API, which is expected to return a 401 error because it uses a bogus token.Test the
run
function in the scenarios of refresh-cache being enabled, but not being provided an API token, as well as a successful scenario in which it would attempt to delete the existing cache, and then reupload it.Screenshots (if appropriate):
Types of changes
Checklist: