From ccf9abd8a4ac81a0555b44abb61f89b382471b23 Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Tue, 23 Apr 2024 17:37:29 +0200 Subject: [PATCH] Use Quarto and Typst --- .github/workflows/test.yaml | 15 +- .github/workflows/test_no_cache.yaml | 9 +- README.md | 64 ++----- action.yml | 72 ++------ dependencies.R | 28 +-- report-generator.R | 32 +--- template.Rmd => template.qmd | 163 ++++++++++-------- ...n-template.Rmd => validation-template.qmd} | 27 ++- 8 files changed, 152 insertions(+), 258 deletions(-) rename template.Rmd => template.qmd (66%) rename tests/packages/buckbeak/{validation-template.Rmd => validation-template.qmd} (70%) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 60f5c67..7b811e3 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.2 + image: rocker/verse:4.4.0 env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} strategy: @@ -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 }} @@ -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 diff --git a/.github/workflows/test_no_cache.yaml b/.github/workflows/test_no_cache.yaml index 7720f95..0b2a6fe 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.2 + image: rocker/verse:4.4.0 env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} strategy: @@ -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 }} @@ -34,8 +33,6 @@ 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 @@ -43,5 +40,5 @@ jobs: 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 diff --git a/README.md b/README.md index c048e33..0622806 100644 --- a/README.md +++ b/README.md @@ -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) @@ -19,78 +20,51 @@ - [admiral](#admiral) -# 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: `--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. @@ -98,20 +72,18 @@ Roche _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 ## How to use diff --git a/action.yml b/action.yml index d8255fb..b05b89a 100644 --- a/action.yml +++ b/action.yml @@ -1,6 +1,7 @@ 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. inputs: report_pkg_dir: @@ -10,27 +11,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: - `--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 @@ -45,10 +28,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" @@ -68,13 +47,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 @@ -83,40 +55,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 }} diff --git a/dependencies.R b/dependencies.R index e06bb94..3a830a2 100755 --- a/dependencies.R +++ b/dependencies.R @@ -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) diff --git a/report-generator.R b/report-generator.R index 8e97ecc..7a48b92 100755 --- a/report-generator.R +++ b/report-generator.R @@ -8,11 +8,11 @@ git_safe_dir <- system( sprintf("git config --global --add safe.directory '%s'", getwd()) ) +cat(paste0("INPUT_REPORT_PKG_DIR = ", Sys.getenv("INPUT_REPORT_PKG_DIR", "."))) + # Get the action inputs from preset env vars 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") -report_output_prefix <- Sys.getenv("INPUT_REPORT_OUTPUT_PREFIX", "") +template_path <- Sys.getenv("INPUT_REPORT_TEMPLATE_PATH", "./template.qmd") disable_install_dev_deps <- tolower( Sys.getenv("DISABLE_INSTALL_DEV_DEPS") ) %in% c("yes", "y", "t", "true") @@ -41,26 +41,6 @@ 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 = report_output_prefix, - output_format = report_format, - params = list(pkg_dir = pkg_dir) -) - -# 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)) +library(quarto) +cat(paste0("Running Quarto render for template: ", template_path)) +quarto_render(template_path, output_file = "validation_report.pdf") diff --git a/template.Rmd b/template.qmd similarity index 66% rename from template.Rmd rename to template.qmd index 718b3e1..d796b8f 100644 --- a/template.Rmd +++ b/template.qmd @@ -1,61 +1,28 @@ --- -title: "Validation Report" -subtitle: "`r sprintf('%s (v%s)', (dcf <- read.dcf(file.path(params$pkg_dir, 'DESCRIPTION')))[,'Package'], dcf[,'Version'])`" -date: "`r format(Sys.time(), '%a %b %d %X %Y')`" -author: - - "`r paste0('**Server**: ',Sys.getenv('GITHUB_SERVER_URL'))`" - - "`r paste0('**Repository**: ',Sys.getenv('GITHUB_REPOSITORY'))`" - - "`r paste0('**Reference**: ',Sys.getenv('GITHUB_REF'))`" - - "`r paste0('**Commit SHA**: ',Sys.getenv('GITHUB_SHA'))`" -params: - pkg_dir: "`r normalizePath(Sys.getenv('INPUT_REPORT_PACKAGE_DIR', '.'))`" -output: - pdf_document: +title: "Validation Report - `r sprintf('%s (v%s)',(dcf <- read.dcf(file.path(Sys.getenv('INPUT_REPORT_PKG_DIR', '.'), 'DESCRIPTION')))[,'Package'], dcf[,'Version'])`" +date: "`r Sys.time()`" +date-format: "ddd MMM DD hh:mm:ss A YYYY" +format: + typst: toc: true - number_sections: true -header-includes: -- \usepackage{fancyhdr} -- \pagestyle{fancy} -- \fancyfoot[RE,RO]{\thepage} + section-numbering: 1.1.1 + df-print: default + margin: + x: 2cm + y: 2cm --- -\fancyhead[LO,LE]{`r sprintf('%s (v%s)', (dcf <- read.dcf(file.path(params$pkg_dir, 'DESCRIPTION')))[,'Package'], dcf[,'Version'])`} -\fancyfoot[CO,CE]{`r paste0('Commit SHA: ',Sys.getenv('GITHUB_SHA'))`} - ```{r setup, include = FALSE} options(width = 80L, covr.record_tests = TRUE) remotes::install_local( - params$pkg_dir, + Sys.getenv('INPUT_REPORT_PKG_DIR', '.'), force = TRUE, quiet = TRUE, INSTALL_opts = "--with-keep.source", upgrade = "never" ) library(magrittr) -library(knitr) -library(kableExtra) -knitr::opts_chunk$set( - error = TRUE, - width = 80L, - comment = "" -) - -helper_tabulate <- function(x, caption = "", col_widths = c("10cm", "5cm")) { - x %>% - kbl( - caption = caption, - booktabs = TRUE, longtable = TRUE - ) %>% - kable_styling( - latex_options = c("striped", "repeat_header") - ) %>% - column_spec( - 1, width = col_widths[1] - ) %>% - column_spec( - 2, width = col_widths[2] - ) -} +library(tinytable) ``` # Context @@ -75,14 +42,21 @@ This report is fully automated, so is limited to assess whether unit tests and d ## System Info ```{r execution_info, echo = FALSE} -data.frame( +tt_sys_info_df <- data.frame( Field = c("OS", "Platform", "System", "Execution Time"), Value = c( sessionInfo()$running, R.version$platform, R.version$system, format(Sys.time(), tz = "UTC", usetz = TRUE) - )) %>% helper_tabulate("System info", col_widths = c("6cm", "6cm")) + )) %>% + dplyr::mutate(Value = paste0("``` ", Value, " ```")) + +tt( + tt_sys_info_df, + caption = "System information", + theme = "striped" +) ``` ## Package installed @@ -90,15 +64,18 @@ data.frame( ```{r version_control, echo = FALSE} # find .git dir containing the package directory gd <- system( - sprintf("cd '%s' && git rev-parse --absolute-git-dir", params$pkg_dir), + sprintf("cd '%s' && git rev-parse --absolute-git-dir", Sys.getenv('INPUT_REPORT_PKG_DIR', '.')), intern = TRUE ) # define reused git args to be sure we're picking up the right git info gd <- sprintf("--git-dir='%s'", gd) -wt <- sprintf("--work-tree='%s'", params$pkg_dir) -data.frame( - Field = c("branch", "commit `SHA1`", "commit date"), +wt <- sprintf("--work-tree='%s'", Sys.getenv('INPUT_REPORT_PKG_DIR', '.')) +tt_git_df <- data.frame( + Field = c("server", "repository", "git ref", "branch", "commit `SHA1`", "commit date"), Value = c( + Sys.getenv('GITHUB_SERVER_URL'), + Sys.getenv('GITHUB_REPOSITORY'), + Sys.getenv('GITHUB_REF'), system2( "git", list(gd, wt, "rev-parse", "--abbrev-ref", "HEAD"), @@ -110,7 +87,14 @@ data.frame( list(gd, wt, "show", "-s", "--format=%ci", "HEAD"), stdout = TRUE ) - )) %>% helper_tabulate("Git information", col_widths = c("5cm", "8cm")) + )) %>% + dplyr::mutate(Value = paste0("``` ", Value, " ```")) + +tt( + tt_git_df, + caption = "Git information", + theme = "striped" +) ``` ## R Session Info @@ -125,7 +109,7 @@ capabilities() The following metrics are derived from the `riskmetric` R package. Metrics overlapping with `covr` and `R CMD Check` are removed. ```{r riskmetric, echo = FALSE, eval = TRUE} -d_riskmetric <- params$pkg_dir %>% +d_riskmetric <- Sys.getenv('INPUT_REPORT_PKG_DIR', '.') %>% riskmetric::pkg_ref() %>% riskmetric::pkg_assess() %>% purrr::map(1) %>% @@ -139,18 +123,20 @@ d_riskmetric <- params$pkg_dir %>% by = c("name" = "column_name") ) -d_riskmetric %>% +tt_riskmetric_df <- d_riskmetric %>% dplyr::filter( name %in% c( "news_current", "has_vignettes", "license", "downloads_1yr" ) ) %>% - dplyr::select(Metric = label, Status = value) %>% - #table - helper_tabulate( - caption = "Package info assessed by the R package riskmetric" - ) + dplyr::select(Metric = label, Status = value) + +tt( + tt_riskmetric_df, + caption = "Package info assessed by the R package riskmetric", + theme = "striped" +) ``` # Installation documentation @@ -159,7 +145,7 @@ d_riskmetric %>% ```{r r_cmd_check, echo = FALSE, eval = TRUE} rcmdcheck_results <- rcmdcheck::rcmdcheck( - params$pkg_dir, + Sys.getenv('INPUT_REPORT_PKG_DIR', '.'), args = c( "--timings", # include execution times in output "--no-build-vignettes", # run vignette code, but disable pdf rendering @@ -175,15 +161,19 @@ cat(rcmdcheck_results$stderr) ## Testing Coverage ```{r coverage, echo = FALSE, eval = TRUE} -covr_results <- covr::package_coverage(params$pkg_dir) +covr_results <- covr::package_coverage(Sys.getenv('INPUT_REPORT_PKG_DIR', '.')) covr_results ``` ## Traceability -Tracebility matrix that maps each unit test to the corresponding documentation, creating a link +Tracebility matrix that maps each unit test to the corresponding documentation, creating a link between intended use and testing. +```{=typst} +#show figure: set block(breakable: true) +``` + ### Testing matrix ```{r traceability, echo = FALSE, eval = TRUE} @@ -206,31 +196,47 @@ if (require("covtracer", quietly = TRUE)) { dplyr::mutate(alias = paste0(alias, "()")) %>% dplyr::mutate(file = paste0("man/", file)) - covtracer_df_clean %>% + tt_covtracer_df <- covtracer_df_clean %>% dplyr::filter(!duplicated(.)) %>% dplyr::filter(!is.na(test_name)) %>% dplyr::filter(!is.na(file)) %>% # unexported? dplyr::arrange(file) %>% - dplyr::select(`Test Description` = test_name, Documentation = file) %>% - helper_tabulate( - caption = "Tracebility matrix mapping unit tests to documented behaviours." - ) + dplyr::mutate(test_name = paste0("``` ", test_name, " ```")) %>% + dplyr::mutate(file = paste0("``` ", file, " ```")) %>% + dplyr::select(`Test Description` = test_name, Documentation = file) + + tt( + tt_covtracer_df, + caption = "Tracebility matrix mapping unit tests to documented behaviours.", + theme = "striped" + ) } else { cat("{covtracer} not available to produce a traceability matrix") } ``` +```{=typst} +#show figure: set block(breakable: false) +``` + ### Untested ```{r traceability2, echo = FALSE, eval = TRUE} if (require("covtracer", quietly = TRUE)) { - covtracer_df_clean %>% + tt_untested_df <- covtracer_df_clean %>% dplyr::filter(is.na(test_name)) %>% dplyr::arrange(alias) %>% - dplyr::select(`Exported package object` = alias, Documentation = file) %>% - helper_tabulate( - caption = "Untested behaviours: documentation that is not covered by any test." + dplyr::mutate(alias = paste0("``` ", alias, " ```")) %>% + dplyr::mutate(file = paste0("``` ", file, " ```")) %>% + dplyr::select(`Exported package object` = alias, Documentation = file) + + if (nrow(tt_untested_df) > 0) { + tt( + tt_untested_df, + caption = "Untested behaviours: documentation that is not covered by any test.", + theme = "striped" ) + } } else { cat("{covtracer} not available to produce a traceability matrix") } @@ -242,14 +248,19 @@ An indicator of test granularity by whether the function is directly tested. ```{r traceability3, echo = FALSE, eval = TRUE} if (require("covtracer", quietly = TRUE)) { - covtracer_df_clean %>% + tt_granularity_df <- covtracer_df_clean %>% dplyr::group_by(alias) %>% dplyr::summarize(any_direct_tests = any(direct, na.rm = TRUE)) %>% dplyr::arrange(alias) %>% - dplyr::select(`Exported package object` = alias, `Tested Directly` = any_direct_tests) %>% - helper_tabulate( - caption = "Granularity of unit tests: directly tested exported functions." - ) + dplyr::mutate(alias = paste0("``` ", alias, " ```")) %>% + dplyr::mutate(any_direct_tests = paste0("``` ", any_direct_tests, " ```")) %>% + dplyr::select(`Exported package object` = alias, `Tested Directly` = any_direct_tests) + + tt( + tt_granularity_df, + caption = "Granularity of unit tests: directly tested exported functions.", + theme = "striped" + ) } else { cat("{covtracer} not available to produce a traceability matrix") } diff --git a/tests/packages/buckbeak/validation-template.Rmd b/tests/packages/buckbeak/validation-template.qmd similarity index 70% rename from tests/packages/buckbeak/validation-template.Rmd rename to tests/packages/buckbeak/validation-template.qmd index 47c30e0..b3e6550 100644 --- a/tests/packages/buckbeak/validation-template.Rmd +++ b/tests/packages/buckbeak/validation-template.qmd @@ -1,44 +1,43 @@ --- title: "Buckbeak Validation Report" -output: - - "md_document" -params: - pkg_dir: "." +date: "`r Sys.time()`" +date-format: "ddd MMM DD hh:mm:ss A YYYY" +format: + typst: + toc: true + section-numbering: 1.1.1 + df-print: default + margin: + x: 2cm + y: 2cm --- - ```{r, include = FALSE} options(width = 80L, covr.record_tests = TRUE) remotes::install_local( - params$pkg_dir, + Sys.getenv('INPUT_REPORT_PACKAGE_DIR', '.'), force = TRUE, quiet = TRUE, INSTALL_opts = "--with-keep.source" ) library(magrittr) -library(knitr) -knitr::opts_chunk$set( - width = 80L, - comment = "" -) ``` - # Execution Info ## System Info ```{r execution_info, echo = FALSE} -kable(data.frame( +data.frame( Field = c("OS", "Platform", "System", "Execution Time"), Value = c( sessionInfo()$running, R.version$platform, R.version$system, format(Sys.time(), tz = "UTC", usetz = TRUE) - ))) + )) ``` ## Session Info