Skip to content

Commit 4655675

Browse files
committed
add coverage reporting
1 parent 0c27fb8 commit 4655675

File tree

4 files changed

+76
-12
lines changed

4 files changed

+76
-12
lines changed

.coveragerc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[run]
2+
relative_files = True
3+
source = cert_chain_resolver
4+
5+
[paths]
6+
source =
7+
cert_chain_resolver
8+
*/cert_chain_resolver

.github/workflows/ci-cd.yml

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,28 @@ jobs:
1414
container:
1515
image: python:2.7.18-buster
1616
steps:
17-
- uses: actions/checkout@v3
18-
- name: Set up Python ${{ matrix.python-version }}
19-
uses: actions/setup-python@v4
20-
with:
21-
python-version: ${{ matrix.python-version }}
17+
- uses: actions/checkout@v4
2218
- name: Install dependencies
2319
run: |
2420
python -m pip install -r requirements.txt && \
2521
python -m pip install -r requirements_dev.txt
26-
- name: Test with pytest
22+
- name: Test with pytest and coverage
2723
run: |
28-
pytest
24+
pytest --cov=./cert_chain_resolver --cov-report term-missing -n auto
25+
- name: Upload coverage artifact
26+
if: success()
27+
uses: actions/upload-artifact@v4
28+
with:
29+
name: coverage-2.7
30+
path: .coverage
2931

3032
Test:
3133
runs-on: ubuntu-latest
3234
strategy:
3335
matrix:
3436
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
3537
steps:
36-
- uses: actions/checkout@v3
38+
- uses: actions/checkout@v4
3739
- name: Set up Python ${{ matrix.python-version }}
3840
uses: actions/setup-python@v4
3941
with:
@@ -42,10 +44,48 @@ jobs:
4244
run: |
4345
python -m pip install -r requirements.txt && \
4446
python -m pip install -r requirements_dev.txt
45-
- name: Test with pytest
47+
- name: Test with pytest and coverage
48+
run: |
49+
pytest --cov=./cert_chain_resolver --cov-report term-missing -n auto
50+
- name: Upload coverage artifact
51+
if: success()
52+
uses: actions/upload-artifact@v4
53+
with:
54+
name: coverage-${{ matrix.python-version }}
55+
path: .coverage
56+
57+
combine-coverage:
58+
runs-on: ubuntu-latest
59+
needs:
60+
- Test
61+
- Test-python-27
62+
steps:
63+
- uses: actions/checkout@v4
64+
- name: Set up Python
65+
uses: actions/setup-python@v4
66+
with:
67+
python-version: 3.12
68+
- name: Install coverage tools
69+
run: |
70+
python -m pip install coverage codecov
71+
- name: Download coverage artifacts
72+
uses: actions/download-artifact@v4
73+
with:
74+
pattern: coverage-*
75+
- name: Combine coverage reports
4676
run: |
47-
pytest
77+
ls -lashR .
78+
set -x
79+
coverage combine coverage-*/.coverage
80+
coverage report
81+
coverage xml -o combined_coverage.xml
4882
83+
coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
84+
- name: Upload coverage to Codecov
85+
uses: codecov/codecov-action@v4
86+
with:
87+
file: ./combined_coverage.xml
88+
token: ${{ secrets.CODECOV_TOKEN }}
4989
mypy:
5090
runs-on: ubuntu-latest
5191
strategy:

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
[![Licence](https://img.shields.io/badge/licence-MIT-blue.svg)](https://tldrlegal.com/license/mit-license)
44
[![CI](https://github.com/rkoopmans/python-certificate-chain-resolver/actions/workflows/ci-cd.yml/badge.svg)](https://github.com/rkoopmans/python-certificate-chain-resolver/actions/workflows/ci-cd.yml)
55
[![Docs](https://readthedocs.org/projects/certificate-resolver/badge/?version=latest)](https://certificate-resolver.readthedocs.io/en/latest/)
6+
[![codecov](https://codecov.io/github/rkoopmans/python-certificate-chain-resolver/graph/badge.svg?token=P2K55Z1KME)](https://codecov.io/github/rkoopmans/python-certificate-chain-resolver)
67
[![Downloads](https://static.pepy.tech/badge/cert-chain-resolver/week)](https://pepy.tech/project/cert-chain-resolver)
78
[![Python)](https://img.shields.io/pypi/pyversions/cert-chain-resolver.svg)](https://pypi.org/project/cert-chain-resolver/)
89
[![PyPI - Wheel](https://img.shields.io/pypi/wheel/cert-chain-resolver)](https://pypi.org/project/cert-chain-resolver/)

tox.ini

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,29 @@
11
[tox]
2-
envlist = py27,py35,py36,py37,py38,py39,py310,py311,py312,mypy,mypy2
2+
envlist = clean,py27,py35,py36,py37,py38,py39,py310,py311,py312,mypy,mypy2
33

44
[testenv]
55
deps = -rrequirements_dev.txt
66
commands =
7-
pytest {posargs}
7+
pytest --cov=cert_chain_resolver --cov-append --cov-report=term-missing {posargs}
8+
depends =
9+
{py27,py312}: clean
10+
report: py27,py312
811

912
[testenv:mypy]
1013
basepython = python3.12
1114
deps =
1215
mypy
1316
-rrequirements_dev.txt
1417
commands = mypy cert_chain_resolver
18+
19+
[testenv:report]
20+
deps = coverage
21+
skip_install = true
22+
commands =
23+
coverage report
24+
coverage html
25+
26+
[testenv:clean]
27+
deps = coverage
28+
skip_install = true
29+
commands = coverage erase

0 commit comments

Comments
 (0)