Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@
^docs$
^pkgdown$
^\.github$
.*\.xlsx$
.*\.code-workspace$
^codecov\.yml$
62 changes: 62 additions & 0 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:

name: test-coverage.yaml

permissions: read-all

jobs:
test-coverage:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr, any::xml2
needs: coverage

- name: Test coverage
run: |
cov <- covr::package_coverage(
quiet = FALSE,
clean = FALSE,
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
print(cov)
covr::to_cobertura(cov)
shell: Rscript {0}

- uses: codecov/codecov-action@v5
with:
# Fail if error if not on PR, or if on PR and token is given
fail_ci_if_error: ${{ github.event_name != 'pull_request' || secrets.CODECOV_TOKEN }}
files: ./cobertura.xml
plugins: noop
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v4
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: SPCreporter
Title: Creates Metric Reports using Statistical Process Control in the NHS style
Version: 0.2.0.9004
Version: 0.2.1
Authors@R: c(
person("Tom", "Smith",, "tomsmith_uk@hotmail.com", role = c("aut", "cre")),
person("Fran", "Barton",, "fbarton@alwaysdata.net", role = "aut"))
Expand Down
6 changes: 3 additions & 3 deletions R/helper_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@ align_rebase_dates <- function(input, measure_data) {
#' @noRd
get_assurance_type <- function(spc, improvement_direction) {
imp_dir <- tolower(improvement_direction)
upl <- spc[["upl"]][1]
lpl <- spc[["lpl"]][1]
target <- spc[["target"]][1]
upl <- tail(spc[["upl"]], 1)
lpl <- tail(spc[["lpl"]], 1)
target <- tail(spc[["target"]], 1)

a <- dplyr::case_when(
imp_dir == "neutral" ~ "Neutral",
Expand Down
4 changes: 4 additions & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ knitr::opts_chunk$set(

# {SPCreporter}

<!-- badges: start -->
[![Codecov test coverage](https://codecov.io/gh/ThomUK/SPCreporter/graph/badge.svg)](https://app.codecov.io/gh/ThomUK/SPCreporter)
<!-- badges: end -->

{SPCreporter} is a simple way to add value to your performance reporting using statistical process control. It produces reports similar to this [**example report**](report_examples/My_Example_Report.html).

**Help sort signals from noise, and ensure your leadership are talking about signals that matter.**
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@

# {SPCreporter}

<!-- badges: start -->

[![Codecov test
coverage](https://codecov.io/gh/ThomUK/SPCreporter/graph/badge.svg)](https://app.codecov.io/gh/ThomUK/SPCreporter)
<!-- badges: end -->

{SPCreporter} is a simple way to add value to your performance reporting
using statistical process control. It produces reports similar to this
[**example report**](report_examples/My_Example_Report.html).
Expand Down
14 changes: 14 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
comment: false

coverage:
status:
project:
default:
target: auto
threshold: 1%
informational: true
patch:
default:
target: auto
threshold: 1%
informational: true
18 changes: 18 additions & 0 deletions tests/testthat/test-get_assurance_type.R
Original file line number Diff line number Diff line change
Expand Up @@ -103,3 +103,21 @@ test_that("it returns correct string in passing conditions", {
"PASS_TARG"
)
})

test_that("it uses the most recent row, not the first, for upl/lpl", {
# Simulates a real ptd_spc output where a single-point first rebase phase
# produces NA limits for that row, while the current (last) rows have valid
# limits. The target column is constant (as ptd_spc stores it) — only
# upl/lpl are NA early on. get_assurance_type must use tail(), not [1],
# matching get_variation_type.
spc <- data.frame(
upl = c(NA, NA, 3),
lpl = c(NA, NA, 1),
target = c(0.5, 0.5, 0.5) # constant target; 0.5 < lpl → PASS for "increase"
)

expect_equal(
get_assurance_type(spc, "increase"),
"PASS_TARG"
)
})
Loading