From a467ad7496fbef8db2d249d150a2ca5572863f2c Mon Sep 17 00:00:00 2001 From: Martin Thoma Date: Fri, 15 Apr 2022 08:06:23 +0200 Subject: [PATCH 1/7] Combine coverage --- .github/workflows/unit-tests.yaml | 45 ++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml index e18da4ae4..3a89b5e08 100644 --- a/.github/workflows/unit-tests.yaml +++ b/.github/workflows/unit-tests.yaml @@ -48,10 +48,13 @@ jobs: run: | pytest Tests --cov --cov-report term-missing --cov-report xml -vv - - name: Upload Coverage to Codecov - uses: codecov/codecov-action@v2 + - 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 @@ -67,4 +70,38 @@ jobs: - run: ls -l dist - run: check-wheel-contents dist/*.whl - name: Check long_description - run: python -m twine check dist/* \ No newline at end of file + 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 html --skip-covered --skip-empty + python -m coverage xml + - name: Upload HTML report + uses: actions/upload-artifact@v3 + with: + name: html-report + path: htmlcov + - name: Upload Coverage to Codecov + uses: codecov/codecov-action@v2 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./coverage.xml \ No newline at end of file From ca6cbb663ef766003fdd7b95c7435580116dc8e4 Mon Sep 17 00:00:00 2001 From: Martin Thoma Date: Fri, 15 Apr 2022 08:13:20 +0200 Subject: [PATCH 2/7] Dont use pytest-cov, use coverage --- .github/workflows/unit-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml index 3a89b5e08..bdd0d9789 100644 --- a/.github/workflows/unit-tests.yaml +++ b/.github/workflows/unit-tests.yaml @@ -46,7 +46,7 @@ jobs: - name: Test with pytest run: | - pytest Tests --cov --cov-report term-missing --cov-report xml -vv + python -m coverage run -m pytest Tests -vv - name: Upload coverage data uses: actions/upload-artifact@v3 From 9b72a415c59ef7b491f5b7f03b303efcd1380741 Mon Sep 17 00:00:00 2001 From: Martin Thoma Date: Fri, 15 Apr 2022 08:19:09 +0200 Subject: [PATCH 3/7] Use parallel mode --- .github/workflows/unit-tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml index bdd0d9789..bbc27579c 100644 --- a/.github/workflows/unit-tests.yaml +++ b/.github/workflows/unit-tests.yaml @@ -46,7 +46,7 @@ jobs: - name: Test with pytest run: | - python -m coverage run -m pytest Tests -vv + python -m coverage run --parallel-mode -m pytest Tests -vv - name: Upload coverage data uses: actions/upload-artifact@v3 From e7dcb7b5b789d1834bfc4d305c6ffb61e8de0c6c Mon Sep 17 00:00:00 2001 From: Martin Thoma Date: Fri, 15 Apr 2022 08:32:15 +0200 Subject: [PATCH 4/7] Names --- .github/workflows/unit-tests.yaml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/unit-tests.yaml index bbc27579c..f307e1f1e 100644 --- a/.github/workflows/unit-tests.yaml +++ b/.github/workflows/unit-tests.yaml @@ -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: @@ -11,6 +11,7 @@ on: jobs: tests: + name: pytest on ${{ matrix.python-version }} runs-on: ubuntu-latest strategy: matrix: @@ -93,13 +94,7 @@ jobs: - name: Combine coverage & create xml report run: | python -m coverage combine - python -m coverage html --skip-covered --skip-empty python -m coverage xml - - name: Upload HTML report - uses: actions/upload-artifact@v3 - with: - name: html-report - path: htmlcov - name: Upload Coverage to Codecov uses: codecov/codecov-action@v2 with: From 6f458a264c75d4f5828a04e0ae0f39cbc2e90656 Mon Sep 17 00:00:00 2001 From: Martin Thoma Date: Fri, 15 Apr 2022 08:33:31 +0200 Subject: [PATCH 5/7] Fix badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5c790a497..884e9a4cf 100644 --- a/README.md +++ b/README.md @@ -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 From 001da9e82ad26639cb67d92d58973305eb32d84a Mon Sep 17 00:00:00 2001 From: Martin Thoma Date: Fri, 15 Apr 2022 08:44:11 +0200 Subject: [PATCH 6/7] Remove pytest-cov from ci --- .../{unit-tests.yaml => github-ci.yaml} | 20 ++--- .gitignore | 2 +- requirements/ci.in | 6 +- requirements/ci.txt | 12 +-- requirements/dev.in | 2 + requirements/dev.txt | 81 ++++++++++++++++++- 6 files changed, 97 insertions(+), 26 deletions(-) rename .github/workflows/{unit-tests.yaml => github-ci.yaml} (90%) diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/github-ci.yaml similarity index 90% rename from .github/workflows/unit-tests.yaml rename to .github/workflows/github-ci.yaml index f307e1f1e..4e5b14ed6 100644 --- a/.github/workflows/unit-tests.yaml +++ b/.github/workflows/github-ci.yaml @@ -18,37 +18,33 @@ jobs: 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 + - 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: | python -m coverage run --parallel-mode -m pytest Tests -vv - - name: Upload coverage data uses: actions/upload-artifact@v3 with: diff --git a/.gitignore b/.gitignore index 6de9eba5f..c47edb777 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,7 @@ build dist/* # Code coverage artifacts -.coverage +.coverage* coverage.xml # Editors / IDEs diff --git a/requirements/ci.in b/requirements/ci.in index 3545b25f2..a7592ecf5 100644 --- a/requirements/ci.in +++ b/requirements/ci.in @@ -1,6 +1,6 @@ -pytest +coverage flake8 -flake8-bugbear flake8_implicit_str_concat -pytest-cov +flake8-bugbear pillow +pytest \ No newline at end of file diff --git a/requirements/ci.txt b/requirements/ci.txt index c926afe44..fcca42ffe 100644 --- a/requirements/ci.txt +++ b/requirements/ci.txt @@ -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 @@ -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 diff --git a/requirements/dev.in b/requirements/dev.in index f01898fea..6a2b12f2b 100644 --- a/requirements/dev.in +++ b/requirements/dev.in @@ -1,4 +1,6 @@ black pip-tools pre-commit +pytest-cov +twine wheel diff --git a/requirements/dev.txt b/requirements/dev.txt index 71a5ee617..ff79c1b38 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -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 From 5e6409d7a4d999544a3dd47dfd22c892c3e7585a Mon Sep 17 00:00:00 2001 From: Martin Thoma Date: Fri, 15 Apr 2022 08:45:43 +0200 Subject: [PATCH 7/7] Python 2.7 extra --- .github/workflows/github-ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/github-ci.yaml b/.github/workflows/github-ci.yaml index 4e5b14ed6..4f2bffd2e 100644 --- a/.github/workflows/github-ci.yaml +++ b/.github/workflows/github-ci.yaml @@ -34,7 +34,7 @@ jobs: - name: Install requirements (Python 2) if: matrix.python-version == '2.7' run: | - pip install pillow pytest + pip install pillow pytest coverage - name: Install PyPDF2 run: | pip install .