Create coverage badges from coverage reports. Using GitHub Actions and GitHub Workflow CPU time (no 3rd parties servers).
npm install coverage-badges-clicoverage-badges-cli
===





Create coverage badges from coverage reports. Using GitHub Actions and GitHub Workflow CPU time (no 3rd parties servers).
Don't worry about the coverage.io service is down.
``shell`
$ npm i coverage-badges-cli
`js`
{
"scripts": {
"coverage": "jest --coverage"
"make-badges": "coverage-badges",
},
"jest": {
"collectCoverageFrom": [
"
"!*/.{js,d.ts}"
],
"coverageReporters": [
"lcov",
"json-summary"
],
}
}
This config creates a coverage badge in a default directory ./badges.
You can add !Coverage to your README.md after the badge creation.


- source - The path of the target file "coverage-summary.json".output
- - Output image path.label
- - The left label of the badge, usually static (default coverage).labelColor
- - \555).color
- - \scale
- - Set badge scale (default: 1).style
- - Badges style: flat, classic (default classic).type
- ~~~~ - (No longer supported after v1.2.0) Coverage report type: lines, statements, functions, branches (default statements)jsonPath
- - Path to the coverage percentage number to be used in the badge (default total.statements.pct)arbitrary
- - Allow jsonPath to point to non-number values. Works in conjunction with jsonPathicon
- - Path to icon file
`yml
- name: Create Coverage Badges
uses: jaywcjlove/coverage-badges-cli@main
with:
style: flat
source: coverage/coverage-summary.json
output: coverage/badges.svg
jsonPath: totals.percent_covered
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build
`
svg svg image string:
`yml
name: Build & Deploy
on:
push:
branches:
- master
jobs:
build-deploy:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14
- run: npm install
- run: npm run build
- run: npm run coverage
- run: npm i coverage-badges-cli -g
- run: coverage-badges --output coverage/badges.svg
- name: Deploy
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/master'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./coverage
`
`bash
Usage: coverage-badges [options] [--help|h]
Options:
--version, -v Show version number
--help, -h Displays help information.
--output, -o Output directory.
--source, -s The path of the target file "coverage-summary.json".
--style Badges style: flat, flat-square.
--type Coverage type: lines, statements, functions, branches.
--scale Set badge scale (default: 1)
--icon Path to icon file
--iconWidth Set this if icon is not square (default: 13)
--label The left label of the badge, usually static (default coverage).
--labelColor
--color
--jsonPath Path to the coverage percentage number to be used in the badge.
--arbitrary Allow jsonPath to point to non-number values. Works in conjunction with jsonPath.
Example:
npm coverage-badges-cli --output coverage/badges.svg
npm coverage-badges-cli --style plastic
npm coverage-badges-cli --source coverage/coverage-summary.json
npm coverage-badges-cli --labelColor ADF
`
`bash``
$ npm i
$ npm run build
$ npm run watch
- Github Release Changelog Generator A GitHub Action that compares the commit differences between two branches
- Create Tags From Auto create tags from commit or package.json.
- Github Action Contributors Github action generates dynamic image URL for contributor list to display it!
- Create Coverage Badges Create coverage badges from coverage reports. (no 3rd parties servers)
- Generated Badges Create a badge using GitHub Actions and GitHub Workflow CPU time (no 3rd parties servers)
As always, thanks to our amazing contributors!
Made with contributors.
MIT © Kenny Wong