Learn R Programming

covr (version 4.0.0)

coverage_to_markdown: Convert a coverage dataset to a markdown table

Description

Creates a markdown table with the total coverage and the coverage of each file, suitable for a GitHub Actions job summary or a pull request comment. If base is given, the table also includes the coverage of base and the change from it.

Usage

coverage_to_markdown(x = package_coverage(), base = NULL)

Value

A character vector of markdown lines, with class "covr_markdown".

Arguments

x

a coverage dataset, defaults to running package_coverage().

base

an optional coverage dataset to compare against, e.g. the coverage of the main branch.

Examples

Run this code
cov <- code_coverage(
  "add <- function(x, y) { x + y }",
  "add(1, 2)"
)
coverage_to_markdown(cov)

if (FALSE) {
# In a GitHub Actions step
md <- coverage_to_markdown(package_coverage())
cat(md, file = Sys.getenv("GITHUB_STEP_SUMMARY"), sep = "\n", append = TRUE)
}

Run the code above in your browser using DataLab