-
Notifications
You must be signed in to change notification settings - Fork 2
314 lines (292 loc) · 9.14 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
name: CI
on:
push:
tags:
- "**"
branches:
- main
- master
pull_request:
workflow_dispatch:
jobs:
build:
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
python-version:
- "3.9"
- "3.10"
- "3.11"
- "3.12"
- "3.13"
include:
- os: macos-latest
target: universal2-apple-darwin
name: Build on ${{ matrix.os}} ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
id: python
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
cache: "pip"
- uses: actions/cache@v4
id: cache-uv
with:
path: ~/.cache/uv
key: ${{ runner.os }}-python-${{ matrix.python-version }}-uv
- name: Install rust stable
id: rust-toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: llvm-tools
- uses: PyO3/maturin-action@v1
with:
manylinux: auto
target: ${{ matrix.target }}
rust-toolchain: stable
sccache: "true"
args: >
--release
--sdist
--interpreter ${{ matrix.python-version }}
--out pgo-wheel
env:
RUSTFLAGS: "-Cprofile-generate=${{ github.workspace }}/target/profdata"
- name: Get rust host
run: echo RUST_HOST=$(rustc -Vv | grep host | cut -d ' ' -f 2) >> "$GITHUB_ENV"
shell: bash
- name: Generate pgo data
run: |
pip install -U uv
uv pip install -r requirements/bench.txt --python ${{ steps.python.outputs.python-path }}
uv pip install serpyco_rs --no-index --no-deps --find-links pgo-wheel --force-reinstall --python ${{ steps.python.outputs.python-path }}
# Install package deps
uv pip install serpyco_rs --find-links pgo-wheel --python ${{ steps.python.outputs.python-path }}
pytest bench -k "not mashumaro and not marshmallow and not pydantic"
rustup run stable bash -c 'echo LLVM_PROFDATA=$RUSTUP_HOME/toolchains/$RUSTUP_TOOLCHAIN/lib/rustlib/${{ env.RUST_HOST }}/bin/llvm-profdata >> "$GITHUB_ENV"'
# - name: Setup upterm session
# uses: lhotari/action-upterm@v1
- name: Merge pgo data
run: ${{ env.LLVM_PROFDATA }} merge -o ${{ github.workspace }}/merged.profdata ${{ github.workspace }}/target/profdata
- name: Build pgo-optimized wheel
uses: PyO3/maturin-action@v1
with:
manylinux: auto
rust-toolchain: stable
command: build
target: ${{ matrix.target }}
sccache: "true"
args: >
--release
--sdist
--interpreter ${{ matrix.python-version }}
--out dist
env:
RUSTFLAGS: "-Cprofile-use=${{ github.workspace }}/merged.profdata"
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels_${{ matrix.os }}_${{ matrix.python-version }}
path: dist
linux-cross:
runs-on: ubuntu-latest
strategy:
matrix:
platform:
- target: aarch64-unknown-linux-gnu
arch: aarch64
# and https://github.com/gnzlbg/jemallocator/issues/170#issuecomment-1503228963
maturin_docker_options: -e JEMALLOC_SYS_WITH_LG_PAGE=16
- target: armv7-unknown-linux-gnueabihf
arch: armv7
- target: s390x-unknown-linux-gnu
arch: s390x
- target: powerpc64le-unknown-linux-gnu
arch: ppc64le
- target: powerpc64-unknown-linux-gnu
arch: ppc64
steps:
- uses: actions/checkout@v4
- name: "Build wheels"
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.platform.target }}
manylinux: auto
docker-options: ${{ matrix.platform.maturin_docker_options }}
args: --release --sdist -o dist --interpreter 3.9 3.10 3.11 3.12 3.13
sccache: "true"
- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels_${{ matrix.platform.arch }}
path: dist
test:
needs: [build]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
name: Test on ${{ matrix.os}} ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- uses: actions/download-artifact@v4
with:
pattern: wheels_*
merge-multiple: true
path: wheels
- name: install dependencies
run: |
# https://github.com/astral-sh/uv/issues/2450
python -m pip install --upgrade pip nox uv==0.1.18
- name: tests
run: nox -s test
env:
CI: true
- name: lint
run: nox -s lint
env:
CI: true
- name: check types
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'
run: nox -s type_check
env:
CI: true
benchmark:
needs: [build]
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
name: Benchmark on ${{ matrix.os}}
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11
- uses: actions/download-artifact@v4
with:
pattern: wheels_*
merge-multiple: true
path: wheels
- name: install dependencies
run: |
# https://github.com/astral-sh/uv/issues/2450
python -m pip install --upgrade pip nox uv==0.1.18
nox -s bench --no-venv --install-only
- name: bench
run: nox -s bench --no-venv --no-install
env:
CI: true
test_rc_leaks:
name: Test reference count leaks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: deadsnakes/action@v3.1.0
with:
python-version: 3.11
debug: true
- run: python3.11 --version --version && which python3.11 && python3.11 -c "import sys; print(sys.gettotalrefcount())"
- uses: PyO3/maturin-action@v1
with:
command: build
args: --release --sdist -o wheels
- name: install dependencies
run: |
# https://github.com/astral-sh/uv/issues/2450
python -m pip install --upgrade pip nox uv==0.1.18
nox -s test_rc_leaks --no-venv --install-only
- name: tests
run: nox -s test_rc_leaks --no-venv --no-install
benchmark-codespeed:
needs: [build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v4
id: cache-uv
with:
path: ~/.cache/uv
key: ubuntu-latest-python-3.12-uv
- name: set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: 3.12
cache: "pip"
cache-dependency-path: |
requirements/*.txt
- uses: actions/download-artifact@v4
with:
pattern: wheels_*
merge-multiple: true
path: wheels
- name: install dependencies
run: |
# https://github.com/astral-sh/uv/issues/2450
python -m pip install --upgrade pip nox uv==0.1.18
nox -s bench_codespeed --no-venv --install-only
- name: Run benchmarks
uses: CodSpeedHQ/action@v3
with:
token: ${{ secrets.CODSPEED_TOKEN }}
run: nox -s bench_codespeed --no-venv --no-install
env:
CI: true
fmt:
name: rustfmt
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: rustfmt
- run: cargo fmt --all -- --check
clippy:
name: clippy
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: clippy
- run: cargo clippy --all-targets --all-features -- -D warnings
release:
name: release
runs-on: ubuntu-latest
if: startsWith(github.event.ref, 'refs/tags')
needs: [build, linux-cross, test]
steps:
- uses: actions/download-artifact@v4
with:
pattern: wheels_*
merge-multiple: true
path: dist
- name: Publish to PyPI
uses: PyO3/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
with:
command: upload
args: --skip-existing dist/*