rstudio / renv

renv: Project environments for R.
https://rstudio.github.io/renv/
MIT License
1.02k stars 155 forks source link

CI vignette: add Bitbucket, review steps #498

Open d-sci opened 4 years ago

d-sci commented 4 years ago

It may be helpful to some to include in the CI vignette an example for bitbucket pipelines.

Here's a prototype similar to the ones provided for other services:

pipelines:
  default:
    - step:
        caches:
          - renvlib
          - renvcache
        script:
          - Rscript -e "if (!requireNamespace('renv', quietly = TRUE)) install.packages('renv')"
          - Rscript -e "renv::restore()"
          - [your next actions here]

definitions:
  caches:
    renvlib: renv/library
    renvcache: ~/.local/share/renv

In actual pipelines that I've written, however, I skipped the if (!requireNamespace('renv', quietly = TRUE)) install.packages('renv') step which you have as an example in all of them. Somewhat related to our discussion regarding the collaboration vignette (#366 ), it seems to me that:

This was a little confusing to me.

kevinushey commented 4 years ago
  • if you checked in .Rprofile and renv/activate.R , the if will always be FALSE, because that will bootstrap everything

I believe you are correct (unless R was launched with --vanilla or --no-init-file, which doesn't appear to be the case here)

  • if you didn't check those in, then renv won't be active yet, so while things may work, you'll be targeting your normal .libPaths()[[1]] instead of renv/library (right?)

That's correct. In this case, I think one would want to explicitly call renv::load(); renv::restore() to ensure that the project infrastructure is loaded before restore.

All that said -- I think the most straightforward way to make sure these things work is to just ensure that the .Rprofile and renv/activate.R scripts are checked in, since then those scripts would automatically make sure the right version of renv is installed and used to load the project.