-
Notifications
You must be signed in to change notification settings - Fork 0
307 lines (251 loc) · 10.7 KB
/
ci.yml
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
name: 'CI: Test / Lint / Build'
on:
pull_request:
push:
branches:
- master
- develop
- 'release/**'
- 'workflow/**'
tags:
- 'v*'
schedule:
- cron: '0 3 * * *'
jobs:
test-venv:
strategy:
matrix:
python-version: ['3.x', '3.10', '3.9', '3.8', 'pypy3.9', 'pypy3.8']
platform: [ubuntu, windows]
architecture: [x64, x86]
exclude:
- platform: ubuntu
architecture: x86
- platform: windows
python-version: '3.10'
- platform: windows
python-version: '3.9'
- platform: windows
python-version: 'pypy3.9'
- platform: windows
python-version: 'pypy3.8'
name: Test venv / ${{ matrix.python-version }}-${{ matrix.platform }}-${{ matrix.architecture }}
runs-on: ${{ matrix.platform }}-latest
steps:
- name: Check out repository and assets
uses: actions/checkout@v3
with:
persist-credentials: false
submodules: recursive
- name: Install required Ubuntu packages
if: ${{ matrix.platform == 'ubuntu' }}
run: |
sudo -n apt-get update -y
sudo -n apt-get install -y --no-upgrade libcurl4-openssl-dev
- name: Set up Python ${{ matrix.python-version }}-${{ matrix.architecture }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: ${{ matrix.architecture }}
- name: Install package in editable mode and its dependencies
shell: sh
run: ./venv.sh install-venv
- name: Disable static analysis coverage on PyPy
if: startsWith(matrix.python-version, 'pypy')
run: sed -i "/^addopts\>/s/^/#/" pyproject.toml
- name: Tests with code coverage and static analysis
id: test
shell: sh
run: ./venv.sh pytest
- name: Archive code coverage report
if: ((success() && matrix.python-version == '3.x' && matrix.platform == 'ubuntu') || steps.test.conclusion == 'failure') && !startsWith(matrix.python-version, 'pypy')
uses: actions/upload-artifact@v3
with:
name: coverage-report-${{ github.job }}-${{ matrix.python-version }}-${{ matrix.platform }}-${{ matrix.architecture }}
path: build/tests/coverage/
- name: Security issues static analysis
shell: sh
run: ./venv.sh misc/scripts/run-bandit.sh
- name: Reinstall minimal required package versions
if: ${{ matrix.platform != 'windows' }}
shell: sh
run: ./venv.sh downgrade-venv
- name: Same tests as before, on minimal required package versions
if: ${{ matrix.platform != 'windows' }}
shell: sh
run: |
rm -r build/tests
./venv.sh pytest
test-conda:
strategy:
matrix:
python-version: ['3.11', '3.8']
platform: [ubuntu, windows, macos]
name: Test miniconda / ${{ matrix.python-version }}-${{ matrix.platform }}
runs-on: ${{ matrix.platform }}-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Set up Miniconda with Python ${{ matrix.python-version }} and package dependencies
uses: conda-incubator/setup-miniconda@v2
with:
python-version: ${{ matrix.python-version }}
miniconda-version: latest
auto-update-conda: true
channel-priority: strict
show-channel-urls: true
environment-file: misc/conda/test-environment.yml
- name: Tests with code coverage and static analysis
id: test
shell: bash -el {0}
run: pytest
- name: Archive code coverage report
if: ((success() && matrix.python-version == '3.11' && matrix.platform != 'ubuntu') || steps.test.conclusion == 'failure')
uses: actions/upload-artifact@v3
with:
name: coverage-report-${{ github.job }}-${{ matrix.python-version }}-${{ matrix.platform }}
path: build/tests/coverage/
test-platform-packages:
name: Test Linux / platform / wheel
needs: build-dist
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Install maximal subset of platform Python packages
run: |
sudo -n apt-get update -y
sudo -n apt-get install -y --no-upgrade libcurl4-openssl-dev
sudo -n apt-get install -y python3-{pycurl,tenacity,tqdm}
sudo -n apt-get install -y python3-{bandit,filelock,mypy,pytest,setuptools-scm,werkzeug,wheel,cairo} black
sudo -n apt-get install -y python3-pytest-{cov,pylint,repeat,sugar,xdist}
- name: Download package distribution
uses: actions/download-artifact@v3
with:
name: curldl-dist
path: dist
- name: Install package wheel and its platform-unavailable dependencies
run: |
find src -mindepth 1 -delete
pip3 install --user $(echo dist/curldl-*.whl)'[test]'
pip3 check
- name: Tests with minimal static analysis
run: python3 -m pytest --no-cov
test-dependency-sanity:
name: Sanity on Linux / platform / wheel
needs: build-dist
runs-on: ubuntu-latest
steps:
- name: Install minimal subset of platform Python packages
run: |
sudo -n apt-get update -y
sudo -n apt-get install -y python3-{pycurl,tenacity,tqdm,cairo}
- name: Download package distribution
uses: actions/download-artifact@v3
with:
name: curldl-dist
path: dist
- name: Install package wheel
run: |
pip3 install --user dist/curldl-*.whl
pip3 check
- name: Sanity tests for package availability
run: |
curldl -h
curldl -V
curldl -vpo test.html https://github.com/
build-dist:
name: Build and test wheel / venv / docs
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
- name: Install required Ubuntu packages
run: |
sudo -n apt-get update -y
sudo -n apt-get install -y --no-upgrade libcurl4-openssl-dev
- name: Set up latest Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install package in editable mode (temporarily) and its dependencies
run: ./venv.sh install-venv
- name: Build Sphinx documentation
run: ./venv.sh misc/scripts/run-sphinx.sh
- name: Upload documentation artifacts
uses: actions/upload-artifact@v3
with:
name: curldl-docs
path: build/docs/
- name: Build the package sdist + wheel and install wheel
run: |
./venv.sh pip uninstall -y curldl
./venv.sh python -m build
find src -mindepth 1 -delete
./venv.sh twine check --strict dist/*
./venv.sh pip install dist/curldl-*.whl
./venv.sh pip check
- name: Tests with minimal static analysis
run: ./venv.sh pytest --no-cov
- name: Upload build artifacts
uses: actions/upload-artifact@v3
with:
name: curldl-dist
path: dist/
publish-dist:
name: Publish to PyPI and GitHub on version tag
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs: [build-dist, test-dependency-sanity, test-platform-packages, test-venv, test-conda]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download package distribution artifact
uses: actions/download-artifact@v3
with:
name: curldl-dist
path: dist
- name: Publish distribution to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_CURLDL_TOKEN }}
repository-url: https://test.pypi.org/legacy/
- name: Publish Release to GitHub
uses: softprops/action-gh-release@v1
with:
files: dist/*
draft: ${{ contains(github.ref, 'dev') }}
prerelease: ${{ contains(github.ref, 'rc') || contains(github.ref, 'a') || contains(github.ref, 'b') }}
- name: Publish distribution to PyPI if non-dev tag
if: (!contains(github.ref, 'dev'))
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_CURLDL_TOKEN }}
upload-coverage:
name: Upload Coverage Reports to Codecov
needs: [test-venv]
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
persist-credentials: false
- name: Download code coverage artifact
uses: actions/download-artifact@v3
with:
name: coverage-report-test-venv-3.x-ubuntu-x64
path: coverage
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
directory: coverage
fail_ci_if_error: true
verbose: true