Add a test coverage badge to your R packages using GitHub Actions

Generate a test coverage badge for your R packages using GitHub Actions without needing a separate service like Codecov or Coveralls.
Author

Mauricio “Pachá” Vargas S.

Published

October 10, 2025

If this post is useful to you I kindly ask a minimal donation on Buy Me a Coffee. It shall be used to continue my Open Source efforts.

You can send me questions for the blog using this form and subscribe to receive an email when there is a new post.

I added a new package to my GitHub profile, armadillo4r, and no matter the different paths I took, it was impossible to get Codecov to detect the new repository.

After over thirty minutes of trying different things, I gave up and decided to create a GitHub Actions workflow that would generate a test coverage badge for my R packages without needing to set up a separate service like Codecov or Coveralls.

The result is the new package ghacoveragebadge, which you can use to add a test coverage badge to your R packages using GitHub Actions. Here is the badge for the kendallknight package that I updated today:

Test coverage

You can install the development version of ghacoveragebadge like so:

pak::pkg_install("pachadotdev/ghacoveragebadge")

To add a badge like the previous one to your own R package, go to the package’s main directory and run:

library(ghacoveragebadge)
use_github_actions_coverage()

Using this function will create a GitHub Actions workflow file in .github/workflows/coverage.yaml that will run the test coverage analysis and generate the badge every time you push to the main branch or merge a pull request into main.

I hope it’s useful!