/
action.yaml
57 lines (52 loc) · 2.52 KB
/
action.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
name: 'setup-renv'
description: 'Action to setup renv and install R dependencies in the lockfile'
author: 'Jim Hester'
inputs:
profile:
description: 'The renv profile that should be activated. Forwarded to `renv::activate()`. Must be an R expression. Note that it often needs to be quoted in YAML, see the README for details.'
cache-version:
description: 'The version of the cache, change this from the default (1) to start over with a fresh cache'
required: true
default: 1
bypass-cache:
description: 'Whether attempts to cache should be completely skipped (for non GitHub testing). Set to `true` to skip.'
default: "false"
working-directory:
description: 'Using the working-directory keyword, you can specify a subdirectory of the repo where `renv` should be run.'
default: '.'
runs:
using: "composite"
steps:
- name: Set RENV_PATHS_ROOT
shell: bash
run: |
echo "RENV_PATHS_ROOT=${{ runner.temp }}/renv" >> $GITHUB_ENV
- name: Install and activate renv
run: |
if (!requireNamespace("renv", quietly=TRUE)) install.packages("renv")
renv::activate(profile = ${{ inputs.profile }})
shell: Rscript {0}
working-directory: ${{ inputs.working-directory }}
- name: Get R and OS version
id: get-version
run: |
cat("os-version=", sessionInfo()$running, "\n", file = Sys.getenv("GITHUB_OUTPUT"), sep = "", append = TRUE)
cat("r-version=", R.Version()$version.string, "\n", file = Sys.getenv("GITHUB_OUTPUT"), sep = "", append = TRUE)
shell: Rscript {0}
- name: Restore Renv package cache
if: ${{ inputs.bypass-cache != 'true' }}
uses: actions/cache@v4
with:
path: ${{ env.RENV_PATHS_ROOT }}
key: ${{ steps.get-version.outputs.os-version }}-${{ steps.get-version.outputs.r-version }}-${{inputs.cache-version }}-${{ hashFiles(format('{0}/renv.lock', inputs.working-directory)) }}
restore-keys: ${{ steps.get-version.outputs.os-version }}-${{ steps.get-version.outputs.r-version }}-${{inputs.cache-version }}-
- name: Install renv dependencies
run: renv::restore()
shell: Rscript {0}
working-directory: ${{ inputs.working-directory }}
- name: Don't use tar 1.30 from Rtools35 to store the cache
shell: bash
run: |
if command -v /c/Rtools/bin/tar && /c/Rtools/bin/tar --version | grep -q 'tar (GNU tar) 1.30'
then echo 'C:/Program Files/Git/usr/bin' >> $GITHUB_PATH
fi