Skip to content

Warning

You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?

OpenCover Badge Generator

Actions
Reads an open cover xml file and generates a badge to use in readme file
v1.0.7
Star (5)

Github Action OpenCover Badge Generator

Simple action to generate code coverage badges from a previously created OpenCover XML file.

(Note: Ensure you get the case of the paths correct for the agent running the job.)

Usage

First ensure you have a valid opencover.xml code coverage file generated by something like coverlet. For example, using the dotnet core command dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover.

Then, generate an access token and save as a GitHub Secret which you can then reference in your Project Workflow yaml as follows:

on:
  pull_request:
    types: [opened]
    branches:
      - master
jobs:
  coverage:
    runs-on: ubuntu-latest
    steps:
      - name: OpenCover Badge Generator
        uses: danpetitt/open-cover-badge-generator-action@1.0.6
        with:
          path-to-opencover-xml: ./test/opencover.xml
          path-to-badges: ./
          minimum-coverage: 75
          repo-token: ${{ secrets.CI_TOKEN }}

Once generated you will get two badges called coverage-badge-line.svg and coverage-badge-branch.svg saved into the path you specified that you can then add to your project readme like:

[![Coverage Status](./coverage-badge-line.svg)](https://github.com/danpetitt/open-cover-badge-generator-action/)

Inputs

path-to-opencover-xml

Required Path to the open cover xml file

path-to-badges

Optional Path where the line and branch coverage svgs would be saved; these will be saved with the names coverage-badge-line.svg and coverage-badge-branch.svg; if not specified the files will be saved into the project root. Default "./".

minimum-coverage

Required Threshold percentage at which a red badge would appear.

repo-token

Required GitHub repo token so that the changed file can be committed, like ${{ secrets.CI_TOKEN }}

OpenCover Badge Generator is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

Reads an open cover xml file and generates a badge to use in readme file
v1.0.7

OpenCover Badge Generator is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.