Skip to content

Commit

Permalink
Add extra-packages option
Browse files Browse the repository at this point in the history
  • Loading branch information
jimhester committed Aug 24, 2021
1 parent ba56c01 commit 12ce88d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
6 changes: 5 additions & 1 deletion setup-r-dependencies/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ This action install dependencies for the current R environment based on the DESC

See [action.yml](action.yml)

The only input is `cache-version`, which defaults to 1. If you need to invalidate the existing cache pass any other number and a new cache will be used.
- `cache-version` - default `1`. If you need to invalidate the existing cache pass any other number and a new cache will be used.
- `extra-packages` - One or more extra package references to install. Separate each reference by newlines or commas for more than one package.

Basic:
```yaml
Expand All @@ -23,6 +24,9 @@ steps:
- uses: r-lib/actions/setup-r-dependencies@v1
with:
cache-version: 2
extra-packages: |
ggplot2
rcmdcheck
```
# License
Expand Down
18 changes: 9 additions & 9 deletions setup-r-dependencies/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ inputs:
description: 'The version of the cache, change this from the default (1) to start over with a fresh cache'
required: true
default: 1
extra-packages:
description: 'Any extra packages to install outside of the packages listed in the dependencies'
runs:
using: "composite"
steps:
Expand All @@ -31,19 +33,17 @@ runs:
key: ${{ steps.get-version.outputs.os-version }}-${{ steps.get-version.outputs.r-version }}-${{inputs.cache-version }}-${{ hashFiles('.github/r-depends.rds') }}
restore-keys: ${{ steps.get-version.outputs.os-version }}-${{ steps.get-version.outputs.r-version }}-${{inputs.cache-version }}-

- name: Install system dependencies
- name: Install dependencies
run: |
local_deps <- pak::local_dev_deps(dependencies = TRUE)[["ref"]]
extra_deps <- strsplit("${{ inputs.extra-packages }}", "[[:space:],]+")[[1]]
if (Sys.info()[["sysname"]] == "Linux") {
pak::local_system_requirements(execute = TRUE)
pak::pkg_system_requirements("rcmdcheck", execute = TRUE)
for (dep in extra_deps) {
pak::pkg_system_requirements(dep, execute = TRUE)
}
}
shell: Rscript {0}

- name: Install dependencies
run: |
options(pak.no_extra_messages = TRUE)
pak::local_install_dev_deps(upgrade = TRUE)
pak::pkg_install("sessioninfo")
pak::pkg_install(c(local_deps, extra_deps, "sessioninfo"))
shell: Rscript {0}

- name: Session info
Expand Down

0 comments on commit 12ce88d

Please sign in to comment.