98 lines (86 loc) · 2.71 KB
/
github-ci.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# 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: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
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:
- 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)
if: matrix.python-version != '2.7'
run: |
pip install -r requirements/ci.txt
- name: Install requirements (Python 2)
if: matrix.python-version == '2.7'
run: |
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: |
python -m coverage run --parallel-mode -m pytest Tests -vv
- name: Upload coverage data
uses: actions/upload-artifact@v3
with:
name: coverage-data
path: .coverage.*
if-no-files-found: ignore
package:
name: Build & verify package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
with:
python-version: ${{env.PYTHON_LATEST}}
- run: python -m pip install build twine check-wheel-contents
- run: python -m build --sdist --wheel .
- run: ls -l dist
- run: check-wheel-contents dist/*.whl
- name: Check long_description
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