From cb6dafa1d28cfc58d6c35ab4d021bac1eb71d359 Mon Sep 17 00:00:00 2001 From: Ernest Guevarra Date: Wed, 1 May 2024 09:03:13 +0100 Subject: [PATCH 1/3] create add_codecov function --- NAMESPACE | 1 + R/add_codecov.R | 30 ++++++++++++++++++++++++++++++ codecov.yml | 3 +++ inst/WORDLIST | 1 + man/add_codecov.Rd | 19 +++++++++++++++++++ 5 files changed, 54 insertions(+) create mode 100644 R/add_codecov.R create mode 100644 man/add_codecov.Rd 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() + +} From 9811d898e5ce6b6be83db0d1f4a539562e81dd40 Mon Sep 17 00:00:00 2001 From: Ernest Guevarra Date: Wed, 1 May 2024 09:21:25 +0100 Subject: [PATCH 2/3] add new function to pkgdown --- pkgdown/_pkgdown.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgdown/_pkgdown.yml b/pkgdown/_pkgdown.yml index b5e7fa3..08300f0 100644 --- a/pkgdown/_pkgdown.yml +++ b/pkgdown/_pkgdown.yml @@ -53,6 +53,9 @@ reference: - add_badge_zenodo - add_logo + - title: Code snippets + - add_codecov + - title: Document templates contents: - add_contributing From 2dd9911e7a00227bbb45b545b868909bbb8193ab Mon Sep 17 00:00:00 2001 From: Ernest Guevarra Date: Wed, 1 May 2024 09:27:48 +0100 Subject: [PATCH 3/3] edit pkgdown entry for new function --- pkgdown/_pkgdown.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgdown/_pkgdown.yml b/pkgdown/_pkgdown.yml index 08300f0..3074cf6 100644 --- a/pkgdown/_pkgdown.yml +++ b/pkgdown/_pkgdown.yml @@ -54,6 +54,7 @@ reference: - add_logo - title: Code snippets + contents: - add_codecov - title: Document templates