-
Notifications
You must be signed in to change notification settings - Fork 216
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
Save a warmed R package cache for faster installs in failing Actions #695
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## v2-branch #695 +/- ##
==========================================
Coverage 83.33% 83.33%
==========================================
Files 3 3
Lines 12 12
==========================================
Hits 10 10
Misses 2 2 ☔ View full report in Codecov by Sentry. |
If the cache is not being updated on a successful Action given a cache hit, I think we should use the This would get rid of the message and gives a clean solution.
** Implementing with Do you know how to save a multiline step output to I'd like to save the cache |
Request to pass the |
@schloerke Thanks for this! Great timing - I was just exploring the same issue. |
The drawback of this is that sometimes the reason for failure is botched packages installation, and we would save a botched cache, that will be potentially picked up across all branches. We have seen this happen for example for mis-specified RSPM repos. So I would be more comfortable if this was opt-in. |
Do you mean that the restore step works, but then the package installation fails? If this is the case, nothing would be saved. Or do you mean that a bad package is installed successfully but during package checking, it fails? In this situation, the bad package would be cached for future restores.
I do not believe a If it can be dynamic, I'm happy with it being opt-in. |
Yes.
You can have alternative cache steps depending on an input parameter. |
Will do!
|
Use a cache keys step to create consistent key and path values. If `cache == 'always'`, use `actions/cache/restore@v3` and `actions/cache/save@v3`. Else use the regular `actions/cache@v3` to restore and save (given Action was successful).
5d92a56
to
6297893
Compare
(Rebased and squashed to remove the long-winded commit history) |
If during packing installation, support was added for removing packages that are installed but not contained within the lock file, then it would fit with this approach nicely. This way, the library would never balloon with unnecessary packages.
|
Will request a review when the PR is stable. Thank you! |
I wonder if it was better and easier to implement this is in pak itself. |
It seems fair to implement it all the way in pkgdepends in the If I can show the PR w/ prune works, I'd be happy to have you relocate it anywhere that makes more sense. |
82fe10c
to
b9cd043
Compare
… only when `cache="always"`
7434095
to
47ee010
Compare
Proof of pruning packages: https://github.com/ggobi/ggally/actions/runs/7905722423/job/21578966735?pr=493#step:3:7274
Proof of not pruning packages: https://github.com/ggobi/ggally/actions/runs/7906986262/job/21583015846?pr=493#step:3:7277
|
@gaborcsardi I'm happy to have you relocate the code to the package you think is best. The addition of pruning packages that are not defined in the lock file makes me feel safe when using a cache that will most likely be restored and should always be saved. This prevents the R library from being poisoned from packages installed from earlier runs. If users do not want to prune the library, they can opt-out. (Pruning only happens when |
* v2-branch: (33 commits) Try to update tinytex Test tinytex version 2024.02 Try installing in tinytex text workflow Upload snapshots in check-release example check-r-package artifact names: include explicit id or job index Include run & attempt number in check-r-package artifact names check-r-package: include arch in artifact name R-devel test: add macos-14 More action version updates Update JamesIves/github-pages-deploy-action version in examples Update actions versions in examples Update setup-tinytex dependencies Update pr-push dependencies Update pr-fetch dependencies Update setup-r dependencies Update setup-pandoc dependencies Update node actions, switch to node 20 Upgrade upload-artifact action Add `working-directory input to `setup-renv` docs Avoid r-project.org URLs ...
fae31a5
to
23fc05b
Compare
23fc05b
to
f974237
Compare
835f496
to
890cb24
Compare
|
Oh, that is awesome! |
Update action.yaml
1dc323a
to
07f7d18
Compare
It is better to implement it in pak.
Thank you! ✅ |
Thank you, and sorry for the long wait! |
@gaborcsardi If you could update the |
Yep, I am preparing a release, either today or tomorrow. |
This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue and include a link to this pull request. |
Goal
When restoring the R package cache, if the primary key is not used, save the currently installed R packages to use as a warmed cache for a followup Action.
If the primary key is used to restore the R package cache, then no secondary cache is saved as there will be a cache hit for followup Actions.
Motivation
actions/cache@v3
is not saved if the Action fails. To me, this is incorrect when installing R packages. The previously installed packages should be available for faster installation in a followup Action.Cons
r-lib/actions/setup-r-dependencies
Other approaches
This was not possible before
actions/cache
had the tagv3
.To remove the cons above, we could
actions/cache/restore@v3
actions/cache/save@v3
However, packages installed outside of
r-lib/actions/setup-r-dependencies
will not be saved with this approach.While not common,
rstudio/shinycoreci
installs packages after the initial dependency installation and would benefit from caching all installed packages when the Action is complete viaactions/cache@v3
.If the Actions are successful, the secondary cache will not be saved or utilized after the initial passing Action.
Example usage
Run actions/cache/save@v3
just beforeRun # Session info
Update: 01/20
Using
actions/cache/restore@v3
andactions/cache/save@v3
to restore and save the package library.Benefit:
Does not capture packages that were installed after the initial installation, but those packages are NOT contained within the cache key. So we should not worry about them.