diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 14acb8c..7597c58 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -18,7 +18,7 @@ jobs: RENV_PATHS_ROOT: ~/.local/share/renv steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: r-lib/actions/setup-pandoc@v2 @@ -30,21 +30,12 @@ jobs: with: extra-packages: rcmdcheck - - uses: oleksiyrudenko/gha-git-credentials@v2-latest - with: - global: true - token: '${{ secrets.GITHUB_TOKEN }}' - - uses: r-lib/actions/check-r-package@v2 + with: + upload-snapshots: true + build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")' - name: Show testthat output if: always() run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true shell: bash - - - name: Upload check results - if: failure() - uses: actions/upload-artifact@main - with: - name: ${{ runner.os }}-r${{ matrix.config.r }}-results - path: check diff --git a/.github/workflows/gitleaks.yaml b/.github/workflows/gitleaks.yaml index c6b58e8..313ac7c 100644 --- a/.github/workflows/gitleaks.yaml +++ b/.github/workflows/gitleaks.yaml @@ -1,29 +1,16 @@ name: gitleaks-action - on: [pull_request, push, workflow_dispatch] jobs: - scan: - name: gitleaks-action - runs-on: ubuntu-latest - steps: - - - uses: actions/checkout@v3 - + - uses: actions/checkout@v4 with: - fetch-depth: 0 - - run: wget -O .gitleaks.toml https://raw.githubusercontent.com/nhsbsa-data-analytics/nhsbsaShinyR/main/gitleaks.toml - - uses: gitleaks/gitleaks-action@v2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - GITLEAKS_LICENSE: ${{ secrets.GITLEAKS_LICENSE}} diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index d5c81a8..3f8bb90 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -13,7 +13,7 @@ jobs: env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: r-lib/actions/setup-r@v2 with: diff --git a/DESCRIPTION b/DESCRIPTION index 9efff0f..8c18f81 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: nhsbsaShinyR -Title: Template for NHSBSA {shiny} apps -Version: 0.0.0.9004 +Title: Template for NHSBSA \{shiny\} apps +Version: 0.0.0.9005 Authors@R: c(person(given = "DALL", family = "", @@ -23,7 +23,7 @@ Authors@R: role = "ctb", email = "mark.mcpherson@nhsbsa.nhs.uk")) Description: Template used for NHSBSA Data Science and Advanced Analytics - {shiny} apps. + \{shiny\} apps. License: Apache License (>= 2) Depends: R (>= 4.0) @@ -61,6 +61,6 @@ Remotes: statistiekcbs/scrollytell Encoding: UTF-8 LazyData: true -RoxygenNote: 7.2.3 +RoxygenNote: 7.3.1 VignetteBuilder: knitr Config/testthat/edition: 3 diff --git a/R/mod_scrollytell_example.R b/R/mod_scrollytell_example.R index c7102e7..3342a21 100644 --- a/R/mod_scrollytell_example.R +++ b/R/mod_scrollytell_example.R @@ -158,10 +158,10 @@ mod_scrollytell_example_server <- function(id) { highcharter::hchart( type = "scatter", highcharter::hcaes( - x = Sepal.Length, - y = Sepal.Width, - group = group_lvl, - color = point_col + x = .data$Sepal.Length, + y = .data$Sepal.Width, + group = .data$group_lvl, + color = .data$point_col ) ) |> highcharter::hc_xAxis( diff --git a/R/nhsbsaShinyR.R b/R/nhsbsaShinyR.R index 2bb1a0d..25bf614 100644 --- a/R/nhsbsaShinyR.R +++ b/R/nhsbsaShinyR.R @@ -1,22 +1,19 @@ -#' \code{nhsbsaShinyR} package -#' -#' Template app using `golem` for NHSBSA DALL `shiny` apps. -#' -#' @docType package -#' @name nhsbsaShinyR -#' -#' @importFrom rlang := .data -#' +#' @keywords internal +#' @importFrom rlang .data := +"_PACKAGE" + +## usethis namespace: start +## usethis namespace: end NULL if (getRversion() >= "2.15.1") { utils::globalVariables( c( - # data column names - "Sepal.Length", - "Sepal.Width", - "group_lvl", - "point_col" + # No unknown global variables + # Add any found during R CMD check, that cannot be handled with .data$ + # e.g. + + # "SOME_UNKNOWN_VARIABLE" ) ) } diff --git a/R/utils_review.R b/R/utils_review.R index c642e49..30a0de3 100644 --- a/R/utils_review.R +++ b/R/utils_review.R @@ -1,6 +1,6 @@ #' Generate a initial Word doc to write draft text in #' -#' The `{officer}` package works best with a Word document generated from +#' The `\{officer\}` package works best with a Word document generated from #' Rmarkdown. This is just a wrapper around `rmarkdown::render` to do that, with #' default arguments matching our package conventions. #' @@ -20,14 +20,14 @@ #' # generate Word doc for adhoc purposes #' gen_template_doc( #' "C:/Users/CYPHER/Downloads", -#' "adhoc.docx", -#' system.file( -#' "inst", "review", "styles", "draft-styles.rmd", package = "nhsbsaShinyR" -#' ) +#' "adhoc.docx" #' )} gen_template_doc <- function(rv_dir = "inst/review", docx_file = "review.docx", - styles_rmd = "inst/review/styles/draft-styles.rmd") { + styles_rmd = system.file( + "review", "styles", "draft-styles.rmd", + package = "nhsbsaShinyR" + )) { rmarkdown::render( styles_rmd, output_dir = rv_dir, @@ -61,15 +61,15 @@ gen_template_doc <- function(rv_dir = "inst/review", #' md_to_word( #' "my/adhoc/markdown", #' "C:/Users/CYPHER/Downloads", -#' "adhoc.docx", -#' system.file( -#' "inst", "review", "styles", "draft-styles.rmd", package = "nhsbsaShinyR" -#' ) +#' "adhoc.docx" #' )} md_to_word <- function(md_dir = "inst/app/www/assets/markdown", rv_dir = "inst/review", docx_file = "review.docx", - styles_rmd = "inst/review/styles/draft-styles.rmd") { + styles_rmd = system.file( + "review", "styles", "draft-styles.rmd", + package = "nhsbsaShinyR" + )) { styles_doc <- gen_template_doc( rv_dir = tempdir(), docx_file = tempfile(), @@ -111,8 +111,8 @@ md_to_word <- function(md_dir = "inst/app/www/assets/markdown", quiet = TRUE ) - # Return path of generated Word doc - docx_path + # Return path of generated Word doc invisibly + invisible(docx_path) } @@ -627,6 +627,7 @@ word_to_md <- function(md_flag = "markdown/", # Unless disabled, create initial snapshot files if there is no or an empty # _snaps dir if (first_run_snaps) { + testthat::local_edition(3) if (file.exists(file.path(rv_dir, "_snaps"))) { if (!length(Sys.glob(file.path(rv_dir, "tests/_snaps/review_md", "*.md")))) { review_md_dir() @@ -738,6 +739,8 @@ review_md <- function(path, snaps_dir = "inst/review/tests") { #' review_md_diff(snaps_dir = "C:/Users/CYPHER/Downloads") #' )} review_md_dir <- function(md_dir = "inst/review/temp", snaps_dir = "inst/review/tests") { + testthat::local_edition(3) + md_files <- Sys.glob(file.path(md_dir, "*.md")) purrr::walk( diff --git a/README.md b/README.md index b972db6..041c403 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,13 @@ # NHSBSA R Shiny template -This R package has been developed by NHS Business Services Authority Data Analytics Learning Lab to use as a template for building NHSBSA branded R `{shiny}` dashboards. +This R package has been developed by NHS Business Services Authority Data Analytics Learning Lab to use as a template for building NHSBSA branded R `{shiny}` dashboards. + +## Installing from GitHub + +To install this package from GitHub, use the below code. Note that you must explicitly ask for vignettes to be built when installing from GitHub. + +`devtools::install_github("nhsbsa-data-analytics/nhsbsaShinyR", build_vignettes = TRUE)` + ## Features @@ -177,9 +184,3 @@ All code that is used internally and/or is to be exported from the package belon ### `README.md` Give an overview of your package including how to install and the simplest example of usage. - -## Installing from GitHub - -To install this package from GitHub, use the below code. Note that you must explicitly ask for vignettes to be built when installing from GitHub. - -`devtools::install_github("nhsbsa-data-analytics/nhsbsaShinyR", build_vignettes = TRUE)` diff --git a/man/gen_template_doc.Rd b/man/gen_template_doc.Rd index ee5a425..e1d2a3a 100644 --- a/man/gen_template_doc.Rd +++ b/man/gen_template_doc.Rd @@ -7,7 +7,8 @@ gen_template_doc( rv_dir = "inst/review", docx_file = "review.docx", - styles_rmd = "inst/review/styles/draft-styles.rmd" + styles_rmd = system.file("review", "styles", "draft-styles.rmd", package = + "nhsbsaShinyR") ) } \arguments{ @@ -21,7 +22,7 @@ gen_template_doc( Path to the generated Word document } \description{ -The `{officer}` package works best with a Word document generated from +The `\{officer\}` package works best with a Word document generated from Rmarkdown. This is just a wrapper around `rmarkdown::render` to do that, with default arguments matching our package conventions. } @@ -34,9 +35,6 @@ gen_template_doc() # generate Word doc for adhoc purposes gen_template_doc( "C:/Users/CYPHER/Downloads", - "adhoc.docx", - system.file( - "inst", "review", "styles", "draft-styles.rmd", package = "nhsbsaShinyR" - ) + "adhoc.docx" )} } diff --git a/man/md_to_word.Rd b/man/md_to_word.Rd index d854d51..37f0fdd 100644 --- a/man/md_to_word.Rd +++ b/man/md_to_word.Rd @@ -8,7 +8,8 @@ md_to_word( md_dir = "inst/app/www/assets/markdown", rv_dir = "inst/review", docx_file = "review.docx", - styles_rmd = "inst/review/styles/draft-styles.rmd" + styles_rmd = system.file("review", "styles", "draft-styles.rmd", package = + "nhsbsaShinyR") ) } \arguments{ @@ -38,9 +39,6 @@ md_to_word() md_to_word( "my/adhoc/markdown", "C:/Users/CYPHER/Downloads", - "adhoc.docx", - system.file( - "inst", "review", "styles", "draft-styles.rmd", package = "nhsbsaShinyR" - ) + "adhoc.docx" )} } diff --git a/man/nhsbsaShinyR-package.Rd b/man/nhsbsaShinyR-package.Rd new file mode 100644 index 0000000..a7548d1 --- /dev/null +++ b/man/nhsbsaShinyR-package.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/nhsbsaShinyR.R +\docType{package} +\name{nhsbsaShinyR-package} +\alias{nhsbsaShinyR} +\alias{nhsbsaShinyR-package} +\title{nhsbsaShinyR: Template for NHSBSA \{shiny\} apps} +\description{ +Template used for NHSBSA Data Science and Advanced Analytics \{shiny\} apps. +} +\author{ +\strong{Maintainer}: DALL \email{dall@nhsbsa.nhs.uk} + +Other contributors: +\itemize{ + \item Adam Ivison [contributor] + \item Kayoung Goffe \email{kayoung.goffe@nhsbsa.nhs.uk} [contributor] + \item Steven Buckley \email{steven.buckley@nhsbsa.nhs.uk} [contributor] + \item Mark McPherson \email{mark.mcpherson@nhsbsa.nhs.uk} [contributor] +} + +} +\keyword{internal} diff --git a/man/nhsbsaShinyR.Rd b/man/nhsbsaShinyR.Rd deleted file mode 100644 index f0b9d1d..0000000 --- a/man/nhsbsaShinyR.Rd +++ /dev/null @@ -1,9 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/nhsbsaShinyR.R -\docType{package} -\name{nhsbsaShinyR} -\alias{nhsbsaShinyR} -\title{\code{nhsbsaShinyR} package} -\description{ -Template app using `golem` for NHSBSA DALL `shiny` apps. -} diff --git a/tests/testthat/test-utils_review.R b/tests/testthat/test-utils_review.R index 7bb999e..9f27402 100644 --- a/tests/testthat/test-utils_review.R +++ b/tests/testthat/test-utils_review.R @@ -21,9 +21,9 @@ test_that("md_to_word generates expected Word doc", { # Due to how officer::read_docx works, we expect there to always be # differences in the package_dir and doc_properties$data. - # Also, when run on github CI, there are small differences in some of the - # colours used in the Word doc styles. - expected_differences <- ifelse(testthat:::on_ci(), 8, 2) + # Also, when run on github CI, there are small differences in the Word doc + # generated, due to the Windows OS being Windows Server. + expected_differences <- ifelse(testthat:::on_ci(), 56, 2) # If unexpected number of diffs, print out the comparison for ease of seeing # where the fail is.