1

Being not familar with R myself, I'd like to create a badge to summarize the test coverage in Gitlab CI, using the covr package. The only way I found on the net was to use the gitlab function; however this seems to create an HTML page, which is not what I want.

Is there a simple way to retrieve the summary on stdout, and a regexp to parse it for the badge?

1 Answer 1

0

usethis::use_gitlab_ci() provides a useful template to set up GitLab CI/CD for R packages which in turn can be used to create coverage badges. It basically executes covr::gitlab() during the pipeline testing stage.

More information on how to create a badge from that can be found in the GitLab docs on pipelines. According to the notes in the usethis template, inside Settings > CI/CD > General Pipelines, you need to insert \d+\.\d+ to extract the coverage from the covr report. You can then simply copy and paste the coverage badge Markdown code shown under the "Coverage report" section. As soon as the pipeline has run all tests, the badge should show the current test coverage.

Not the answer you're looking for? Browse other questions tagged or ask your own question.