Computes test coverage for the current package using covr and writes a normalized JSON summary file. Intended to be called from GitHub Actions workflows, but works locally with explicit argument overrides.
Usage
emit_coverage_summary(
output_path = "coverage-summary.json",
repo = NULL,
sha = NULL,
ref = NULL,
runner_os = NULL,
r_version = NULL,
timestamp_utc = NULL,
coverage = NULL,
allow_fail = FALSE,
quiet = TRUE
)Arguments
- output_path
(
string) Path for the output JSON file. Default is"coverage-summary.json".- repo
(
string) Repository name inowner/repoformat. Defaults to theGITHUB_REPOSITORYenvironment variable, orNAif unset.- sha
(
string) Full commit SHA. Defaults to theGITHUB_SHAenvironment variable, orNAif unset.- ref
(
string) git ref (e.g."refs/heads/main"). Defaults to theGITHUB_REFenvironment variable, orNAif unset.- runner_os
(
string) Runner OS label. Defaults to theRUNNER_OSenvironment variable, orNAif unset.- r_version
(
string) R version string. Defaults toas.character(getRversion()).- timestamp_utc
(
string) ISO-8601 UTC timestamp string. Defaults to the current time formatted as"%Y-%m-%dT%H:%M:%SZ".- coverage
A
covrcoverage object returned bycovr::package_coverage(). IfNULL(default), coverage is computed automatically.- allow_fail
(
boolean) IfTRUE, coverage computation errors are caught; the JSON is written withcoverage_percent: nulland anerror_messagefield instead of stopping. Default isFALSE.- quiet
(
boolean) Suppress informational messages. Default isTRUE.
Examples
if (FALSE) { # \dontrun{
# Compute and write to default location
emit_coverage_summary()
# Override context fields for local testing
emit_coverage_summary(
output_path = tempfile(fileext = ".json"),
repo = "Gilead-BioStats/gsm.utils",
sha = "abc1234"
)
} # }