Skip to content

Commit d9cf54c

Browse files
committed
Add coverage badge
1 parent 3f8d265 commit d9cf54c

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

.github/workflows/python-app.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,44 @@ jobs:
1919

2020
steps:
2121
- uses: actions/checkout@v4
22+
2223
- name: Set up Python 3.10
2324
uses: actions/setup-python@v3
2425
with:
2526
python-version: "3.10"
27+
2628
- name: Install dependencies
2729
run: |
2830
python -m pip install --upgrade pip
2931
pip install flake8
3032
pip install .
33+
3134
- name: Lint with flake8
3235
run: |
3336
# stop the build if there are Python syntax errors or undefined names
3437
flake8 . --ignore=E501,F401,W503,E266 --count --select=E9,F63,F7,F82 --show-source --statistics
3538
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
3639
flake8 . --ignore=E501,F401,W503,E266 --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
37-
- name: Test with unittest
40+
41+
- name: Unit testing
3842
run: |
39-
python -m unittest discover src/test_pownet
43+
coverage run -m unittest discover src/test_pownet
44+
coverage json
45+
COVERAGE_PERCENT=$(python -c "import json; print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")
46+
echo "Total Coverage: $COVERAGE_PERCENT%"
47+
echo "total=$COVERAGE_PERCENT" >> $GITHUB_ENV
48+
49+
- name: Code coverage
50+
uses: schneegans/[email protected]
51+
with:
52+
auth: ${{ secrets.GIST_TOKEN }}
53+
gistID: 23c151ad08ede7f698ce7cfbc2c09a0a
54+
filename: covbadge.json
55+
label: Coverage
56+
message: ${{ env.total }}%
57+
minColorRange: 50
58+
maxColorRange: 90
59+
valColorRange: ${{ env.total }}
60+
61+
62+

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
![license MIT](https://img.shields.io/badge/License-MIT-yellow.svg)
22
[![CI Tests](https://github.com/Critical-Infrastructure-Systems-Lab/PowNet/actions/workflows/python-app.yml/badge.svg)](https://github.com/Critical-Infrastructure-Systems-Lab/PowNet/actions)
3+
[![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/phumthep/23c151ad08ede7f698ce7cfbc2c09a0a/raw/covbadge.json)](https://github.com/Critical-Infrastructure-Systems-Lab/PowNet/actions)
34
[![GitHub Release](https://img.shields.io/github/v/release/Critical-Infrastructure-Systems-Lab/PowNet)](https://github.com/Critical-Infrastructure-Systems-Lab/PowNet/releases/tag/v2.0)
45
[![Read the Docs](https://img.shields.io/readthedocs/pownet)](https://pownet.readthedocs.io/en/latest/)
56
[![status](https://joss.theoj.org/papers/f7509a62fde550bec7ae3d1da0181b7d/status.svg)](https://joss.theoj.org/papers/f7509a62fde550bec7ae3d1da0181b7d)

pyproject.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ where = ["src"]
88
[tool.setuptools.package-data]
99
pownet = ["database/*.csv"]
1010

11+
[tool.coverage.run]
12+
disable_warnings = ["no-data-collected"]
13+
1114
[project]
1215
name = "pownet"
1316
version = "2.2.0"
@@ -28,6 +31,7 @@ dependencies = [
2831
"statsmodels >= 0.14.4",
2932
"geopandas >= 1.0.1",
3033
"contextily >= 1.6.2",
34+
"coverage >= 7.8.0",
3135
]
3236
requires-python = ">=3.10"
3337

0 commit comments

Comments
 (0)