Skip to content

Commit

Permalink
Add possibility to disable installation of dependencies (#50)
Browse files Browse the repository at this point in the history
* Add possibility to disable installation of dependencies
* Add missing github token

Co-authored-by: Dinakar <26552821+dinakar29@users.noreply.github.com>
  • Loading branch information
knightdave and cicdguy authored Jan 21, 2022
1 parent 5210a1c commit b846500
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Roche

* `no_cache`:

_Description_: Disable github action R dependency caching
_Description_: Disable github action R dependency caching.

_Required_: `false`

Expand All @@ -86,7 +86,15 @@ Roche

_Required_: `false`

_Default_: `v1"`
_Default_: `v1`

* `disable_install_dev_deps`:

_Description_: Disable installation of dev dependencies while building the report.

_Required_: `false`

_Default_: `false`

### Outputs
None
Expand Down
7 changes: 7 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ inputs:
description: "Version of the cache. To clean cache bump this version."
required: false
default: "v1"
disable_install_dev_deps:
description: |
Disable installation of dev dependencies while
building the report.
required: false
default: "false"
branding: # https://feathericons.com/
icon: "award"
color: "blue"
Expand Down Expand Up @@ -96,3 +102,4 @@ runs:
INPUT_REPORT_PKG_DIR: ${{ inputs.report_pkg_dir }}
INPUT_REPORT_TEMPLATE_PATH: ${{ inputs.report_template_path }}
INPUT_REPORT_RMARKDOWN_FORMAT: ${{ inputs.report_rmarkdown_format }}
DISABLE_INSTALL_DEV_DEPS: ${{ inputs.disable_install_dev_deps }}
1 change: 1 addition & 0 deletions dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ lapply(github_packages, remotes::install_github)
# CRAN
options(repos = c("https://cloud.r-project.org/"))
ncores <- parallel::detectCores(all.tests = FALSE, logical = TRUE)
if (!require("git2r")) install.packages("git2r", upgrade = "never", Ncpus = ncores)
if (!require("kableExtra")) install.packages("kableExtra", upgrade = "never", Ncpus = ncores)
if (!require("tinytex")) install.packages("tinytex", upgrade = "never", Ncpus = ncores)

Expand Down
9 changes: 8 additions & 1 deletion report-generator.R
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ cat(sprintf("Current dir is: '%s'", getwd()))
pkg_dir <- normalizePath(Sys.getenv("INPUT_REPORT_PKG_DIR", "."))
template_path <- Sys.getenv("INPUT_REPORT_TEMPLATE_PATH", "/template.Rmd")
report_format <- Sys.getenv("INPUT_REPORT_RMARKDOWN_FORMAT", "all")
disable_install_dev_deps <- tolower(Sys.getenv("DISABLE_INSTALL_DEV_DEPS")) %in% c('yes', 'y', 't', 'true')

# fail with meaningful message if REPORT_PKG_DIR does not appear to be a package
if (!file.exists(file.path(pkg_dir, "DESCRIPTION"))) {
Expand All @@ -23,7 +24,13 @@ if (!file.exists(file.path(pkg_dir, "DESCRIPTION"))) {
}

# Install package dependencies
devtools::install_dev_deps(pkg_dir)
if (!disable_install_dev_deps){
options("remotes.git_credentials" = git2r::cred_user_pass(
username = "token",
password = remotes:::github_pat()
))
devtools::install_dev_deps(pkg_dir, upgrade = "never")
}

# allow rmarkdown to choose appropriate file extension for output format
report_file_path <- rmarkdown::render(
Expand Down

0 comments on commit b846500

Please sign in to comment.