Site icon R-bloggers

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

[This article was first published on https://pacha.dev/blog, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
< !DOCTYPE html> < charset="utf-8"> < http-equiv="X-UA-Compatible" content="IE=edge"> < name="viewport" content="width=device-width, initial-scale=1.0"> pacha.dev/blog < !-- MathJax Configuration --> < !-- Smart header: libraries detected based on content --> < !-- File: /tmp/tmp.UEMQ4Vm5yQ/index.html -->
  • < !-- DEBUG: Found sourceCode --> < !-- Load custom CSS after any library CSS to ensure proper precedence -->
  • < header class="site-top">

    Mauricio “Pachá” Vargas Sepúlveda

    Blog with notes about R, Shiny, SQL, Python, Linux and C++. This blog is listed on R-Bloggers.

    HOME 🏠
    < !-- categories are printed below this--> < nav class="sidebar-nav">

    Categories

    < header id="title-block-header" class="quarto-title-block default">

    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!

    < footer>

    Loading…

  • < !-- Load shared sidebar -->
    To leave a comment for the author, please follow the link and comment on their blog: https://pacha.dev/blog.

    R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
    Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
    Exit mobile version