-
Notifications
You must be signed in to change notification settings - Fork 0
347 lines (329 loc) · 10.1 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
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
name: CI
on:
push:
branches:
- main
tags:
- '*'
workflow_dispatch:
pull_request:
permissions:
contents: read
concurrency:
group: ci-${{ github.ref_name }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- run: pip install pre-commit
name: Install pre-commit
- run: pre-commit run --all
name: Run pre-commit checks
test:
strategy:
matrix:
os: [ubuntu-22.04, macos-13, windows-latest ]
python_version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13', 'pypy-3.7', 'pypy-3.8', 'pypy-3.9', 'pypy-3.10']
exclude:
- python_version: 3.7
os: macos-13
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
allow-prereleases: true
- name: Setup dependencies
run: pip install pytest
- name: Install mkcert (Linux)
if: matrix.os == 'ubuntu-22.04'
run: sudo apt-get install mkcert
- name: Install mkcert (MacOS)
if: matrix.os == 'macos-12'
run: brew install mkcert
- name: Inject fake CA in TrustStore
if: matrix.os == 'macos-12' || matrix.os == 'ubuntu-22.04'
run: mkcert -install
- name: Generate a valid certificate
if: matrix.os == 'macos-12' || matrix.os == 'ubuntu-22.04'
run: mkcert example.test
- name: Build wheels (Unix, Linux)
if: matrix.os != 'windows-latest'
uses: PyO3/maturin-action@v1
with:
args: --release --out dist --interpreter ${{ matrix.python_version }}
sccache: 'true'
manylinux: auto
- name: Build wheels (NT)
if: matrix.os == 'windows-latest'
uses: PyO3/maturin-action@v1
with:
args: --release --out dist
sccache: 'true'
target: x64
- run: pip install --find-links=./dist wassima
name: Install built package
- name: Ensure test target (NT)
if: matrix.os == 'windows-latest'
run: Remove-Item -Path wassima -Force -Recurse
- name: Ensure test target (Linux, Unix)
if: matrix.os != 'windows-latest'
run: rm -fR wassima
- run: pytest tests/
name: Run tests
linux:
runs-on: ubuntu-22.04
needs:
- test
- lint
strategy:
fail-fast: false
matrix:
target: [x86_64, x86, aarch64, armv7, s390x, ppc64le, ppc64, i686]
python_version: ['3.10', 'pypy-3.7', 'pypy-3.8', 'pypy-3.9', 'pypy-3.10', '3.13t']
manylinux: ['auto', 'musllinux_1_1']
exclude:
- manylinux: musllinux_1_1
target: s390x
- manylinux: musllinux_1_1
target: ppc64
- manylinux: musllinux_1_1
target: ppc64le
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
if: matrix.python_version != '3.13t'
with:
python-version: ${{ matrix.python_version }}
- uses: Quansight-Labs/setup-python@v5
if: matrix.python_version == '3.13t'
with:
python-version: '3.13t'
- name: FreeThreaded Patch
if: matrix.python_version == '3.13t'
run: git apply freethreaded.patch
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist -i ${{ matrix.python_version }}
sccache: 'true'
manylinux: ${{ matrix.manylinux }}
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist
windows:
needs:
- test
- lint
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
target: [x64, aarch64]
python_version: ['3.10', 'pypy-3.7', 'pypy-3.8', 'pypy-3.9', 'pypy-3.10']
exclude:
- target: aarch64
python_version: 'pypy-3.7'
- target: aarch64
python_version: 'pypy-3.8'
- target: aarch64
python_version: 'pypy-3.9'
- target: aarch64
python_version: 'pypy-3.10'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
architecture: x64
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist
macos:
needs:
- test
- lint
runs-on: macos-13
strategy:
fail-fast: false
matrix:
target: [x86_64, aarch64, universal2]
python_version: ['3.10', 'pypy-3.7', 'pypy-3.8', 'pypy-3.9', 'pypy-3.10']
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python_version }}
- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist --interpreter ${{ matrix.python_version }}
sccache: 'true'
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist
freethreaded:
needs:
- test
- lint
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-13 ] # windows-latest
qemu: [ '' ]
include:
# Split ubuntu job for the sake of speed-up
- os: ubuntu-latest
qemu: aarch64
- os: ubuntu-latest
qemu: ppc64le
- os: ubuntu-latest
qemu: s390x
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
submodules: true
- name: Set up QEMU
if: ${{ matrix.qemu }}
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf # v3.2.0
with:
platforms: arm64,s390x,ppc64le
id: qemu
- name: Prepare emulation
run: |
if [[ -n "${{ matrix.qemu }}" ]]; then
# Build emulated architectures only if QEMU is set,
# use default "auto" otherwise
echo "CIBW_ARCHS_LINUX=${{ matrix.qemu }}" >> $GITHUB_ENV
fi
shell: bash
- name: Setup Python
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
- name: Build wheels
uses: pypa/cibuildwheel@7940a4c0e76eb2030e473a5f864f291f63ee879b # v2.21.3
env:
CIBW_BUILD_FRONTEND: build
CIBW_BEFORE_BUILD: git apply freethreaded.patch || true
CIBW_BEFORE_BUILD_WINDOWS: git apply freethreaded.patch || (exit 0)
CIBW_BUILD: cp313t*
CIBW_BEFORE_ALL_LINUX: curl -sSf https://sh.rustup.rs | sh -s -- -y
# CIBW_BEFORE_ALL_WINDOWS: rustup target add aarch64-pc-windows-msvc
CIBW_BEFORE_ALL_MACOS: rustup target add aarch64-apple-darwin
CIBW_ENVIRONMENT_LINUX: "PATH=$HOME/.cargo/bin:$PATH"
CIBW_ARCHS_MACOS: universal2
# CIBW_ARCHS_WINDOWS: AMD64 ARM64
- name: Upload wheels
uses: actions/upload-artifact@v3
with:
name: wheels
path: ./wheelhouse/*.whl
sdist:
needs:
- test
- lint
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
- name: Upload sdist
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist
universal:
needs:
- test
- lint
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install dependencies
run: python -m pip install build wheel
- name: Use fallback pyproject.toml
run: rm -f pyproject.toml && mv pyproject.fb.toml pyproject.toml
- name: Build fallback wheel
run: python -m build
- name: Upload sdist
uses: actions/upload-artifact@v3
with:
name: wheels
path: dist/*.whl
checksum:
name: compute hashes
runs-on: ubuntu-22.04
needs: [linux, windows, macos, sdist, universal, freethreaded]
if: "startsWith(github.ref, 'refs/tags/')"
outputs:
hashes: ${{ steps.compute.outputs.hashes }}
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- name: Download distributions
uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: wheels
path: dist
- name: Collected dists
run: |
tree dist
- name: Generate hashes
id: compute # needs.checksum.outputs.hashes
working-directory: ./dist
run: echo "hashes=$(sha256sum * | base64 -w0)" >> $GITHUB_OUTPUT
provenance:
needs: checksum
if: "startsWith(github.ref, 'refs/tags/')"
uses: slsa-framework/slsa-github-generator/.github/workflows/[email protected]
permissions:
actions: read
id-token: write
contents: write
with:
base64-subjects: ${{ needs.checksum.outputs.hashes }}
upload-assets: true
compile-generator: true
release:
name: release
runs-on: ubuntu-22.04
if: "startsWith(github.ref, 'refs/tags/')"
needs: provenance
environment: pypi
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v3
with:
name: wheels
- name: Publish to PyPI
uses: PyO3/maturin-action@v1
with:
command: upload
args: --non-interactive --skip-existing *