Skip to content

Commit 637c782

Browse files
authored
Add 'subdirectory' optional input.
1 parent 756399d commit 637c782

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

setup-renv/action.yaml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ author: 'Jim Hester'
44
inputs:
55
profile:
66
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.'
7+
default: 'NULL'
78
cache-version:
89
description: 'The version of the cache, change this from the default (1) to start over with a fresh cache'
9-
required: true
1010
default: 1
1111
bypass-cache:
1212
description: 'Whether attempts to cache should be completely skipped (for non GitHub testing). Set to `true` to skip.'
1313
default: "false"
14+
subdirectory:
15+
description: 'To restore a renv.lock that is not in the repository root, set this to the folder containing the renv.lock to restore from.'
16+
default: '.'
1417
runs:
1518
using: "composite"
1619
steps:
@@ -24,6 +27,7 @@ runs:
2427
if (!requireNamespace("renv", quietly=TRUE)) install.packages("renv")
2528
renv::activate(profile = ${{ inputs.profile }})
2629
shell: Rscript {0}
30+
working-directory: ${{ inputs.subdirectory }}
2731

2832
- name: Get R and OS version
2933
id: get-version
@@ -37,12 +41,13 @@ runs:
3741
uses: actions/cache@v3
3842
with:
3943
path: ${{ env.RENV_PATHS_ROOT }}
40-
key: ${{ steps.get-version.outputs.os-version }}-${{ steps.get-version.outputs.r-version }}-${{inputs.cache-version }}-${{ hashFiles('renv.lock') }}
41-
restore-keys: ${{ steps.get-version.outputs.os-version }}-${{ steps.get-version.outputs.r-version }}-${{inputs.cache-version }}-
44+
key: ${{ steps.get-version.outputs.os-version }}-${{ steps.get-version.outputs.r-version }}-${{ inputs.cache-version }}-${{ hashFiles('${{ inputs.subdirectory }}/renv.lock') }}
45+
restore-keys: ${{ steps.get-version.outputs.os-version }}-${{ steps.get-version.outputs.r-version }}-${{ inputs.cache-version }}-
4246

4347
- name: Install renv dependencies
4448
run: renv::restore()
4549
shell: Rscript {0}
50+
working-directory: ${{ inputs.subdirectory }}
4651

4752
- name: Don't use tar 1.30 from Rtools35 to store the cache
4853
shell: bash

0 commit comments

Comments
 (0)