rstudio / renv

renv: Project environments for R.
https://rstudio.github.io/renv/
MIT License
986 stars 153 forks source link

Package development & continuous integration #1910

Open shug0131 opened 2 months ago

shug0131 commented 2 months ago

There should be advice on best practice for CI when developing a package whilst using renv locally.

https://rstudio.github.io/renv/articles/ci.html

Just says "don't do this" but doesn't say what you should do.

https://rstudio.github.io/renv/articles/packages.html doesn't offer much advice either when you want to use github/CI

I think I'd want to mirror the renv, .Rprofile, files used locally onto github; so I can work in two physical locations and PCs. But I want to make sure the CI in a github workflow then ignores them and uses the most recent package versions as if it were on CRAN. I think then the .Rbuildignore may achieve this (I'll try this out next). But I could remove all renv-related files on github with .gitignore, but this would not be ideal.

Happy to be corrected, though and told what to do.

shug0131 commented 1 month ago

Editing .Rbuildignore to have

^.Rrofile$

Helps, but still the github actions run any .Rprofile file and run into problems. A solution is to modify the .Rprofile into

if(Sys.getenv("GITHUB_ACTIONS")!="true"){
  source("renv/activate.R")
}

So that it is ignored within github actions.

kevinushey commented 2 weeks ago

Sorry for the late response. I think there's some open questions on what the best approach is:

In any event, I'm definitely open to improving the documentation -- I'm just not sure what that documentation should be.

shug0131 commented 2 weeks ago

I think using the step in (https://rstudio.github.io/renv/articles/ci.html#using-the-github-actions-cache-with-renv) would work correctly the first time it is run in github actions, but then it would be stuck with those versions of all packages, and eventually break as the version of R advances in github. I've not tried it though.

Giving the user the option to leave github actions to check for CRAN, using latest versions of everything, makes a lot of sense to me, in which case it wants to disable renv totally. Hence the modified .Rprofile seems to achieve this well.