Skip to content

Commit fe45d2e

Browse files
authored
Combine coverage (#755)
* Replace pytest-cov by coverage * Fix coverage badge
1 parent 01a1242 commit fe45d2e

File tree

7 files changed

+136
-33
lines changed

7 files changed

+136
-33
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
22
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
33

4-
name: Unit Tests
4+
name: CI
55

66
on:
77
push:
@@ -11,47 +11,47 @@ on:
1111

1212
jobs:
1313
tests:
14+
name: pytest on ${{ matrix.python-version }}
1415
runs-on: ubuntu-latest
1516
strategy:
1617
matrix:
1718
python-version: ["2.7", "3.6", "3.7", "3.8", "3.9", "3.10"]
1819

1920
steps:
20-
- uses: actions/checkout@v3
21-
- uses: actions/setup-python@v3
21+
- name: Checkout Code
22+
uses: actions/checkout@v3
23+
- name: Setup Python
24+
uses: actions/setup-python@v3
2225
with:
2326
python-version: ${{ matrix.python-version }}
24-
2527
- name: Upgrade pip
2628
run: |
2729
python -m pip install --upgrade pip
28-
29-
- name: Install requirements (python 3)
30+
- name: Install requirements (Python 3)
3031
if: matrix.python-version != '2.7'
3132
run: |
3233
pip install -r requirements/ci.txt
33-
- name: Install requirements (python 2)
34+
- name: Install requirements (Python 2)
3435
if: matrix.python-version == '2.7'
3536
run: |
36-
pip install pillow pytest pytest-cov
37-
38-
- name: Install module
37+
pip install pillow pytest coverage
38+
- name: Install PyPDF2
3939
run: |
4040
pip install .
41-
4241
- name: Test with flake8
4342
run: |
4443
flake8 . --ignore=E203,W503,W504,E,F403,F405
4544
if: matrix.python-version != '2.7'
46-
4745
- name: Test with pytest
4846
run: |
49-
pytest Tests --cov --cov-report term-missing --cov-report xml -vv
50-
51-
- name: Upload Coverage to Codecov
52-
uses: codecov/codecov-action@v2
47+
python -m coverage run --parallel-mode -m pytest Tests -vv
48+
- name: Upload coverage data
49+
uses: actions/upload-artifact@v3
5350
with:
54-
files: ./coverage.xml
51+
name: coverage-data
52+
path: .coverage.*
53+
if-no-files-found: ignore
54+
5555
package:
5656
name: Build & verify package
5757
runs-on: ubuntu-latest
@@ -67,4 +67,32 @@ jobs:
6767
- run: ls -l dist
6868
- run: check-wheel-contents dist/*.whl
6969
- name: Check long_description
70-
run: python -m twine check dist/*
70+
run: python -m twine check dist/*
71+
72+
coverage:
73+
name: Combine & check coverage.
74+
runs-on: ubuntu-latest
75+
needs: tests
76+
77+
steps:
78+
- uses: actions/checkout@v3
79+
- uses: actions/setup-python@v3
80+
with:
81+
# Use latest Python, so it understands all syntax.
82+
python-version: ${{env.PYTHON_LATEST}}
83+
84+
- run: python -m pip install --upgrade coverage[toml]
85+
86+
- uses: actions/download-artifact@v3
87+
with:
88+
name: coverage-data
89+
90+
- name: Combine coverage & create xml report
91+
run: |
92+
python -m coverage combine
93+
python -m coverage xml
94+
- name: Upload Coverage to Codecov
95+
uses: codecov/codecov-action@v2
96+
with:
97+
token: ${{ secrets.CODECOV_TOKEN }}
98+
files: ./coverage.xml

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ build
88
dist/*
99

1010
# Code coverage artifacts
11-
.coverage
11+
.coverage*
1212
coverage.xml
1313

1414
# Editors / IDEs

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
[![Python Support](https://img.shields.io/pypi/pyversions/PyPDF2.svg)](https://pypi.org/project/PyPDF2/)
33
[![](https://img.shields.io/badge/-documentation-green)](https://pypdf2.readthedocs.io/en/latest/)
44
![GitHub last commit](https://img.shields.io/github/last-commit/py-pdf/PyPDF2)
5-
[![codecov](https://codecov.io/gh/py-pdf/PyPDF2/branch/master/graph/badge.svg?token=id42cGNZ5Z)](https://codecov.io/gh/py-pdf/PyPDF2)
5+
[![codecov](https://codecov.io/gh/py-pdf/PyPDF2/branch/main/graph/badge.svg?token=id42cGNZ5Z)](https://codecov.io/gh/py-pdf/PyPDF2)
66

77
# PyPDF2
88

requirements/ci.in

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
pytest
1+
coverage
22
flake8
3-
flake8-bugbear
43
flake8_implicit_str_concat
5-
pytest-cov
4+
flake8-bugbear
65
pillow
6+
pytest

requirements/ci.txt

+3-9
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ attrs==20.3.0
99
# flake8-bugbear
1010
# flake8-implicit-str-concat
1111
# pytest
12-
coverage[toml]==6.2
13-
# via pytest-cov
12+
coverage==6.2
13+
# via -r requirements/ci.in
1414
flake8==4.0.1
1515
# via
1616
# -r requirements/ci.in
@@ -45,15 +45,9 @@ pyflakes==2.4.0
4545
pyparsing==3.0.7
4646
# via packaging
4747
pytest==7.0.1
48-
# via
49-
# -r requirements/ci.in
50-
# pytest-cov
51-
pytest-cov==3.0.0
5248
# via -r requirements/ci.in
5349
tomli==1.2.3
54-
# via
55-
# coverage
56-
# pytest
50+
# via pytest
5751
typing-extensions==4.1.1
5852
# via importlib-metadata
5953
zipp==3.6.0

requirements/dev.in

+2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
black
22
pip-tools
33
pre-commit
4+
pytest-cov
5+
twine
46
wheel

requirements/dev.txt

+80-1
Original file line numberDiff line numberDiff line change
@@ -4,66 +4,145 @@
44
#
55
# pip-compile requirements/dev.in
66
#
7+
attrs==21.4.0
8+
# via pytest
79
black==22.3.0
810
# via -r requirements/dev.in
11+
bleach==4.1.0
12+
# via readme-renderer
13+
certifi==2021.10.8
14+
# via requests
15+
cffi==1.15.0
16+
# via cryptography
917
cfgv==3.3.1
1018
# via pre-commit
19+
charset-normalizer==2.0.12
20+
# via requests
1121
click==8.0.4
1222
# via
1323
# black
1424
# pip-tools
25+
colorama==0.4.4
26+
# via twine
27+
coverage[toml]==6.2
28+
# via pytest-cov
29+
cryptography==36.0.2
30+
# via secretstorage
1531
dataclasses==0.8
1632
# via black
1733
distlib==0.3.4
1834
# via virtualenv
35+
docutils==0.18.1
36+
# via readme-renderer
1937
filelock==3.4.1
2038
# via virtualenv
2139
identify==2.4.4
2240
# via pre-commit
41+
idna==3.3
42+
# via requests
2343
importlib-metadata==4.8.3
2444
# via
2545
# click
46+
# keyring
2647
# pep517
48+
# pluggy
2749
# pre-commit
50+
# pytest
51+
# twine
2852
# virtualenv
2953
importlib-resources==5.2.3
3054
# via
3155
# pre-commit
56+
# tqdm
3257
# virtualenv
58+
iniconfig==1.1.1
59+
# via pytest
60+
jeepney==0.7.1
61+
# via
62+
# keyring
63+
# secretstorage
64+
keyring==23.4.1
65+
# via twine
3366
mypy-extensions==0.4.3
3467
# via black
3568
nodeenv==1.6.0
3669
# via pre-commit
70+
packaging==21.3
71+
# via
72+
# bleach
73+
# pytest
3774
pathspec==0.9.0
3875
# via black
3976
pep517==0.12.0
4077
# via pip-tools
4178
pip-tools==6.4.0
4279
# via -r requirements/dev.in
80+
pkginfo==1.8.2
81+
# via twine
4382
platformdirs==2.4.0
4483
# via
4584
# black
4685
# virtualenv
86+
pluggy==1.0.0
87+
# via pytest
4788
pre-commit==2.17.0
4889
# via -r requirements/dev.in
90+
py==1.11.0
91+
# via pytest
92+
pycparser==2.21
93+
# via cffi
94+
pygments==2.11.2
95+
# via readme-renderer
96+
pyparsing==3.0.8
97+
# via packaging
98+
pytest==7.0.1
99+
# via pytest-cov
100+
pytest-cov==3.0.0
101+
# via -r requirements/dev.in
49102
pyyaml==6.0
50103
# via pre-commit
104+
readme-renderer==34.0
105+
# via twine
106+
requests==2.27.1
107+
# via
108+
# requests-toolbelt
109+
# twine
110+
requests-toolbelt==0.9.1
111+
# via twine
112+
rfc3986==1.5.0
113+
# via twine
114+
secretstorage==3.3.1
115+
# via keyring
51116
six==1.16.0
52-
# via virtualenv
117+
# via
118+
# bleach
119+
# virtualenv
53120
toml==0.10.2
54121
# via pre-commit
55122
tomli==1.2.3
56123
# via
57124
# black
125+
# coverage
58126
# pep517
127+
# pytest
128+
tqdm==4.64.0
129+
# via twine
130+
twine==3.8.0
131+
# via -r requirements/dev.in
59132
typed-ast==1.5.2
60133
# via black
61134
typing-extensions==4.1.1
62135
# via
63136
# black
64137
# importlib-metadata
138+
urllib3==1.26.9
139+
# via
140+
# requests
141+
# twine
65142
virtualenv==20.14.0
66143
# via pre-commit
144+
webencodings==0.5.1
145+
# via bleach
67146
wheel==0.37.1
68147
# via
69148
# -r requirements/dev.in

0 commit comments

Comments
 (0)