usethis
usethis copied to clipboard
How to update badges
The recommended badge snippet for GHA and Codecov has changed over time.
The dev version of usethis produces badges that match what GitHub's and Codecov's official badge helpers provide now.
If you have old badge syntax (which still seems to work, BTW), but you want to update, here's how.
Note that the Codecov badge update will be prompted by urlchecker::url_check()
, i.e. you're going to have to do this one anyway, eventually.
This is a little fiddly, given how low impact it is. Our current/old badges do work, at least for the moment. But here's the deal anyway.
Reasons to update badges:
- Part of finishing
master
-->main
. - Use the URLs returned by GitHub's and Codecov's own official badge helpers / docs.
This requires dev usethis. The GHA update in question happened in https://github.com/r-lib/usethis/commit/aa510ec8d4d511ad74ecb15b63ab14febcdfa27c.
Pick one, to update GHA R-CMD-check badge:
-
use_tidy_github_actions()
inserts an updated GHA badge in README, while doing its main job. -
use_github_actions_badge("R-CMD-check")
just inserts a badge.
To update a Codecov badge, you have to call an internal helper via :::
:
-
usethis:::use_codecov_badge("OWNER/SPEC")
, e.g.usethis:::use_codecov_badge("r-lib/gh")
Before committing new badges:
- If this resulted in 2 badges in
README.[R]?md
, delete the old. Move the new into desired place. - Re-render
README.Rmd
withdevtools::build_readme()
.
R-CMD-check
badge:
Old svg: ...OWNER/REPO/workflows/R-CMD-check/badge.svg
New svg: ...OWNER/REPO/actions/workflows/R-CMD-check.yaml/badge.svg
Old URL: ...OWNER/REPO/actions
New URL: ...OWNER/REPO/actions/workflows/R-CMD-check.yaml
Codecov test coverage badge:
Old svg: probably mentions master
New svg: probably should mention main
Old URL: https://codecov.io/gh/OWNER/REPO?branch=master
New URL: https://app.codecov.io/gh/OWNER/REPO?branch=main
Should we wait on #1554 before doing this systematically?
Sure. I don't see any urgency around this. (Although I have been doing it whenever I work on a package.)