Add Coverage Badge #62
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Perform Checks | |
on: | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
REPOSITORY_NAME: 'action-demo' | |
permissions: write-all | |
jobs: | |
standard-checks: | |
name: Perform Standard Checks | |
permissions: | |
contents: write | |
pull-requests: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Install Dependencies | |
run: python3 -m pip install -r requirements.txt | |
- name: Run Pylint | |
uses: dciborow/[email protected] | |
with: | |
github_token: ${{ secrets.github_token }} | |
# Change reviewdog reporter if you need [github-pr-check,github-check,github-pr-review]. | |
reporter: github-pr-review | |
# Change reporter level if you need. | |
# GitHub Status Check won't become failure with warning. | |
level: warning | |
glob_pattern: "sources/**/*.py" | |
- name: Behave Tests | |
run: coverage run --source="sources" -m behave tests/qualification_tests | |
- name: Generate XML coverage report | |
run: coverage xml | |
- name: Get Coverage | |
uses: orgoro/[email protected] | |
with: | |
coverageFile: coverage.xml | |
token: ${{ secrets.GITHUB_TOKEN }} | |
thresholdAll: 0.9 | |
- name: Retrieve Total Coverage | |
id: coverage | |
run: echo "TOTAL_COVERAGE=$(coverage report | grep TOTAL | awk '{ print $4 }') | sed 's/%/%25/g'" >> "$GITHUB_ENV" | |
- name: Retrieve Release Version | |
id: version | |
run: echo "VERSION=$(python3 setup.py --version)" >> "$GITHUB_ENV" | |
- name: Add Badges | |
# You may pin to the exact commit or the version. | |
# uses: wow-actions/add-badges@43f2c1eaecfb2596b89a8136a3fbda4f18d1d188 | |
uses: wow-actions/[email protected] | |
env: | |
repo_url: ${{ github.event.repository.html_url }} | |
repo_name: ${{ github.event.repository.name }} | |
repo_owner: ${{ github.event.repository.owner.login }} | |
with: | |
# Your GitHub token for authentication. | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# The badges to add with JSON format | |
badges: | | |
[ | |
{ | |
"badge": "https://img.shields.io/badge/License-MIT-yellow.svg?style=for-the-badge", | |
"alt": "MIT License", | |
"link": "${{ env.repo_url }}/blob/main/LICENSE" | |
}, | |
{ | |
"badge": "https://img.shields.io/badge/Language-Python-blue?style=for-the-badge&logo=python", | |
"alt": "Language", | |
"link": "https://www.python.org/" | |
}, | |
{ | |
"badge": "https://img.shields.io/badge/PRs-Welcome-brightgreen.svg?style=for-the-badge", | |
"alt": "PRs Welcome", | |
"link": "${{ env.repo_url }}/pulls" | |
}, | |
{ | |
"badge": "https://img.shields.io/badge/TestPyPi-${{ env.VERSION }}-brightgreen.svg?style=for-the-badge", | |
"alt": "TestPyPi ${{ env.VERSION }}", | |
"link": "https://test.pypi.org/project/${{ env.REPOSITORY_NAME }}/" | |
}, | |
{ | |
"badge": "https://img.shields.io/badge/PyPi-${{ env.VERSION }}-brightgreen.svg?style=for-the-badge", | |
"alt": "PyPi ${{ env.VERSION }}", | |
"link": "https://pypi.org/project/${{ env.REPOSITORY_NAME }}/" | |
}, | |
{ | |
"badge": "https://img.shields.io/badge/Coverage-${{ env.TOTAL_COVERAGE }}-gray.svg?style=for-the-badge", | |
"alt": "Coverage ${{ env.TOTAL_COVERAGE }}" | |
} | |
] | |
# Path and file name to add badges | |
path: README.md | |
# Should center align the badges | |
center: false |