Skip to content

Commit

Permalink
Use shields.io badges for R-CMD-check and test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
jennybc committed Dec 22, 2021
1 parent cc1ac60 commit 4e66530
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion R/coverage.R
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ 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")
img <- glue("https://img.shields.io/codecov/c/github/{repo_spec}?label=test%20coverage&logo=codecov")
use_badge("Codecov test coverage", url, img)
}

Expand Down
13 changes: 9 additions & 4 deletions R/github-actions.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,20 @@ use_github_actions <- function() {
#' @rdname github_actions
use_github_actions_badge <- function(name = "R-CMD-check.yaml",
repo_spec = NULL) {
name_no_ext <- path_ext_remove(name)
if (path_ext(name) == "") {
name <- path_ext_set(name, "yaml")
}
name_enc <- utils::URLencode(name)
name_no_ext_enc <- utils::URLencode(name_no_ext)
badge_label <- glue("{name_no_ext} GitHub Action status")

repo_spec <- repo_spec %||% target_repo_spec()
enc_name <- utils::URLencode(name)
img <- glue("https://github.com/{repo_spec}/actions/workflows/{enc_name}/badge.svg")
url <- glue("https://github.com/{repo_spec}/actions/workflows/{enc_name}")

use_badge(path_ext_remove(name), url, img)
img <- glue("https://img.shields.io/github/workflow/status/{repo_spec}/{name_no_ext_enc}?label={name_no_ext_enc}&logo=github")
url <- glue("https://github.com/{repo_spec}/actions/workflows/{name_enc}")

use_badge(badge_label, url, img)
}

uses_github_actions <- function() {
Expand Down
4 changes: 2 additions & 2 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ knitr::opts_chunk$set(
# usethis <img src="man/figures/logo.png" align="right" height="139" />

<!-- 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)
[![R-CMD-check GitHub Action status](https://img.shields.io/github/workflow/status/r-lib/usethis/R-CMD-check?label=R-CMD-check&logo=github)](https://github.com/r-lib/usethis/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://img.shields.io/codecov/c/github/r-lib/usethis?label=test%20coverage&logo=codecov)](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)
<!-- badges: end -->
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@

<!-- 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)
[![R-CMD-check GitHub Action
status](https://img.shields.io/github/workflow/status/r-lib/usethis/R-CMD-check?label=R-CMD-check&logo=github)](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)
coverage](https://img.shields.io/codecov/c/github/r-lib/usethis?label=test%20coverage&logo=codecov)](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:
Expand Down

0 comments on commit 4e66530

Please sign in to comment.