项目作者: danpetitt

项目描述 :
GitHub Action to read an open cover xml file in the project folder and generate a badge to use in readme file
高级语言: JavaScript
项目地址: git://github.com/danpetitt/open-cover-badge-generator-action.git
创建时间: 2020-02-07T20:06:38Z
项目社区:https://github.com/danpetitt/open-cover-badge-generator-action

开源协议:MIT License

下载


Github Action OpenCover Badge Generator

Simple action to generate code coverage badges from a previously created dotnet OpenCover XML file generated by tools such as coverlet.

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:

  1. on:
  2. pull_request:
  3. types: [opened]
  4. branches:
  5. - master
  6. jobs:
  7. coverage:
  8. runs-on: ubuntu-latest
  9. steps:
  10. - name: OpenCover Badge Generator
  11. uses: danpetitt/open-cover-badge-generator-action@v1.0.9
  12. with:
  13. path-to-opencover-xml: ./test/opencover.xml
  14. path-to-badges: ./
  15. minimum-coverage: 75
  16. commit-badges: false
  17. repo-token: ${{ secrets.CI_TOKEN }}

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

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

  1. [![Line Coverage Status](./coverage-badge-line.svg)](https://github.com/danpetitt/open-cover-badge-generator-action/)
  2. [![Branch Coverage Status](./coverage-badge-branch.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)

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.

commit-badges (Optional)

Optional: When set will commit the changed badges to the repo. Default true.

commit-branch-name (Optional)

Optional: When set will checkout the given branch name before committing the changed badges. Default is the current main branch.

repo-token (Required)

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