-
Notifications
You must be signed in to change notification settings - Fork 14
358 lines (303 loc) · 11.4 KB
/
build-wheels.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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
name: Build Wheels
on:
push:
tags:
- '*'
branches:
- develop
- ci/*
pull_request:
types:
- opened
- synchronize
branches:
- develop
env:
PYTHON_VERSION: "3.12"
FORCE_COLOR: "1"
jobs:
build-wheels:
runs-on: ${{ matrix.os }}
strategy:
matrix:
# os: [ ubuntu-latest, windows-latest, macos-12 ]
os: [ ubuntu-latest ]
env:
CIBW_BUILD: "cp312*"
CIBW_SKIP: "*-musllinux*"
CIBW_ARCHS_MACOS: "x86_64 arm64"
CIBW_ARCHS_LINUX: "x86_64"
# CIBW_ARCHS_LINUX: "x86_64 aarch64" # https://github.com/pypa/cibuildwheel/issues/1771#issuecomment-1973003145
CIBW_MANYLINUX_X86_64_IMAGE: ghcr.io/chatnoir-eu/resiliparse-manylinux_2_28_x86_64:latest
CIBW_MANYLINUX_AARCH64_IMAGE: ghcr.io/chatnoir-eu/resiliparse-manylinux_2_28_aarch64:latest
CIBW_TEST_SKIP: "*-macosx_arm64 *-manylinux_aarch64" # ARM64 wheels cannot be tested
CIBW_REPAIR_WHEEL_COMMAND_MACOS: >-
DYLD_LIBRARY_PATH=$LIBRARY_PATH delocate-wheel --require-archs {delocate_archs} -w {dest_dir} {wheel}
CIBW_BEFORE_BUILD_WINDOWS: "python -m pip install delvewheel"
CIBW_REPAIR_WHEEL_COMMAND_WINDOWS: >-
delvewheel repair --add-path C:\vcpkg\installed\x64-windows\bin -w {dest_dir} {wheel}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Cache Vcpkg
uses: actions/cache@v4
id: cache-vcpkg
if: runner.os == 'macOS' || runner.os == 'Windows'
with:
path: |
/usr/local/share/vcpkg/installed
C:\vcpkg\installed
key: ${{ runner.os }}-vcpkg-15 # INCREMENT ME!!
- name: Install Vcpkg Dependencies
if: (runner.os == 'macOS' || runner.os == 'Windows') && steps.cache-vcpkg.outputs.cache-hit != 'true'
shell: bash
run: |
set -e
VCPKG_CMD="vcpkg --overlay-ports .vcpkg/ports --overlay-triplets .vcpkg/triplets install"
PKG_LIST="lexbor lz4 re2 uchardet zlib"
if [ -d /usr/local/share/vcpkg/ports ]; then
# MacOS
$VCPKG_CMD --triplet=x64-osx $PKG_LIST
$VCPKG_CMD --triplet=arm64-osx $PKG_LIST
elif [ -d /c/vcpkg ]; then
# Windows
$VCPKG_CMD --triplet=x64-windows $PKG_LIST
else
echo "Unsupported platform." >&2
exit 1
fi
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
# - name: Set up QEMU
# if: runner.os == 'Linux'
# uses: docker/setup-qemu-action@v3
# with:
# platforms: aarch64
- name: Build FastWARC
uses: pypa/[email protected]
with:
package-dir: fastwarc
output-dir: wheelhouse
env:
CIBW_TEST_COMMAND: python -m pytest --capture=sys --verbose {project}/tests/fastwarc
- name: Build Resiliparse
uses: pypa/[email protected]
with:
package-dir: resiliparse
output-dir: wheelhouse
env:
CIBW_BEFORE_TEST: >-
python -c "import glob, platform; open('fastwarc.txt', 'w').write(glob.glob('wheelhouse/FastWARC-*cp' + ''.join(map(str, platform.python_version_tuple()[:2])) + '-*_' + platform.machine().lower() + '.whl')[0])" &&
python -m pip install -r fastwarc.txt
CIBW_TEST_COMMAND: python -m pytest --capture=sys --verbose {project}/tests/resiliparse
- name: Upload Wheels
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.os }}
path: ./wheelhouse/*.whl
# To be merged with the above when https://github.com/pypa/cibuildwheel/issues/1771#issuecomment-1973003145 is fixed
build-wheels-aarch64:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
env:
CIBW_SKIP: "*cp38* *cp39* *-musllinux*"
CIBW_MANYLINUX_AARCH64_IMAGE: ghcr.io/chatnoir-eu/resiliparse-manylinux_2_28_aarch64:latest
CIBW_ARCHS_LINUX: "aarch64"
CIBW_TEST_SKIP: "*"
CIBW_CONTAINER_ENGINE: "docker; create_args: --platform linux/arm64/v8"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Build FastWARC
uses: pypa/[email protected]
with:
package-dir: fastwarc
output-dir: wheelhouse
env:
CIBW_TEST_COMMAND: python -m pytest --capture=sys --verbose {project}/tests/fastwarc
- name: Build Resiliparse
uses: pypa/[email protected]
with:
package-dir: resiliparse
output-dir: wheelhouse
env:
CIBW_BEFORE_TEST: >-
python -c "import glob, platform; open('fastwarc.txt', 'w').write(glob.glob('wheelhouse/FastWARC-*cp' + ''.join(map(str, platform.python_version_tuple()[:2])) + '-*_' + platform.machine().lower() + '.whl')[0])" &&
python -m pip install -r fastwarc.txt
CIBW_TEST_COMMAND: python -m pytest --capture=sys --verbose {project}/tests/resiliparse
- name: Upload Wheels
uses: actions/upload-artifact@v4
with:
name: wheels-ubuntu-latest-aarch64
path: ./wheelhouse/*.whl
build-sdist:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install Build Module
run: python -m pip install build
- name: Build FastWARC Source Dist
run: python -m build --sdist --outdir dist fastwarc
- name: Build Resiliparse Source Dist
run: python -m build --sdist --outdir dist resiliparse
- name: Upload Source Dists
uses: actions/upload-artifact@v4
with:
name: sdist
path: ./dist/*.tar.gz
build-asan:
runs-on: ubuntu-latest
container:
image: ghcr.io/chatnoir-eu/resiliparse-manylinux_2_28_x86_64:latest
env:
DEBUG: "1"
ASAN: "1"
ASAN_OPTIONS: leak_check_at_exit=0
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build Extensions
run: |
set -e
python${PYTHON_VERSION} -m pip install -e "fastwarc[all,test]"
python${PYTHON_VERSION} -m pip install -e "resiliparse[all,test]"
- name: Run Tests
run: |
export LD_PRELOAD="$(ldconfig -p | grep libasan | head -n1 | awk '{print $4}')"
python${PYTHON_VERSION} -m pytest --capture=sys --verbose tests/
build-coverage:
runs-on: ubuntu-latest
container:
image: ghcr.io/chatnoir-eu/resiliparse-manylinux_2_28_x86_64:latest
env:
TRACE: "1"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build Extensions
run: |
set -e
python${PYTHON_VERSION} -m pip install cython codecov-cli
python${PYTHON_VERSION} -m pip install -e "fastwarc[all,test]"
python${PYTHON_VERSION} -m pip install -e "resiliparse[all,test]"
- name: Run Tests
run: python${PYTHON_VERSION} -m pytest --cov --cov-report xml --junitxml=report.junit.xml tests/
# We cannot use the Codecov GitHub action due to incompatible Glibc versions
- name: Upload to Codecov
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
TOKENLESS: ${{ github.event.pull_request.head.label }}
run: |
set -e
PR=""
if [ -n '${{ github.event.pull_request.head.sha }}' ]; then
PR="--pr ${{ github.event.number }}"
fi
python${PYTHON_VERSION} -m codecov_cli.main do-upload \
--file report.junit.xml \
--report-type test_results \
--sha ${{ github.event.pull_request.head.sha || github.sha }} \
--branch ${{ github.event.pull_request.head.label || github.ref_name }} \
$PR \
--slug ${{ github.repository }} \
--git-service github \
--fail-on-error
python${PYTHON_VERSION} -m codecov_cli.main upload-process \
--file coverage.xml \
--report-type coverage \
--sha ${{ github.event.pull_request.head.sha || github.sha }} \
--branch ${{ github.event.pull_request.head.label || github.ref_name }} \
$PR \
--slug ${{ github.repository }} \
--git-service github \
--fail-on-error
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: coverage
path: |
report.junit.xml
coverage.xml
build-documentation:
runs-on: ubuntu-latest
needs: build-wheels
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: wheels-ubuntu-latest
path: wheelhouse
- name: Build Documentation
run: |
set -e
python -m pip install twine
grep -vE "fastwarc|resiliparse" docs/requirements.txt | xargs python -m pip install
PYTHON_ABI="cp${PYTHON_VERSION/./}"
find wheelhouse -name "FastWARC-*-${PYTHON_ABI}-*-manylinux_x86_64.whl" | xargs -I% python -m pip install "%[all]"
find wheelhouse -name "Resiliparse-*-${PYTHON_ABI}-*-manylinux_x86_64.whl" | xargs -I% python -m pip install "%[all]"
cd docs
make html
- name: Trigger Readthedocs Build
if: github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/tags/v')
uses: dfm/rtds-action@v1
with:
webhook_url: ${{ secrets.RTDS_WEBHOOK_URL }}
webhook_token: ${{ secrets.RTDS_WEBHOOK_TOKEN }}
commit_ref: ${{ github.ref }}
publish-wheels:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
needs: [ build-wheels, build-wheels-aarch64, build-asan, build-sdist, build-documentation ]
steps:
- name: Download Wheels
uses: actions/download-artifact@v4
with:
pattern: wheels-*
merge-multiple: true
- name: Download Source Dist
uses: actions/download-artifact@v4
with:
name: sdist
- name: Publish to PyPi
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD1: ${{ secrets.PYPI_FASTWARC_API_TOKEN }}
TWINE_PASSWORD2: ${{ secrets.PYPI_RESILIPARSE_API_TOKEN }}
run: |
set -e
python3 -m pip install twine
TWINE_PASSWORD="$TWINE_PASSWORD1" python3 -m twine upload FastWARC-*.whl fastwarc-*.tar.gz
TWINE_PASSWORD="$TWINE_PASSWORD2" python3 -m twine upload Resiliparse-*.whl resiliparse-*.tar.gz
- name: Wait
run: sleep 30
- name: Trigger Readthedocs Build
uses: dfm/rtds-action@v1
with:
webhook_url: ${{ secrets.RTDS_WEBHOOK_URL }}
webhook_token: ${{ secrets.RTDS_WEBHOOK_TOKEN }}
commit_ref: ${{ github.ref }}