Integrate Coveralls with .Net Core to display badge in GitHub README
Today, I want to know code coverage about my dot net project, and also want to check it in GitHub directly.
I try to use Coveralls
to get code coverage.
Install Nuget packages
Install coverlet.collector and coverlet.msbuild Nuget packages in project.
It can use command or Nuget package tool to install package
dotnet add package coverlet.collector
dotnet add package coverlet.msbuild
Register in Coveralls.io
Sign up with GitHub account to link GitHub repositories with coveralls.io.
After login, add the repository that you need and click sync repo

Modify Actions yaml file
Add a step for generate coverage report in yaml file after run test

You don’t need to create
GITHUB_TOKEN
secret, because GitHub automatically create it at the start of each workflow run.Could check GitHub Docs to get more information.
Push code and yaml file to GitHub
Get code coverage badge for README
Login Coveralls.io
and choose REPOS
in menu bar.
Click Embed
drop down list and copy Markdown

Finally, past it to README

Unfortunately, it isn’t updated immediately because of browser cache.
Need to clear browser cache, after the action complete.