Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
kygoffe committed Aug 9, 2024
2 parents aff15e1 + 59dff77 commit 7ae2c52
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 93 deletions.
17 changes: 4 additions & 13 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
15 changes: 1 addition & 14 deletions .github/workflows/gitleaks.yaml
Original file line number Diff line number Diff line change
@@ -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}}
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 = "",
Expand All @@ -23,7 +23,7 @@ Authors@R:
role = "ctb",
email = "[email protected]"))
Description: Template used for NHSBSA Data Science and Advanced Analytics
{shiny} apps.
\{shiny\} apps.
License: Apache License (>= 2)
Depends:
R (>= 4.0)
Expand Down Expand Up @@ -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
8 changes: 4 additions & 4 deletions R/mod_scrollytell_example.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
25 changes: 11 additions & 14 deletions R/nhsbsaShinyR.R
Original file line number Diff line number Diff line change
@@ -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"
)
)
}
29 changes: 16 additions & 13 deletions R/utils_review.R
Original file line number Diff line number Diff line change
@@ -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.
#'
Expand All @@ -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,
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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)
}


Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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(
Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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)`
10 changes: 4 additions & 6 deletions man/gen_template_doc.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 3 additions & 5 deletions man/md_to_word.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions man/nhsbsaShinyR-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 0 additions & 9 deletions man/nhsbsaShinyR.Rd

This file was deleted.

6 changes: 3 additions & 3 deletions tests/testthat/test-utils_review.R
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 7ae2c52

Please sign in to comment.