Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Quarto and Typst to render the validation report #71

Merged
merged 68 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
00710f7
Update
walkowif Apr 23, 2024
654bf09
Update
walkowif May 6, 2024
71d8609
Update
walkowif May 6, 2024
e21c50d
Update
walkowif May 6, 2024
9191ea2
Update
walkowif May 6, 2024
7e1c223
Update
walkowif May 6, 2024
43e4123
Update
walkowif May 6, 2024
b6be622
Remove all latex references
cicdguy May 7, 2024
869238f
Update
walkowif May 7, 2024
d28578a
Don't use knitr and kableExtra
walkowif May 7, 2024
c44f5a3
Update
walkowif May 7, 2024
b7f8df1
Update
walkowif May 7, 2024
d36d0dc
Update
walkowif May 7, 2024
9c8b5ab
Update
walkowif May 7, 2024
b0a0e6e
Update
walkowif May 7, 2024
0d337d2
Update
walkowif May 7, 2024
fad3c44
Update
walkowif May 7, 2024
ed70454
Update
walkowif May 7, 2024
a7e677c
Update
walkowif May 7, 2024
09023d1
Update
walkowif May 7, 2024
c07159a
Try to use rtables
walkowif May 7, 2024
3447f0f
Revert "Try to use rtables"
walkowif May 7, 2024
ceea37f
Revert "Revert "Try to use rtables""
walkowif May 7, 2024
0560a8f
Use rtables
walkowif May 7, 2024
9f7fa08
Update
walkowif May 7, 2024
bc90cec
Update
walkowif May 7, 2024
a1773ca
Update
walkowif May 7, 2024
e39ad58
df-print: kable
walkowif May 7, 2024
359fef0
Update
walkowif May 8, 2024
c320e24
Update
walkowif May 8, 2024
cd29a97
Update
walkowif May 8, 2024
1105442
Update
walkowif May 8, 2024
1831e62
Update
walkowif May 8, 2024
53842f1
Make table breakable
walkowif May 8, 2024
d3d8546
Escape backticks
walkowif May 8, 2024
d6924a3
Escape backticks
walkowif May 8, 2024
cad30f3
Move mutate
walkowif May 8, 2024
c414417
Set margin
walkowif May 8, 2024
a803d31
Update
walkowif May 8, 2024
9541c0c
Typo
walkowif May 8, 2024
2819ced
Cleanup
walkowif May 8, 2024
ad9aa26
Update
walkowif May 8, 2024
1cb5ce0
Fix failing test
walkowif May 8, 2024
5c4d150
Try using tinytable
walkowif May 9, 2024
6b61132
Try using tinytable
walkowif May 9, 2024
aee37e2
Try using tinytable
walkowif May 9, 2024
a616436
Update R image
walkowif May 9, 2024
5727989
Cleanup
walkowif May 9, 2024
232eaa6
Update
walkowif May 9, 2024
2f4a942
Update
walkowif May 9, 2024
9471d96
Update
walkowif May 9, 2024
8a46ca2
Update
walkowif May 9, 2024
e7a81dc
Update
walkowif May 9, 2024
d4b9222
Update
walkowif May 9, 2024
ff3a8b1
Update
walkowif May 9, 2024
915ae38
Use tinytable
walkowif May 9, 2024
f9c6451
Try rocker 4.4.0
walkowif May 9, 2024
ad37622
Update
walkowif May 9, 2024
bf135ca
Update
walkowif May 9, 2024
b12fb0c
Fix variable name
walkowif May 9, 2024
78c0777
Update
walkowif May 9, 2024
abc03df
Update
walkowif May 9, 2024
838b182
Ensure sufficient Quarto CLI version is installed
walkowif May 9, 2024
0b6c2f5
Update
walkowif May 9, 2024
0c1a8d3
Update
walkowif May 9, 2024
7821fd4
Update
walkowif May 9, 2024
5980561
Update README
walkowif May 9, 2024
a0c0099
Empty
walkowif May 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
name: ${{ matrix.package.name }}
container:
image: rocker/verse:4.1.2
image: rocker/verse:4.4.0
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
strategy:
Expand All @@ -21,14 +21,10 @@ jobs:
package:
- name: aragog
report_pkg_dir: ./tests/packages/aragog
report_template_path: ./template.Rmd
report_rmarkdown_format: pdf_document
additional_tlmgr_packages: "courier ec fancyhdr"
report_template_path: ./template.qmd
- name: buckbeak
report_pkg_dir: ./tests/packages/buckbeak
report_template_path: ./tests/packages/buckbeak/validation-template.Rmd
report_rmarkdown_format: html_document
additional_tlmgr_packages: "courier ec"
report_template_path: ./tests/packages/buckbeak/validation-template.qmd

steps:
- name: Checkout ${{ matrix.package.name }}
Expand All @@ -40,14 +36,11 @@ jobs:
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 }}

- name: Upload ${{ matrix.package.name }} validation report
uses: actions/upload-artifact@v4
if: success()
with:
name: ${{ matrix.package.name }} validation report
path: ${{ steps.validation.outputs.report_output_filename }}
path: validation_report.pdf
if-no-files-found: error
9 changes: 3 additions & 6 deletions .github/workflows/test_no_cache.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
name: ${{ matrix.package.name }}
container:
image: rocker/verse:4.1.2
image: rocker/verse:4.4.0
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
strategy:
Expand All @@ -21,8 +21,7 @@ jobs:
package:
- name: buckbeak
report_pkg_dir: ./tests/packages/buckbeak
report_template_path: ./tests/packages/buckbeak/validation-template.Rmd
report_rmarkdown_format: html_document
report_template_path: ./tests/packages/buckbeak/validation-template.qmd

steps:
- name: Checkout ${{ matrix.package.name }}
Expand All @@ -34,14 +33,12 @@ jobs:
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

- name: Upload ${{ matrix.package.name }} validation report
uses: actions/upload-artifact@v4
if: success()
with:
name: ${{ matrix.package.name }} validation report
path: ${{ steps.validation.outputs.report_output_filename }}
path: validation_report.pdf
if-no-files-found: error
64 changes: 18 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
[![SuperLinter](https://github.com/insightsengineering/thevalidatoR/actions/workflows/lint.yaml/badge.svg)](https://github.com/insightsengineering/thevalidatoR/actions/workflows/lint.yaml)
[![Test This Action](https://github.com/insightsengineering/thevalidatoR/actions/workflows/test.yaml/badge.svg)](https://github.com/insightsengineering/thevalidatoR/actions/workflows/test.yaml)

- [thevalidatoR](#thevalidator)
- [An R Package Validation Report](#an-r-package-validation-report)
- [Description](#description)
- [Action Type](#action-type)
Expand All @@ -19,99 +20,70 @@
- [admiral](#admiral)

<!-- BEGIN_ACTION_DOC -->
# An R Package Validation Report
# R Package Validation Report

### Description

A Github Action that generates a validation report for an R package. The four main steps are:

A Github Action that generates a validation report for an R package.
The four main steps are:
- Run `R CMD check` (check installation)
- Run `covr::package_coverage()` (check unit test coverage)
- Run `covtracer` (link documentation to unit tests)
- Place results into report
- _If valtools present - run valtools and also publish report?_ (to discuss)
- Attach report as object to release

### Action Type

Composite

### Author

Roche

### Inputs
* `report_pkg_dir`:

- `report_pkg_dir`:

_Description_: Path to package's root
_Description_: Path to package's root.

_Required_: `false`

_Default_: `.`

- `report_template_path`:

_Description_: File path of the R markdown template to use for the report. The default template is available [here.](./template.Rmd)
* `report_template_path`:

_Required_: `false`

_Default_: `template.Rmd`

- `report_rmarkdown_format`:
_Description_: File path of the R markdown template to use for the report.
The default template is available [here.](./template.qmd)

_Description_: The output format to use when rendering the report. Value is used by `rmarkdown::render`'s `output_format` parameter.

_Required_: `false`

_Default_: `pdf_document`
_Default_: `./template.qmd`

- `report_output_prefix`:
* `no_cache`:

_Description_: The output filename prefix for the validation report. If left blank, it defaults to the following convention: `<package name>-<package version>-validation-report`.

_Required_: `false`

_Default_: `""`

- `additional_tlmgr_packages`:

_Description_: Additional tex packages to install with tlmgr.

_Required_: `false`

_Default_: `courier ec`

- `no_cache`:

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

_Required_: `false`

_Default_: `false`

- `cache_version`:
* `cache_version`:

_Description_: Version of the cache. To clean cache bump this version.

_Required_: `false`

_Default_: `v1`

- `disable_install_dev_deps`:
* `disable_install_dev_deps`:

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

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

_Required_: `false`

_Default_: `false`

### Outputs

- `report_output_filename`:

_Description_: Filename of the generated report.

None
<!-- END_ACTION_DOC -->

## How to use
Expand Down
78 changes: 25 additions & 53 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
name: R Package Validation Report
author: Roche
description: A Github Action that generates a validation report for an R package.
description: |
A Github Action that generates a validation report for an R package.
The four main steps are:
- Run `R CMD check` (check installation)
- Run `covr::package_coverage()` (check unit test coverage)
- Run `covtracer` (link documentation to unit tests)
- Place results into report
- Attach report as object to release

inputs:
report_pkg_dir:
Expand All @@ -10,27 +17,9 @@ inputs:
report_template_path:
description: |
File path of the R markdown template to use for the report.
The default template is available [here.](./template.Rmd)
The default template is available [here.](./template.qmd)
required: false
default: "./template.Rmd"
report_rmarkdown_format:
description: |
The file format of the validation report. See `rmarkdown::render`'s
`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:
`<package name>-<package version>-validation-report`.
required: false
default: ""
additional_tlmgr_packages:
description: |
Additional tex packages to install with tlmgr.
required: false
default: "courier ec"
default: "./template.qmd"
no_cache:
description: "Disable github action R dependency caching"
required: false
Expand All @@ -45,10 +34,6 @@ 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"
Expand All @@ -68,13 +53,6 @@ runs:
cat ~/.Rprofile
shell: bash

- name: Set tlmgr cache folder
if: "contains(inputs.no_cache, 'false')"
id: texlive_version
run: |
echo "TEX_LIVE_VERSION=$(tlmgr --version |tail -1 |awk '{print $NF}')" >> $GITHUB_OUTPUT
shell: bash

- name: Cache R packages
if: "contains(inputs.no_cache, 'false')"
uses: actions/cache@v4
Expand All @@ -83,40 +61,34 @@ runs:
key: ${{ inputs.cache_version }}-${{ runner.os }}-${{ steps.r_version.outputs.R_VERSION }}-${{ hashFiles('DESCRIPTION') }}
restore-keys: ${{ inputs.cache_version }}-${{ runner.os }}-${{ steps.r_version.outputs.R_VERSION }}

- name: Cache Tex packages
if: "contains(inputs.no_cache, 'false')"
uses: actions/cache@v4
with:
path: /home/runner/work/_temp/TinyTeX
key: ${{ inputs.cache_version }}-${{ runner.os }}-${{ steps.texlive_version.outputs.TEX_LIVE_VERSION }}-${{ hashFiles(inputs.report_template_path) }}
restore-keys: ${{ inputs.cache_version }}-${{ runner.os }}-${{ steps.texlive_version.outputs.TEX_LIVE_VERSION }}

- name: Install dependencies
run: |
${GITHUB_ACTION_PATH}/dependencies.R
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

- name: Install additional tex packages
run: tlmgr install ${{ inputs.additional_tlmgr_packages }}
[ ! -f "./template.qmd" ] && cp ${GITHUB_ACTION_PATH}/template.qmd . || echo "./template.qmd already exists"
if [[ "$(echo -e "$(quarto --version)\n1.4.0" | sort -V | head -1)" == "1.4.0" ]]; then
echo "✅ Quarto CLI version sufficient (>= 1.4.0)"
echo "Quarto CLI version: $(quarto --version)"
else
echo "❌ Quarto CLI version insufficient (< 1.4.0)"
echo "Downloading Quarto CLI..."
# Install newer version of Quarto CLI.
export QUARTO_VERSION="1.4.554"
apt-get update
apt-get install -qy wget
wget https://github.com/quarto-dev/quarto-cli/releases/download/v${QUARTO_VERSION}/quarto-${QUARTO_VERSION}-linux-amd64.deb
dpkg -i quarto-${QUARTO_VERSION}-linux-amd64.deb
echo "New Quarto CLI version: $(quarto --version)"
fi
shell: bash

- name: Run report generator
id: report-generator
run: |
${GITHUB_ACTION_PATH}/report-generator.R
filename=$(basename $(cat /tmp/report_file_path.txt))
echo "output-filename=${filename}" >> $GITHUB_OUTPUT
shell: bash
env:
# Composite action doesn't set inputs as env vars.
# We need to do this manually...
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 }}
28 changes: 2 additions & 26 deletions dependencies.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,5 @@ lapply(github_packages, remotes::install_github)
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)

# Conditionally install TinyTex
if(!dir.exists(paste(Sys.getenv("RUNNER_TEMP"), "TinyTeX", sep="/"))) {
# nolint start
tinytex_installer <- '
export TINYTEX_DIR=${RUNNER_TEMP}/TinyTeX
wget -qO- "https://raw.githubusercontent.com/yihui/tinytex/master/tools/install-unx.sh" | sh -s - --admin --no-path
mkdir -p ${RUNNER_TEMP}/TinyTeX
cp -r ~/.TinyTeX/. ${RUNNER_TEMP}/TinyTeX
rm -rf ~/.TinyTeX
${RUNNER_TEMP}/TinyTeX/bin/*/tlmgr path add
tlmgr update --self
tlmgr install latex-bin luatex xetex ae bibtex context inconsolata listings makeindex metafont mfware parskip pdfcrop tex tools url xkeyval
'
# nolint end
system(tinytex_installer)
tinytex::r_texmf()
permission_update <- '
chown -R root:staff ${RUNNER_TEMP}/TinyTeX
chmod -R g+w ${RUNNER_TEMP}/TinyTeX
chmod -R g+wx ${RUNNER_TEMP}/TinyTeX/bin
'
system(permission_update)
}
if (!require("quarto")) install.packages("quarto", upgrade = "never", Ncpus = ncores)
if (!require("tinytable")) install.packages("tinytable", upgrade = "never", Ncpus = ncores)
Loading
Loading