-
Notifications
You must be signed in to change notification settings - Fork 1.4k
226 lines (209 loc) · 6.75 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# 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, 2.0.0-dev ]
paths-ignore:
- '**/*.md'
- '**/*.rst'
pull_request:
branches: [ main, 2.0.0-dev ]
paths-ignore:
- '**/*.md'
- '**/*.rst'
workflow_dispatch:
jobs:
test_windows:
name: pytest on windows
runs-on: windows-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Setup Python (3.11+)
uses: actions/setup-python@v4
with:
python-version: 3.12 # latest stable python
allow-prereleases: true
- name: Upgrade pip
run: |
python -m pip install --upgrade pip
- name: Install requirements (Python 3.11+)
run: |
pip install -r requirements/ci-3.11.txt
- name: Install cryptography
run: |
pip install cryptography
- name: Install pypdf
run: |
pip install .
- name: Prepare
run: |
python -c "from tests import download_test_pdfs; download_test_pdfs()"
- name: Test with pytest
run: |
python -m pytest tests --cov=pypdf --cov-append -n auto -vv
tests:
name: "pytest on ${{ matrix.python-version }} (crypto-lib: ${{ matrix.use-crypto-lib }})"
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"]
use-crypto-lib: ["cryptography"]
include:
- python-version: "3.6"
use-crypto-lib: "pycryptodome"
- python-version: "3.7"
use-crypto-lib: "none"
steps:
- name: Update APT packages
run:
sudo apt-get update
- name: Install APT dependencies
run:
sudo apt-get install ghostscript
- name: Checkout Code
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Cache Downloaded Files
id: cache-downloaded-files
uses: actions/cache@v3
with:
path: '**/tests/pdf_cache/*'
key: cache-downloaded-files
- name: Setup Python
uses: actions/setup-python@v4
if: matrix.python-version == '3.6' || matrix.python-version == '3.7' || matrix.python-version == '3.8' || matrix.python-version == '3.9' || matrix.python-version == '3.10'
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: '**/requirements/ci.txt'
- name: Setup Python (3.11+)
uses: actions/setup-python@v4
if: matrix.python-version == '3.11' || matrix.python-version == '3.12'
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
cache: 'pip'
cache-dependency-path: '**/requirements/ci-3.11.txt'
- name: Upgrade pip
run: |
python -m pip install --upgrade pip
- name: Install requirements (Python 3)
run: |
pip install -r requirements/ci.txt
if: matrix.python-version == '3.6' || matrix.python-version == '3.7' || matrix.python-version == '3.8' || matrix.python-version == '3.9' || matrix.python-version == '3.10'
- name: Install requirements (Python 3.11+)
run: |
pip install -r requirements/ci-3.11.txt
if: matrix.python-version == '3.11' || matrix.python-version == '3.12'
- name: Remove pycryptodome and cryptography
run: |
pip uninstall pycryptodome cryptography -y
- name: Install cryptography
run: |
pip install cryptography
if: matrix.use-crypto-lib == 'cryptography'
- name: Install pycryptodome
run: |
pip install pycryptodome
if: matrix.use-crypto-lib == 'pycryptodome'
- name: Install pypdf
run: |
pip install .
- name: Prepare
run: |
python -c "from tests import download_test_pdfs; download_test_pdfs()"
- name: Test with pytest
run: |
python -m pytest tests --cov=pypdf --cov-append -n auto -vv
- name: Rename coverage data file
run: mv .coverage ".coverage.$RANDOM"
- name: Upload coverage data
uses: actions/upload-artifact@v3
with:
name: coverage-data
path: .coverage.*
if-no-files-found: ignore
codestyle:
name: Check code style issues
runs-on: ubuntu-20.04
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Setup Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: 'pip'
cache-dependency-path: '**/requirements/ci-3.11.txt'
- name: Upgrade pip
run: |
python -m pip install --upgrade pip
- name: Install requirements
run: |
pip install -r requirements/ci-3.11.txt
- name: Install pypdf
run: |
pip install .
- name: Test with ruff
run: |
echo `ruff --version`
ruff .
- name: Test with mypy
run : |
mypy pypdf
package:
name: Build & verify package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: ${{env.PYTHON_LATEST}}
- run: python -m pip install flit check-wheel-contents
- run: flit build
- run: ls -l dist
- run: check-wheel-contents dist/*.whl
- name: Test installing package
run: python -m pip install .
- name: Test running installed package
working-directory: /tmp
run: python -c "import pypdf;print(pypdf.__version__)"
coverage:
name: Combine & check coverage.
runs-on: ubuntu-latest
needs: tests
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
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: Check Number of Downloaded Files
run: |
downloaded_files_count=$(find \.coverage* -type f | wc -l)
if [ $downloaded_files_count -eq 8 ]; then
echo "The expected number of files (8) were downloaded."
else
echo "ERROR: Expected 8 files, but found $downloaded_files_count files."
exit 1
fi
- name: Combine coverage & create xml report
run: |
python -m coverage combine
python -m coverage xml
- name: Upload Coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml