Skip to content

Commit

Permalink
Combine coverage (#755)
Browse files Browse the repository at this point in the history
* Replace pytest-cov by coverage
* Fix coverage badge
  • Loading branch information
MartinThoma authored Apr 15, 2022
1 parent 01a1242 commit fe45d2e
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 33 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Unit Tests
name: CI

on:
push:
Expand All @@ -11,47 +11,47 @@ on:

jobs:
tests:
name: pytest on ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["2.7", "3.6", "3.7", "3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- name: Checkout Code
uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Upgrade pip
run: |
python -m pip install --upgrade pip
- name: Install requirements (python 3)
- name: Install requirements (Python 3)
if: matrix.python-version != '2.7'
run: |
pip install -r requirements/ci.txt
- name: Install requirements (python 2)
- name: Install requirements (Python 2)
if: matrix.python-version == '2.7'
run: |
pip install pillow pytest pytest-cov
- name: Install module
pip install pillow pytest coverage
- name: Install PyPDF2
run: |
pip install .
- name: Test with flake8
run: |
flake8 . --ignore=E203,W503,W504,E,F403,F405
if: matrix.python-version != '2.7'

- name: Test with pytest
run: |
pytest Tests --cov --cov-report term-missing --cov-report xml -vv
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v2
python -m coverage run --parallel-mode -m pytest Tests -vv
- name: Upload coverage data
uses: actions/upload-artifact@v3
with:
files: ./coverage.xml
name: coverage-data
path: .coverage.*
if-no-files-found: ignore

package:
name: Build & verify package
runs-on: ubuntu-latest
Expand All @@ -67,4 +67,32 @@ jobs:
- run: ls -l dist
- run: check-wheel-contents dist/*.whl
- name: Check long_description
run: python -m twine check dist/*
run: python -m twine check dist/*

coverage:
name: Combine & check coverage.
runs-on: ubuntu-latest
needs: tests

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
# Use latest Python, so it understands all syntax.
python-version: ${{env.PYTHON_LATEST}}

- run: python -m pip install --upgrade coverage[toml]

- uses: actions/download-artifact@v3
with:
name: coverage-data

- name: Combine coverage & create xml report
run: |
python -m coverage combine
python -m coverage xml
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v2
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ build
dist/*

# Code coverage artifacts
.coverage
.coverage*
coverage.xml

# Editors / IDEs
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
[![Python Support](https://img.shields.io/pypi/pyversions/PyPDF2.svg)](https://pypi.org/project/PyPDF2/)
[![](https://img.shields.io/badge/-documentation-green)](https://pypdf2.readthedocs.io/en/latest/)
![GitHub last commit](https://img.shields.io/github/last-commit/py-pdf/PyPDF2)
[![codecov](https://codecov.io/gh/py-pdf/PyPDF2/branch/master/graph/badge.svg?token=id42cGNZ5Z)](https://codecov.io/gh/py-pdf/PyPDF2)
[![codecov](https://codecov.io/gh/py-pdf/PyPDF2/branch/main/graph/badge.svg?token=id42cGNZ5Z)](https://codecov.io/gh/py-pdf/PyPDF2)

# PyPDF2

Expand Down
6 changes: 3 additions & 3 deletions requirements/ci.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pytest
coverage
flake8
flake8-bugbear
flake8_implicit_str_concat
pytest-cov
flake8-bugbear
pillow
pytest
12 changes: 3 additions & 9 deletions requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ attrs==20.3.0
# flake8-bugbear
# flake8-implicit-str-concat
# pytest
coverage[toml]==6.2
# via pytest-cov
coverage==6.2
# via -r requirements/ci.in
flake8==4.0.1
# via
# -r requirements/ci.in
Expand Down Expand Up @@ -45,15 +45,9 @@ pyflakes==2.4.0
pyparsing==3.0.7
# via packaging
pytest==7.0.1
# via
# -r requirements/ci.in
# pytest-cov
pytest-cov==3.0.0
# via -r requirements/ci.in
tomli==1.2.3
# via
# coverage
# pytest
# via pytest
typing-extensions==4.1.1
# via importlib-metadata
zipp==3.6.0
Expand Down
2 changes: 2 additions & 0 deletions requirements/dev.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
black
pip-tools
pre-commit
pytest-cov
twine
wheel
81 changes: 80 additions & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,66 +4,145 @@
#
# pip-compile requirements/dev.in
#
attrs==21.4.0
# via pytest
black==22.3.0
# via -r requirements/dev.in
bleach==4.1.0
# via readme-renderer
certifi==2021.10.8
# via requests
cffi==1.15.0
# via cryptography
cfgv==3.3.1
# via pre-commit
charset-normalizer==2.0.12
# via requests
click==8.0.4
# via
# black
# pip-tools
colorama==0.4.4
# via twine
coverage[toml]==6.2
# via pytest-cov
cryptography==36.0.2
# via secretstorage
dataclasses==0.8
# via black
distlib==0.3.4
# via virtualenv
docutils==0.18.1
# via readme-renderer
filelock==3.4.1
# via virtualenv
identify==2.4.4
# via pre-commit
idna==3.3
# via requests
importlib-metadata==4.8.3
# via
# click
# keyring
# pep517
# pluggy
# pre-commit
# pytest
# twine
# virtualenv
importlib-resources==5.2.3
# via
# pre-commit
# tqdm
# virtualenv
iniconfig==1.1.1
# via pytest
jeepney==0.7.1
# via
# keyring
# secretstorage
keyring==23.4.1
# via twine
mypy-extensions==0.4.3
# via black
nodeenv==1.6.0
# via pre-commit
packaging==21.3
# via
# bleach
# pytest
pathspec==0.9.0
# via black
pep517==0.12.0
# via pip-tools
pip-tools==6.4.0
# via -r requirements/dev.in
pkginfo==1.8.2
# via twine
platformdirs==2.4.0
# via
# black
# virtualenv
pluggy==1.0.0
# via pytest
pre-commit==2.17.0
# via -r requirements/dev.in
py==1.11.0
# via pytest
pycparser==2.21
# via cffi
pygments==2.11.2
# via readme-renderer
pyparsing==3.0.8
# via packaging
pytest==7.0.1
# via pytest-cov
pytest-cov==3.0.0
# via -r requirements/dev.in
pyyaml==6.0
# via pre-commit
readme-renderer==34.0
# via twine
requests==2.27.1
# via
# requests-toolbelt
# twine
requests-toolbelt==0.9.1
# via twine
rfc3986==1.5.0
# via twine
secretstorage==3.3.1
# via keyring
six==1.16.0
# via virtualenv
# via
# bleach
# virtualenv
toml==0.10.2
# via pre-commit
tomli==1.2.3
# via
# black
# coverage
# pep517
# pytest
tqdm==4.64.0
# via twine
twine==3.8.0
# via -r requirements/dev.in
typed-ast==1.5.2
# via black
typing-extensions==4.1.1
# via
# black
# importlib-metadata
urllib3==1.26.9
# via
# requests
# twine
virtualenv==20.14.0
# via pre-commit
webencodings==0.5.1
# via bleach
wheel==0.37.1
# via
# -r requirements/dev.in
Expand Down

0 comments on commit fe45d2e

Please sign in to comment.