Skip to content

Commit

Permalink
Add 'subdirectory' optional input.
Browse files Browse the repository at this point in the history
  • Loading branch information
Skenvy authored Aug 18, 2023
1 parent 756399d commit 637c782
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions setup-renv/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@ 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.'
default: 'NULL'
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"
subdirectory:
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.'
default: '.'
runs:
using: "composite"
steps:
Expand All @@ -24,6 +27,7 @@ runs:
if (!requireNamespace("renv", quietly=TRUE)) install.packages("renv")
renv::activate(profile = ${{ inputs.profile }})
shell: Rscript {0}
working-directory: ${{ inputs.subdirectory }}

- name: Get R and OS version
id: get-version
Expand All @@ -37,12 +41,13 @@ runs:
uses: actions/cache@v3
with:
path: ${{ env.RENV_PATHS_ROOT }}
key: ${{ steps.get-version.outputs.os-version }}-${{ steps.get-version.outputs.r-version }}-${{inputs.cache-version }}-${{ hashFiles('renv.lock') }}
restore-keys: ${{ steps.get-version.outputs.os-version }}-${{ steps.get-version.outputs.r-version }}-${{inputs.cache-version }}-
key: ${{ steps.get-version.outputs.os-version }}-${{ steps.get-version.outputs.r-version }}-${{ inputs.cache-version }}-${{ hashFiles('${{ inputs.subdirectory }}/renv.lock') }}
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.subdirectory }}

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

0 comments on commit 637c782

Please sign in to comment.