-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add boolean input variables to reevaluate primary cache key & to only restore (skip save post run) #826
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
* implement only-restore within save
* add regular & proxy server jobs * run job between save & restore jobs to test that only-restore option works with consecutive restores
* also format code with prettier
Add boolean inputs to: * reevaluate cache's primary key * only restore the cache (not save it)
* could be eliminated if primary key is generated differently, e.g. hashing of file paths on reevaluation
* add logic to not save state in restore step when setting `reeval` to true * create infrastructure to set `Inputs.Reeval` input variable within tests * `Inputs.Reeval` set to false for all save & restore tests
Hi @prncevince 👋🏽 We have had a few similar feature requests/ PRs in the past. We are trying to consolidate all such requests and come up with a common solution. Your contribution will definitely help move this request forward. Please allow us some time to circle back on this PR while we evaluate the possible solutions. |
Thanks & Good luck! |
I got a little ambitious with this one. Understand it may never get merged. This tackles a few PRs / issues & topics of conversation all in one:
On the topic of skipping the post run save script, aka only restoring:
only-restore
. Default is set tofalse
.On the topic of reevaluating the primary cache key:
reeval
. Default is set tofalse
.Being that I added new input variables, I had to do quite a bit to get all checks to pass. The goal was adding reevaluation of the primary key during the post run save script as a capability, which was accomplished. In a nut shell, for reevaluation, you need logic to handle when the primary key gets saved to the cache's state. This PR handles doing that.
The jest tests were edited bare minimally to pass. New jest tests were not added for say, testing setting boolean inputs of
only-restore
andreeval
to eithertrue
orfalse
. However, test utilities were added to be able to read these input boolean variables. Also,Inputs.Reeval
was set tofalse
throughout both save and restore jest tests to evaluate save & restore scripts appropriately with the defaultreeval
action input value.The 'Tests' workflow was however changed to begin to handle setting the boolean variables to either.
The new field of
reeval
was added to the job matrix of thetest-save
&test-restore
jobs. In addition, matrices were added to thetest-proxy-save
&test-proxy-restore
jobs to handle this input as well. To differentiate primary keys between matrix runs, a-${{ matrix.reeval }}
partial was appended to these keys.In addition, to handle the
only-restore
case, new jobs oftest-only-restore
&test-proxy-only-restore
were created, each settingreeval
totrue
, and their setting of the primary key follows the convention described above.I created a tag on the main branch of my own repo with these features as well. I've also tested it in quite a few other repos where it's used within composite actions.
Examples using the prncevince/r-actions/setup-knitr-cache composite action:
reeval
set totrue
:only-restore
set totrue
:I also added to the README.md & to examples.md. To the readme I added descriptions of the input variables with their defaults. To the examples I added an example for using knitr caching when rendering R Markdown, as well as detailed explanation of why you would want to use it, with links to examples mentioned above.
A lot of this implementation could be better. I think that the creation of the primary keys during the Tests workflow could be based on an actual file hashing. This could be checked into the repository - say the __test__/__fixtures__/helloWorld.txt). Then, edits to the file could be reflected in the primary key and indeed be tested upon reevaluation.
I'm sure better messaging could be implemented with only restoring (forgoing the post run save script). Not sure that I'm going to pursue this much. Full implementation works right now on my own tag. But if what's requested by reviewers is simple enough for me to have a go to get it merged, I may be interested.
Cheers