diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml
index 42eba46..18821cf 100644
--- a/.github/workflows/test.yaml
+++ b/.github/workflows/test.yaml
@@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
name: ${{ matrix.package.name }}
container:
- image: rocker/verse:4.1.1
+ image: rocker/verse:4.1.2
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
strategy:
@@ -35,10 +35,12 @@ jobs:
uses: actions/checkout@v2
- name: Generate validation report for ${{ matrix.package.name }}
+ id: validation
uses: ./
with:
report_pkg_dir: ${{ matrix.package.report_pkg_dir }}
report_template_path: ${{ matrix.package.report_template_path }}
+ report_output_prefix: validation_report
report_rmarkdown_format: ${{ matrix.package.report_rmarkdown_format }}
additional_tlmgr_packages: ${{ matrix.package.additional_tlmgr_packages }}
@@ -47,5 +49,5 @@ jobs:
if: success()
with:
name: ${{ matrix.package.name }} validation report
- path: validation_report.*
+ path: ${{ steps.validation.outputs.report_output_filename }}
if-no-files-found: error
diff --git a/.github/workflows/test_no_cache.yaml b/.github/workflows/test_no_cache.yaml
index e3314ef..4aef1b5 100644
--- a/.github/workflows/test_no_cache.yaml
+++ b/.github/workflows/test_no_cache.yaml
@@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
name: ${{ matrix.package.name }}
container:
- image: rocker/verse:4.1.1
+ image: rocker/verse:4.1.2
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
strategy:
@@ -30,9 +30,11 @@ jobs:
- name: Generate validation report for ${{ matrix.package.name }}
uses: ./
+ id: validation
with:
report_pkg_dir: ${{ matrix.package.report_pkg_dir }}
report_template_path: ${{ matrix.package.report_template_path }}
+ report_output_prefix: validation_report
report_rmarkdown_format: ${{ matrix.package.report_rmarkdown_format }}
no_cache: true
@@ -41,5 +43,5 @@ jobs:
if: success()
with:
name: ${{ matrix.package.name }} validation report
- path: validation_report.*
+ path: ${{ steps.validation.outputs.report_output_filename }}
if-no-files-found: error
diff --git a/Dockerfile b/Dockerfile
deleted file mode 100644
index 9895fa8..0000000
--- a/Dockerfile
+++ /dev/null
@@ -1,15 +0,0 @@
-FROM docker.io/rocker/verse:4.1.1
-
-# Copy validator and template
-COPY report-generator.R /main.R
-COPY template.Rmd /template.Rmd
-COPY dependencies.R /dependencies.R
-
-# Set exec permissions on entrypoint script
-# and dependencies installer.
-# Run the installer
-RUN chmod +x /main.R /dependencies.R && \
- ./dependencies.R
-
-# Set entrypoint
-ENTRYPOINT ["/main.R"]
diff --git a/README.md b/README.md
index 6a2ae51..96b7bbb 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# thevalidatoR
-
+
[](https://pharmaverse.org)
[![SuperLinter](https://github.com/insightsengineering/thevalidatoR/actions/workflows/lint.yaml/badge.svg)](https://github.com/insightsengineering/thevalidatoR/actions/workflows/lint.yaml)
@@ -33,14 +33,16 @@ A Github Action that generates a validation report for an R package. The four ma
- Attach report as object to release
### Action Type
+
Composite
### Author
+
Roche
### Inputs
-* `report_pkg_dir`:
+- `report_pkg_dir`:
_Description_: Path to package's root
@@ -48,7 +50,7 @@ Roche
_Default_: `.`
-* `report_template_path`:
+- `report_template_path`:
_Description_: File path of the R markdown template to use for the report. The default template is available [here.](./template.Rmd)
@@ -56,7 +58,7 @@ Roche
_Default_: `template.Rmd`
-* `report_rmarkdown_format`:
+- `report_rmarkdown_format`:
_Description_: The output format to use when rendering the report. Value is used by `rmarkdown::render`'s `output_format` parameter.
@@ -64,7 +66,15 @@ Roche
_Default_: `pdf_document`
-* `additional_tlmgr_packages`:
+- `report_output_prefix`:
+
+ _Description_: The output filename prefix for the validation report. If left blank, it defaults to the following convention: `--validation-report`.
+
+ _Required_: `false`
+
+ _Default_: `""`
+
+- `additional_tlmgr_packages`:
_Description_: Additional tex packages to install with tlmgr.
@@ -72,7 +82,7 @@ Roche
_Default_: `courier ec`
-* `no_cache`:
+- `no_cache`:
_Description_: Disable github action R dependency caching.
@@ -80,7 +90,7 @@ Roche
_Default_: `false`
-* `cache_version`:
+- `cache_version`:
_Description_: Version of the cache. To clean cache bump this version.
@@ -88,7 +98,7 @@ Roche
_Default_: `v1`
-* `disable_install_dev_deps`:
+- `disable_install_dev_deps`:
_Description_: Disable installation of dev dependencies while building the report.
@@ -97,7 +107,10 @@ Roche
_Default_: `false`
### Outputs
-None
+
+- `report_output_filename`:
+
+ _Description_: Filename of the generated report.
@@ -105,8 +118,8 @@ None
To use this GitHub Action you will need to complete the following:
-* Create a new file in your repository called `.github/workflows/r-pkg-validation.yml`
-* Copy the template over (and edit if you wish to modify it)
+- Create a new file in your repository called `.github/workflows/r-pkg-validation.yml`
+- Copy the template over (and edit if you wish to modify it)
### Quickstart
@@ -138,6 +151,7 @@ jobs:
uses: actions/checkout@v2
- name: Build report 🏗
+ id: validation
uses: insightsengineering/thevalidatoR@main
# see parameters above for custom templates and other formats
@@ -146,14 +160,14 @@ jobs:
if: success()
uses: svenstaro/upload-release-action@v2
with:
- file: ./validation_report.pdf
- asset_name: validation-report.pdf
+ file: ${{ steps.validation.outputs.report_output_filename }}
+ asset_name: ${{ steps.validation.outputs.report_output_filename }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref }}
overwrite: false
```
-### V1.0 Examples
+### V1.0 Examples
#### rbmi
diff --git a/action.yml b/action.yml
index 7aba28d..40acc66 100644
--- a/action.yml
+++ b/action.yml
@@ -19,6 +19,13 @@ inputs:
`output_format` parameter for accepted values.
required: false
default: "all"
+ report_output_prefix:
+ description: >
+ The output filename prefix for the validation report. If left blank,
+ it defaults to the following convention:
+ `--validation-report`.
+ required: false
+ default: ""
additional_tlmgr_packages:
description: |
Additional tex packages to install with tlmgr.
@@ -38,6 +45,10 @@ inputs:
building the report.
required: false
default: "false"
+outputs:
+ report_output_filename:
+ description: Filename of the generated report.
+ value: ${{ steps.report-generator.outputs.output-filename }}
branding: # https://feathericons.com/
icon: "award"
color: "blue"
@@ -86,6 +97,7 @@ runs:
export PATH=${RUNNER_TEMP}/TinyTeX/bin/x86_64-linux:${PATH}
echo "PATH=${PATH}" >> $GITHUB_ENV
tlmgr path add
+ tlmgr update --self
[ ! -f "./template.Rmd" ] && cp ${GITHUB_ACTION_PATH}/template.Rmd . || echo "./template.Rmd Already exists"
shell: bash
@@ -94,7 +106,11 @@ runs:
shell: bash
- name: Run report generator
- run: ${GITHUB_ACTION_PATH}/report-generator.R
+ id: report-generator
+ run: |
+ ${GITHUB_ACTION_PATH}/report-generator.R
+ filename=$(basename $(cat /tmp/report_file_path.txt))
+ echo "::set-output name=output-filename::${filename}"
shell: bash
env:
# Composite action doesn't set inputs as env vars.
@@ -102,4 +118,5 @@ 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 }}
+ INPUT_REPORT_OUTPUT_PREFIX: ${{ inputs.report_output_prefix }}
DISABLE_INSTALL_DEV_DEPS: ${{ inputs.disable_install_dev_deps }}
diff --git a/report-generator.R b/report-generator.R
index d7b3c25..83ad6aa 100755
--- a/report-generator.R
+++ b/report-generator.R
@@ -7,10 +7,14 @@ 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')
+report_output_prefix <- Sys.getenv("INPUT_REPORT_OUTPUT_PREFIX", "")
+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"))) {
+desc_file <- file.path(pkg_dir, "DESCRIPTION")
+if (!file.exists(desc_file)) {
stop(sprintf(
paste(sep = "\n",
"Could not find package at '%s'",
@@ -24,7 +28,7 @@ if (!file.exists(file.path(pkg_dir, "DESCRIPTION"))) {
}
# Install package dependencies
-if (!disable_install_dev_deps){
+if (!disable_install_dev_deps) {
options("remotes.git_credentials" = git2r::cred_user_pass(
username = "token",
password = remotes:::github_pat()
@@ -32,13 +36,26 @@ if (!disable_install_dev_deps){
devtools::install_dev_deps(pkg_dir, upgrade = "never")
}
+# Set the output file name
+if (report_output_prefix == "") {
+ desc <- read.dcf(desc_file)
+ pkg_name <- toString(desc[, "Package"])
+ pkg_version <- toString(desc[, "Version"])
+ report_output_prefix <- paste0(
+ pkg_name, "-", pkg_version, "-validation-report"
+ )
+}
+
# allow rmarkdown to choose appropriate file extension for output format
report_file_path <- rmarkdown::render(
template_path,
output_dir = getwd(), # create report wherever R script was called
- output_file = "validation_report",
+ output_file = report_output_prefix,
output_format = report_format,
params = list(pkg_dir = pkg_dir)
)
-cat(sprintf("Created report at: '%s'", report_file_path))
+# Create a tmp file which contains the final report filename
+writeLines(report_file_path, "/tmp/report_file_path.txt")
+
+cat(sprintf("Created report at: '%s'\n\n", report_file_path))
diff --git a/template.Rmd b/template.Rmd
index c076083..51d4a69 100644
--- a/template.Rmd
+++ b/template.Rmd
@@ -66,7 +66,7 @@ documentation of the installation of this package on an open source R environmen
- Traceability matrix of specifications (documented behaviours) and testing
- Risk assessment benchmarks
-This report is fully automated, so is limited to assess whether unit tests and documentation are present and can execute without error. An assessment would be required that the tests and documentation are meaningful. Validation is system dependent, so specific to the validation environment environment used by this gh-action (see `https://github.com/insightsengineering/thevalidatoR/blob/main/Dockerfile` for the base dockerfile, and details in this document for the session info).
+This report is fully automated, so is limited to assess whether unit tests and documentation are present and can execute without error. An assessment would be required that the tests and documentation are meaningful. Validation aims to be system independent as the underlying workflow is based on the ["composite"](https://docs.github.com/en/actions/creating-actions/creating-a-composite-action) type of Github Action.
# Installation environment and package