Skip to content
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

Enable cache clear by adding a version prefix to the key #86

Closed
yutannihilation opened this issue Apr 19, 2020 · 6 comments
Closed

Enable cache clear by adding a version prefix to the key #86

yutannihilation opened this issue Apr 19, 2020 · 6 comments

Comments

@yutannihilation
Copy link
Contributor

Unlike Travis CI and AppVeyor, GitHub Actions doesn't provide a way to clear cache. In such a situation, it seems it's a common practice to add a version prefix to the key as Circle CI suggests so:

Tip: Caches are immutable so it is useful to start all your cache keys with a version prefix, for example v1-.... This enables you to regenerate all of your caches by incrementing the version in this prefix.
(https://circleci.com/docs/2.0/caching/#clearing-cache)

I followed this on ggplot2: tidyverse/ggplot2@644c436

lcolladotor added a commit to leekgroup/derfinderPlot that referenced this issue Apr 20, 2020
…ly a workaround. Add conditional caching. Could be a solution to r-lib/actions#86
lcolladotor added a commit to LieberInstitute/recount3 that referenced this issue Apr 20, 2020
lcolladotor added a commit to LieberInstitute/recount3 that referenced this issue Apr 20, 2020
…ssing-commit-message-in-pull-request-event/m-p/42138#M4879 though (if it works) it worn't clear the cache as requested in r-lib/actions#86. I see that it's a highly requested feature at actions/cache#2
@lcolladotor
Copy link
Contributor

Hi @yutannihilation,

I found that if you edit the if condition for the step that caches, you can skip the cache step. That way you can test things without your cached R packages. However, you can't clear the cache. Clearing seems to be a highly requested feature upstream of r-lib/actions at actions/cache#2.

That is, edit check-standard.yaml#L45-L46 from

- name: Cache R packages
  if: runner.os != 'Windows'

to something like this (you can keep the Windows part inside the if statement if you want):

- name: Cache R packages
  if: "!contains(github.event.head_commit.message, '/nocache')"

which is what I did at check-bioc.yml#L91. You can see at the GHA logs here that on a commit with the word /nocache on the commit message (such as LieberInstitute/recount3@0cb70fa) correctly skipped the caching step.

I ran into the need for something like this myself to avoid making mistakes like at r-lib/xml2#296 (comment) where I thought I had resolved my macOS issue with compiling xml2, but it was simply due to having the package already cached (after using Rscript -e "remotes::install_github('r-lib/xml2')" successfully in a previous run). I discovered the issue when I copied the GHA workflow to a new package which I initially suspected would be an issue after discovering this r-lib/xml2#296 (comment). Hence my family of commits like leekgroup/derfinderHelper@0a7f5e7.

Best,
Leo

@jimhester
Copy link
Member

Bumping the cache by adding a number like @yutannihilation suggests is the correct solution. I normally just append a -2- to the cache myself, e.g. this is how I bumped the cache recently in xml2 r-lib/xml2@6baece5.

@hadley
Copy link
Member

hadley commented Apr 21, 2020

I think clearing the cache is such an important action that GitHub is bound to implement it in the near future, so I think it's premature to design anything into r-lib/actions at this point.

@yutannihilation
Copy link
Contributor Author

GitHub is bound to implement it in the near future

Not allowing cache clear can be a design choice (as I described above, Circle CI is an example). That said, I'm not sure how GitHub will handle this popular feature request, so I agree it's better to wait for some months before considering implementing this on r-lib/actions' side.

Anyway, in the meantime, we can use this issue to share the tips like @lcolladotor's one. Hope this helps those who struggle with cache.

@jimhester
Copy link
Member

The workflows now have a -1- suffix to hopefully make it more clear what you have to bump (if needed).

Robinlovelace added a commit to geocompx/geocompr that referenced this issue May 2, 2020
lcolladotor added a commit to lcolladotor/biocthis that referenced this issue May 9, 2020
Created both an introductory and a developer's notes vignette, updated README
and docs with examples, added a second biocViews term, fixed some small
bugs/typos.

Related links (as many as I could remember):

* https://rstd.io/tidytools19
* https://twitter.com/CVWickham
* https://twitter.com/hadleywickham
* https://www.rstudio.com/products/rstudio/download
* https://comunidadbioinfo.github.io/post/building-tidy-tools-cdsb-runconf-2019/#.XrbLMxNKiu4
* http://bioconductor.org/
* https://lcolladotor.github.io/pkgs/
* https://stat.ethz.ch/pipermail/bioc-devel/2020-March/016365.html
* https://www.bioconductor.org/help/docker/
* https://stat.ethz.ch/pipermail/bioc-devel/2020-April/016532.html
* https://github.com/features/actions
* https://stat.ethz.ch/pipermail/bioc-devel/2020-April/016650.html
* r-lib/actions#84
* r-lib/usethis#1108
* r-lib/styler#636
* Bioconductor/BiocCheck#57
* Bioconductor/bioconductor.org#54
* http://bioconductor.org/developers/how-to/coding-style/
* https://style.tidyverse.org/
* https://twitter.com/lorenzwalthert
* https://twitter.com/mt_morgan
* https://docs.travis-ci.com/user/languages/r/
* r-lib/pkgdown#1206
* r-lib/pkgdown#1230
* https://twitter.com/jimhester_
* https://www.jimhester.com/talk/2020-rsc-github-actions/
* https://github.com/Bioconductor/BBS
* https://github.com/Bioconductor/packagebuilder
* https://www.appveyor.com/
* r-hub/rhub#52
* r-hub/rhub#38
* https://www.tidyverse.org/blog/2020/04/usethis-1-6-0/
* https://github.com/r-lib/actions/tree/master/examples
* https://yihui.org/en/2018/03/second-pull-request/
* https://github.com/r-lib/actions/blob/master/examples/check-standard.yaml
* https://help.github.com/en/actions
* https://ropenscilabs.github.io/actions_sandbox/
* https://twitter.com/seandavis12
* https://github.com/seandavi/BiocActions/blob/master/.github/workflows/main.yml
* https://twitter.com/CSoneson
* https://github.com/csoneson/dreval/blob/master/.github/workflows/R-CMD-check.yaml
* https://bioc-community.herokuapp.com/
* https://github.com/leekgroup/derfinderPlot/blob/master/.github/workflows/check-bioc.yml
* https://github.com/LieberInstitute/recount3/blob/master/.github/workflows/check-bioc.yml
* https://github.com/hpages
* r-lib/actions#68
* r-lib/actions#85
* https://twitter.com/opencpu
* https://community.rstudio.com/u/const-ae
* https://community.rstudio.com/t/compiler-support-fo-c-14-features-on-windows/57284/4
* r-lib/xml2#296
* r-lib/xml2#302
* https://github.com/r-lib/usethis/blob/master/.github/workflows/R-CMD-check.yaml
* https://github.com/r-lib/usethis/commits/master/.github/workflows/R-CMD-check.yaml
* https://stat.ethz.ch/pipermail/bioc-devel/2020-April/016703.html
* https://stat.ethz.ch/pipermail/bioc-devel/2020-April/thread.html
* r-lib/remotes#296
* r-lib/actions#86
* r-lib/covr#427
* https://github.com/r-lib/actions/blob/master/examples/pr-commands.yaml
* https://www.digitalocean.com/community/tutorials/how-to-install-git-on-ubuntu-18-04
* r-lib/actions#50
* actions/checkout#238
* https://github.com/rocker-org/rocker-versioned2/blob/master/dockerfiles/Dockerfile_rstudio_4.0.0-ubuntu18.04
* https://twitter.com/niteshturaga
* https://twitter.com/cboettig
* rocker-org/rocker-versioned#208
* https://github.community/t5/GitHub-Actions/bd-p/actions
* https://www.r-consortium.org/blog/2020/03/18/cdsb-diversity-and-outreach-hotspot-in-mexico
* https://github.com/maxheld83
* r-lib/actions#87
* https://github.com/yutannihilation
famuvie added a commit to VABAR/vibass that referenced this issue Jul 8, 2021
pdil added a commit to pdil/usmap that referenced this issue Sep 4, 2021
This should prevent issues with R CMD check on ubuntu.
See r-lib/actions#86.
@github-actions
Copy link

github-actions bot commented Nov 8, 2022

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue and include a link to this issue

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants