diff --git a/NAMESPACE b/NAMESPACE index ea0d7f5..fedefae 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,6 +3,7 @@ export(add_badge_codefactor) export(add_badge_status) export(add_badge_zenodo) +export(add_codecov) export(add_contributing) export(add_issue_template) export(add_logo) diff --git a/R/add_codecov.R b/R/add_codecov.R new file mode 100644 index 0000000..8d6cf05 --- /dev/null +++ b/R/add_codecov.R @@ -0,0 +1,30 @@ +#' +#' Add Codecov token snippet +#' +#' @returns An entry in the `codecov.yml` file for Codecov token specifications +#' suitable for GitHub Actions. +#' +#' @examples +#' if (interactive()) add_codecov() +#' +#' @export +#' + +add_codecov <- function() { + if (!file.exists("codecov.yml")) + return(FALSE) + + codecov_lines <- readLines("codecov.yml") + codecov_lines <- c( + "codecov:", + " token: ${{ secrets.CODECOV_TOKEN }}", + "", + codecov_lines + ) + + ## Append replacement text ---- + writeLines(text = codecov_lines, con = "codecov.yml") + + ## Return TRUE if snippet was added ---- + TRUE +} diff --git a/codecov.yml b/codecov.yml index 04c5585..36c1021 100644 --- a/codecov.yml +++ b/codecov.yml @@ -1,3 +1,6 @@ +codecov: + token: ${{ secrets.CODECOV_TOKEN }} + comment: false coverage: diff --git a/inst/WORDLIST b/inst/WORDLIST index b85d31b..30b3a6a 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -5,6 +5,7 @@ Lifecycle ORCID WIP Zenodo +codecov cran github ke diff --git a/man/add_codecov.Rd b/man/add_codecov.Rd new file mode 100644 index 0000000..6a40b5f --- /dev/null +++ b/man/add_codecov.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/add_codecov.R +\name{add_codecov} +\alias{add_codecov} +\title{Add Codecov token snippet} +\usage{ +add_codecov() +} +\value{ +An entry in the \code{codecov.yml} file for Codecov token specifications +suitable for GitHub Actions. +} +\description{ +Add Codecov token snippet +} +\examples{ +if (interactive()) add_codecov() + +} diff --git a/pkgdown/_pkgdown.yml b/pkgdown/_pkgdown.yml index b5e7fa3..3074cf6 100644 --- a/pkgdown/_pkgdown.yml +++ b/pkgdown/_pkgdown.yml @@ -53,6 +53,10 @@ reference: - add_badge_zenodo - add_logo + - title: Code snippets + contents: + - add_codecov + - title: Document templates contents: - add_contributing