Skip to content

add coverage (#82) #438

add coverage (#82)

add coverage (#82) #438

name: CLI Unit tests
on:
push:
paths:
- '**.py'
- '.github/workflows/python-unit-tests.yaml'
jobs:
python-unit-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]
- name: Setup Python
uses: actions/[email protected]
with:
python-version: 3.11
- name: Install Python dependencies
run: pip install -qr cli/requirements.txt
- name: Run tests
run: |
cd cli
python -m unittest
- name: Generate coverage report
run: |
cd cli
coverage run -m unittest discover
coverage json
test_coverage=$(jq ".totals.percent_covered" coverage.json)
echo "Coverage: $test_coverage"
if [ $test_coverage -lt 65 ]; then
echo "Coverage is less than 65%"
exit 1
fi
# Add this
- name: Update Coverage Badge
# GitHub actions: default branch variable
# https://stackoverflow.com/questions/64781462/github-actions-default-branch-variable
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
uses: we-cli/coverage-badge-action@main