(R env) Update getting Renv package cache location

pull/660/head
Manuel Roth 4 years ago
parent 36fee96435
commit 444a9aa15c

@ -450,53 +450,31 @@ 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$cache()` function is used to get the cache location based on the OS and R version. Look at https://rstudio.github.io/renv/articles/renv.html#cache for more details.
Locations:
- Ubuntu: `~/.cache/R/renv`
- macOS: `~/Library/Caches/org.R-project.R/R/renv`
- Windows: `%LOCALAPPDATA%/R/cache/R/renv`
### Simple example
```yaml
- uses: actions/cache@v2
with:
path: ~/.cache/R/renv
key: ${{ runner.os }}-renv-${{ hashFiles('**/renv.lock') }}
restore-keys: |
${{ runner.os }}-renv-
```
Replace `~/.cache/R/renv` with the correct `path` if not using Ubuntu.
### Multiple OS's in a workflow
```yaml ```yaml
- uses: actions/cache@v2 - name: Install and activate renv
if: startsWith(runner.os, 'Linux') run: |
with: install.packages("renv")
path: ~/.cache/R/renv renv::activate()
key: ${{ runner.os }}-renv-${{ hashFiles('**/renv.lock') }} shell: Rscript {0}
restore-keys: | - name: Get R and OS version
${{ runner.os }}-renv- id: get-version
run: |
- uses: actions/cache@v2 cat("##[set-output name=os-version;]", sessionInfo()$running, "\n", sep = "")
if: startsWith(runner.os, 'macOS') cat("##[set-output name=r-version;]", R.Version()$version.string, sep = "")
with: shell: Rscript {0}
path: ~/Library/Application Support/renv - name: Get renv cache path
key: ${{ runner.os }}-renv-${{ hashFiles('**/renv.lock') }} id: get-renv-cache-path
restore-keys: | run: |
${{ runner.os }}-renv- cat("##[set-output name=renv-cache-path;]", renv::paths$cache(), sep = "")
shell: Rscript {0}
- uses: actions/cache@v2 - name: Restore Renv package cache
if: startsWith(runner.os, 'Windows') uses: actions/cache@v2
with: with:
path: ~\AppData\Local\renv path: ${{ steps.get-renv-cache-path.outputs.renv-cache-path }}
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