Package 'covrpage'

Title: Create a Readme Summary Page for GitHub testthat and covr Outputs
Description: Create a README file to place in package test subdirectory to communicate with other users in more detail results of testthat and covr.
Authors: Jonathan Sidi [aut, cre] , Locke Data [fnd] (https://itsalocke.com)
Maintainer: Jonathan Sidi <[email protected]>
License: MIT + file LICENSE
Version: 0.2
Built: 2024-11-01 11:17:15 UTC
Source: https://github.com/yonicd/covrpage

Help Index


Run covr with failing tests

Description

Run package_coverage ignoring failing tests from test_dir.

Usage

coverage_skip(test_path = "tests/testthat", test_skip = NULL)

Arguments

test_path

character, path to test directory, Default: 'tests/testthat'

test_skip

data.frame, mapping of failing tests, PARAM_DESCRIPTION, Default: NULL

Details

If test_skip is NULL then a new test_dir will be run internally checking for failing tests.

See Also

test_dir package_coverage

Other utility: covr_summary(), map_testthat_snapshot(), map_testthat(), map_test(), package_name(), testthat_summary()


Query 'git log' for code coverage history

Description

Retrieve log of code coverages evaluated by covrpage that were committed to git version control.

Usage

covr_log()

Value

data.frame

See Also

Other log: covrpage_log()

Examples

## Not run: 
covr_log()

## End(Not run)

Summary outputs for covr object

Description

Creates a summary data.frame for covr object output that mimics the console print method of package_coverage

Usage

covr_summary(x, package, failed = FALSE)

Arguments

x

covr object

package

character, package name

failed

flag for failed test, Default: FALSE

Value

data.frame

See Also

package_coverage

Other utility: coverage_skip(), map_testthat_snapshot(), map_testthat(), map_test(), package_name(), testthat_summary()


Render covrpage

Description

Render the template of the covrpage in the package directory.

Usage

covrpage(
  path = getwd(),
  preview = TRUE,
  auto_push = FALSE,
  update_badge = TRUE,
  vignette = FALSE
)

Arguments

path

path to package

preview

boolean, to open the output in viewer, Default: TRUE

auto_push

boolean, push to remote repo on exit, Default: FALSE

update_badge

boolean, locate badge in README and update with testthat results, Default: TRUE

vignette

boolean, if TRUE then the covrpage README will be copied as a vignette of the package, Default: FALSE

See Also

render

Other invoke: covrpage_ci(), covrpage_snapshot()


covrpage for travis

Description

wrapper for covrpage call with switches for running after-success on travis and deploying gh-pages.

Usage

covrpage_ci(path = getwd(), ...)

Arguments

path

character, path to package, Default: getwd()

...

arguments to pass to covrpage

See Also

Other invoke: covrpage_snapshot(), covrpage()

Examples

## Not run: 
if(interactive()){
 covrpage_ci()
 }

## End(Not run)

Query 'git log' for covrpage history

Description

Retrieve log of covrpage README.md files committed to git version control

Usage

covrpage_log()

Value

list

See Also

Other log: covr_log()

Examples

## Not run: 
covrpage_log()

## End(Not run)

Run covrpage on a GitHub Repository

Description

Runs a covrpage on a GitHub repository in a sterile environment

Usage

covrpage_snapshot(
  repo,
  branch = NULL,
  PAT = Sys.getenv("GITHUB_PAT"),
  host = "api.github.com",
  preview = TRUE
)

Arguments

repo

character, Public GitHub repository

branch

character, Name of the branch to checkout. Default: NULL

PAT

character, GitHub Personal Access Token, Default: Sys.getenv("GITHUB_PAT")

host

character, GitHub API host to use, Default: "api.github.com"

preview

boolean, to open the output in viewer, Default: TRUE

Details

Creates a markdown output that is sent to the internal viewer.

Setting branch to NULL means that clone will use the remote's default branch.

See Also

covrpage clone install_github

Other invoke: covrpage_ci(), covrpage()

Examples

## Not run: 
if(interactive()){
 covrpage_snapshot('tidyverse/purrr')
 }

## End(Not run)

Create covrpage Badge

Description

Create covrpage badge for test status and date that is connected to the README.md created in the tests directory.

Usage

make_badge(remote_origin = NULL, active_branch = NULL, tinyurl = TRUE)

Arguments

remote_origin

character, username/repo of the remote origin, Default: NULL

active_branch

character, current active git branch, Default: NULL

tinyurl

boolean, convert badge uri to tinyurl link, Default: TRUE

Details

if either inputs are NULL then the .git file is inspected to gather the information

Value

character

See Also

Other setup: tencrypt(), use_covrpage_vignette(), use_covrpage()


Map the hierarchy structure of a testthat test file

Description

Query a test file to see what expectations are defined in it.

Usage

map_test(path)

Arguments

path

character, path to file

Details

Return data.frame containing which expectations are in the test file by context/description/test/expectation/linerange

Value

data.frame

See Also

getParseData

Other utility: coverage_skip(), covr_summary(), map_testthat_snapshot(), map_testthat(), package_name(), testthat_summary()


Map the hierarchy structure of testthat directory

Description

Query a testthat directory for the unit test structure.

Usage

map_testthat(path = "tests/testthat")

Arguments

path

character, path to tests, Default: 'tests/testthat'

Details

Return data.frame containing which expecations are in the testthat directory by file/context/description/test/expectation/linerange

Value

data.frame

See Also

setNames

Other utility: coverage_skip(), covr_summary(), map_testthat_snapshot(), map_test(), package_name(), testthat_summary()


Run map_testthat on a GitHub Repository

Description

Runs a covrpage on a GitHub repository in a sterile environment

Usage

map_testthat_snapshot(
  repo,
  branch = NULL,
  PAT = Sys.getenv("GITHUB_PAT"),
  host = "api.github.com"
)

Arguments

repo

character, Public GitHub repository

branch

character, Name of the branch to checkout. Default: NULL

PAT

character, GitHub Personal Access Token, Default: Sys.getenv("GITHUB_PAT")

host

character, GitHub API host to use, Default: "api.github.com"

Details

Creates a markdown output that is sent to the internal viewer.

Setting branch to NULL means that clone will use the remote's default branch.

Value

tibble

See Also

covrpage clone install_github

Other utility: coverage_skip(), covr_summary(), map_testthat(), map_test(), package_name(), testthat_summary()

Examples

## Not run: 
if(interactive()){
 map_testthat_snapshot('tidyverse/purrr')
 }

## End(Not run)

package name

Description

Retrieve package name

Usage

package_name(path = getwd())

Arguments

path

path to package

See Also

Other utility: coverage_skip(), covr_summary(), map_testthat_snapshot(), map_testthat(), map_test(), testthat_summary()


Encrypt Travis environment variables

Description

Add encrypted Travis environment variable to git directory and .travis.yml.

Usage

tencrypt(
  r_obj = Sys.getenv("GITHUB_PAT"),
  travis_env = "GITHUB_PAT",
  add = TRUE
)

Arguments

r_obj

object value to encrypt

travis_env

character, name of Travis environment variable

add

boolean, add directly to .travis.yml, Default: TRUE

See Also

Other setup: make_badge(), use_covrpage_vignette(), use_covrpage()


Summary outputs for testthat object

Description

Summary outputs for testthat object that is used in rmd

Usage

testthat_summary(x, type = c("short", "long"))

Arguments

x

list, testthat object output

type

character, format of the object output, Default: c("short", "long")

Value

data.frame

See Also

Other utility: coverage_skip(), covr_summary(), map_testthat_snapshot(), map_testthat(), map_test(), package_name()


Add covrpage to Travis CI for a git directory

Description

Adds bash file to execute after Travis test is successfully completed.

Usage

use_covrpage(
  file = ".travis/covrpage.sh",
  travis_type = c("bash", "pkgdown", "tic"),
  travis_blocks = c("after_success", "after_failure", "deploy_ghpages"),
  gh_user = gsub("@(.*?)$", "", system("git config user.email", intern = TRUE)),
  push_branch = "test",
  repo = system("git config travis.slug", intern = TRUE),
  deploy_branch = system("git rev-parse --abbrev-ref HEAD", intern = TRUE)
)

Arguments

file

character, file path to save bash script to, Default: '.travis/covrpage.sh'

travis_type

character, build .travis.yml template for bash script, pkgdown deployment or using the 'tic' package from ropenscilabs on GitHub Default: c('bash','pkgdown','tic')

travis_blocks

character, vector that defines what .travis.yml blocks tocreate, Default: c('after_success','after_failure','deploy_ghpages')

gh_user

character, Github user name, Default: gsub("@(.*?)$", "", system("git config user.email", intern = TRUE))

push_branch

character, branch Travis will create to push updated covrpage readme file, Default: 'test'

repo

character, name of git repo that package is hosted on, Default: system("git config travis.slug", intern = TRUE)

deploy_branch

character, name of branch that current package build is located, Default: system("git rev-parse –abbrev-ref HEAD", intern = TRUE) (usually 'master')

See Also

Other setup: make_badge(), tencrypt(), use_covrpage_vignette()

Examples

use_covrpage(travis_type = 'bash',file=file.path(tempdir(),'myfile.sh'))

#does not write to disk
use_covrpage(travis_type = 'bash',file=NULL)

use_covrpage(travis_type = 'pkgdown')
use_covrpage(travis_type = 'pkgdown',travis_block = 'after_success')
use_covrpage(travis_type = 'pkgdown',travis_block = 'after_failure')
use_covrpage(travis_type = 'pkgdown',travis_block = c('after_success','after_failure'))

Create a vignette for covrpage

Description

Perform general setup and copying of tests/README.md into vignette subdirectory

Usage

use_covrpage_vignette(path = ".")

Arguments

path

character, path to root of file, Default:'.'

See Also

Other setup: make_badge(), tencrypt(), use_covrpage()

Examples

## Not run: 
use_covrpage_vignette()

## End(Not run)