diff --git a/.github/workflows/unit-tests.yaml b/.github/workflows/github-ci.yaml similarity index 51% rename from .github/workflows/unit-tests.yaml rename to .github/workflows/github-ci.yaml index e18da4ae4..4f2bffd2e 100644 --- a/.github/workflows/unit-tests.yaml +++ b/.github/workflows/github-ci.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,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 @@ -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/* \ 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 xml + - name: Upload Coverage to Codecov + uses: codecov/codecov-action@v2 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./coverage.xml \ No newline at end of file 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/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 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