Skip to content

Commit 4b25d05

Browse files
committed
Add coverage report in CI
1 parent f227c05 commit 4b25d05

File tree

1 file changed

+47
-4
lines changed

1 file changed

+47
-4
lines changed

.github/workflows/test.yml

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ permissions:
1616
contents: read # to fetch code (actions/checkout)
1717

1818
env:
19+
FORCE_COLOR: "1" # Make tools pretty.
20+
TOX_TESTENV_PASSENV: FORCE_COLOR
21+
PIP_DISABLE_PIP_VERSION_CHECK: "1"
22+
PIP_NO_PYTHON_VERSION_WARNING: "1"
1923
PYTHON_LATEST: "3.11"
2024

2125

@@ -32,7 +36,7 @@ jobs:
3236
python-version: ${{env.PYTHON_LATEST}}
3337
- uses: pre-commit/[email protected]
3438

35-
test:
39+
tests:
3640
runs-on: ubuntu-latest
3741
needs: lint
3842
strategy:
@@ -41,17 +45,56 @@ jobs:
4145

4246
steps:
4347
- uses: actions/checkout@v3
44-
- name: Setup Python ${{ matrix.python }}
48+
- name: 🐍 Setup Python ${{ matrix.python }}
4549
uses: actions/setup-python@v4
4650
with:
4751
python-version: ${{ matrix.python }}
48-
- name: Install dependencies
52+
- name: 📦 Install dependencies
4953
run: |
50-
python -Im pip install --upgrade pip
5154
python -Im pip install tox tox-gh-actions wheel
5255
5356
- name: 🏗️ Build wheel
5457
run: python setup.py bdist_wheel
5558

5659
- name: 🧪 Run tox targets for Python ${{ matrix.python-version }}
5760
run: tox --installpkg ./dist/*.whl
61+
62+
- name: ⬆️ Upload coverage data
63+
uses: actions/upload-artifact@v3
64+
with:
65+
name: coverage-data
66+
path: .coverage.*
67+
if-no-files-found: ignore
68+
retention-days: 1
69+
70+
coverage:
71+
runs-on: ubuntu-latest
72+
needs: tests
73+
steps:
74+
- uses: actions/checkout@v3
75+
with:
76+
fetch-depth: 0
77+
- uses: actions/setup-python@v4
78+
with:
79+
# Use latest Python, so it understands all syntax.
80+
python-version: ${{env.PYTHON_LATEST}}
81+
82+
- run: python -Im pip install --upgrade "coverage[toml]>=7.2,<8.0"
83+
84+
- name: ⬇️ Download coverage data
85+
uses: actions/download-artifact@v3
86+
with:
87+
name: coverage-data
88+
89+
- name: + Combine coverage
90+
run: |
91+
python -Im coverage combine
92+
python -Im coverage html --skip-covered --skip-empty
93+
python -Im coverage report
94+
echo "## Coverage summary" >> $GITHUB_STEP_SUMMARY
95+
python -Im coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
96+
- name: 📈 Upload HTML report if check failed.
97+
uses: actions/upload-artifact@v3
98+
with:
99+
name: html-report
100+
path: htmlcov

0 commit comments

Comments
 (0)