CodeCoverageSummary icon indicating copy to clipboard operation
CodeCoverageSummary copied to clipboard

Badge Showing Coverage % for main branch for README.md file?

Open ardalis opened this issue 3 years ago • 3 comments

Looking at the existing badge support I see it is generating an image like this one:

![Code Coverage](https://img.shields.io/badge/Code%20Coverage-97%25-success?style=flat)

This works fine in the PR comment but I'd like to include a badge in my project README with the latest coverage value from the main branch. Is this something this tool can help with, or does that require some separate service that would host the image?

Looking at the various shields.io branches for coverage, none of these seem like they would work with CodeCoverageSummary: https://shields.io/category/coverage

Thanks for any tips.

ardalis avatar Feb 18 '22 16:02 ardalis

Hi @ardalis, at the moment CCS doesn't produce a badge for the readme but it is a feature I'd like to have.

Ideally CCS would download the badge from shields.io and save it to a fixed location for the readme to reference. I've considered saving the badge to the root of the repo running the action but I'm not happy with that solution. I really don't want to write to users' repos.

If you have any ideas I'm open to suggestions.

irongut avatar Feb 18 '22 17:02 irongut

While looking for the latest in solving this problem the most promising item I found was this one. It's hacky but leverages gists rather than actual repo access:

https://dev.to/thejaredwilcurt/coverage-badge-with-github-actions-finally-59fa

HTH.

ardalis avatar Feb 18 '22 17:02 ardalis

That is an interesting solution. If I incorporate uploading the json file into CCS then the user would need to create a gist and supply its id and a PAT in the workflow. That doesn't sound too bad.

Schneegans/dynamic-badges-action

irongut avatar Feb 18 '22 22:02 irongut