Skip to content

Commit

Permalink
Update URLs related to a codecov badge (#2008)
Browse files Browse the repository at this point in the history
* Update URLs related to a codecov badge

Fixes #1991
Closes #1876

* Add a NEWS bullet
  • Loading branch information
jennybc authored Jun 26, 2024
1 parent be5e7f0 commit 90dc393
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 6 deletions.
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# usethis (development version)

* The URLs baked into the badge generated by `use_coverage(type = "codecov")`
no longer specify a branch (#2008).

* The `ui_*()` functions have been marked as
[superseded](https://lifecycle.r-lib.org/articles/stages.html#superseded).
External users of these functions are encouraged to use the
Expand Down
5 changes: 2 additions & 3 deletions R/coverage.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ use_covr_ignore <- function(files) {
}

use_codecov_badge <- function(repo_spec) {
default_branch <- git_default_branch()
url <- glue("https://app.codecov.io/gh/{repo_spec}?branch={default_branch}")
img <- glue("https://codecov.io/gh/{repo_spec}/branch/{default_branch}/graph/badge.svg")
url <- glue("https://codecov.io/gh/{repo_spec}")
img <- glue("https://codecov.io/gh/{repo_spec}/graph/badge.svg")
use_badge("Codecov test coverage", url, img)
}

Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ knitr::opts_chunk$set(

<!-- badges: start -->
[![R-CMD-check](https://github.com/r-lib/usethis/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/usethis/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/r-lib/usethis/branch/main/graph/badge.svg)](https://app.codecov.io/gh/r-lib/usethis?branch=main)
[![CRAN status](https://www.r-pkg.org/badges/version/usethis)](https://CRAN.R-project.org/package=usethis)
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
[![.github/workflows/R-CMD-check](https://github.com/r-lib/usethis/actions/workflows/.github/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/usethis/actions/workflows/.github/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/r-lib/usethis/graph/badge.svg)](https://codecov.io/gh/r-lib/usethis)
<!-- badges: end -->

usethis is a workflow package: it automates repetitive tasks that arise during project setup and development, both for R packages and non-package projects.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<!-- badges: start -->

[![R-CMD-check](https://github.com/r-lib/usethis/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/usethis/actions/workflows/R-CMD-check.yaml)
[![Codecov test
coverage](https://codecov.io/gh/r-lib/usethis/branch/main/graph/badge.svg)](https://app.codecov.io/gh/r-lib/usethis?branch=main)
[![CRAN
status](https://www.r-pkg.org/badges/version/usethis)](https://CRAN.R-project.org/package=usethis)
[![Lifecycle:
stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
[![.github/workflows/R-CMD-check](https://github.com/r-lib/usethis/actions/workflows/.github/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/usethis/actions/workflows/.github/workflows/R-CMD-check.yaml)
[![Codecov test
coverage](https://codecov.io/gh/r-lib/usethis/graph/badge.svg)](https://codecov.io/gh/r-lib/usethis)
<!-- badges: end -->

usethis is a workflow package: it automates repetitive tasks that arise
Expand Down
13 changes: 13 additions & 0 deletions tests/testthat/_snaps/coverage.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# we use specific URLs in a codecov badge

Code
use_codecov_badge("OWNER/REPO")
Message
! Can't find a README for the current project.
i See `usethis::use_readme_rmd()` for help creating this file.
i Badge link will only be printed to screen.
[ ] Copy and paste the following lines into 'README':
<!-- badges: start -->
[![Codecov test coverage](https://codecov.io/gh/OWNER/REPO/graph/badge.svg)](https://codecov.io/gh/OWNER/REPO)
<!-- badges: end -->

5 changes: 5 additions & 0 deletions tests/testthat/test-coverage.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
test_that("we use specific URLs in a codecov badge", {
create_local_package()
withr::local_options(usethis.quiet = FALSE)
expect_snapshot(use_codecov_badge("OWNER/REPO"))
})

0 comments on commit 90dc393

Please sign in to comment.