(R renv) Fix Renv package cache location in examples (#660)

* (R renv) Fix Renv package cache location in examples

* (R env) Update getting Renv package cache location

* (R env) Set renv package cache location using RENV_PATHS_ROOT environment variable
pull/663/head
Manuel Roth 3 years ago committed by GitHub
parent 6bbe742add
commit 92f67a4829
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -450,53 +450,35 @@ jobs:
## R - renv ## R - renv
For renv, the cache directory will vary by OS. Look at https://rstudio.github.io/renv/articles/renv.html#cache For renv, the cache directory will vary by OS. The `RENV_PATHS_ROOT` environment variable is used to set the cache location. Have a look at https://rstudio.github.io/renv/reference/paths.html#details for more details.
Locations:
- Ubuntu: `~/.local/share/renv`
- macOS: `~/Library/Application Support/renv`
- Windows: `%LOCALAPPDATA%/renv`
### Simple example
```yaml
- uses: actions/cache@v2
with:
path: ~/.local/share/renv
key: ${{ runner.os }}-renv-${{ hashFiles('**/renv.lock') }}
restore-keys: |
${{ runner.os }}-renv-
```
Replace `~/.local/share/renv` with the correct `path` if not using Ubuntu.
### Multiple OS's in a workflow
```yaml ```yaml
- uses: actions/cache@v2 - name: Set RENV_PATHS_ROOT
if: startsWith(runner.os, 'Linux') shell: bash
with: run: |
path: ~/.local/share/renv echo "RENV_PATHS_ROOT=${{ runner.temp }}/renv" >> $GITHUB_ENV
key: ${{ runner.os }}-renv-${{ hashFiles('**/renv.lock') }} - name: Install and activate renv
restore-keys: | run: |
${{ runner.os }}-renv- install.packages("renv")
renv::activate()
- uses: actions/cache@v2 shell: Rscript {0}
if: startsWith(runner.os, 'macOS') - name: Get R and OS version
with: id: get-version
path: ~/Library/Application Support/renv run: |
key: ${{ runner.os }}-renv-${{ hashFiles('**/renv.lock') }} cat("##[set-output name=os-version;]", sessionInfo()$running, "\n", sep = "")
restore-keys: | cat("##[set-output name=r-version;]", R.Version()$version.string, sep = "")
${{ runner.os }}-renv- shell: Rscript {0}
- name: Get renv cache path
- uses: actions/cache@v2 id: get-renv-cache-path
if: startsWith(runner.os, 'Windows') run: |
cat("##[set-output name=renv-cache-path;]", renv::paths$cache(), sep = "")
shell: Rscript {0}
- name: Restore Renv package cache
uses: actions/cache@v2
with: with:
path: ~\AppData\Local\renv path: ${{ env.RENV_PATHS_ROOT }}
key: ${{ runner.os }}-renv-${{ hashFiles('**/renv.lock') }} key: ${{ steps.get-version.outputs.os-version }}-${{ steps.get-version.outputs.r-version }}-${{ inputs.cache-version }}-${{ hashFiles('renv.lock') }}
restore-keys: | restore-keys: ${{ steps.get-version.outputs.os-version }}-${{ steps.get-version.outputs.r-version }}-${{inputs.cache-version }}-
${{ runner.os }}-renv-
``` ```
## Ruby - Bundler ## Ruby - Bundler

Loading…
Cancel
Save