-
Notifications
You must be signed in to change notification settings - Fork 0
273 lines (253 loc) · 8.66 KB
/
Copy pathpython-tests.yml
File metadata and controls
273 lines (253 loc) · 8.66 KB
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
name: Python Tests
on:
pull_request:
push:
branches:
- stable
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
python-lint:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v6
with:
python-version: "3.13"
- name: Install ruff
run: pip install ruff==0.15.10
- name: ruff check
run: ruff check
- name: ruff format --check
run: ruff format --check
python-tests:
needs: python-lint
runs-on: ubuntu-24.04
strategy:
matrix:
python-version:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
- "3.14"
steps:
- uses: actions/checkout@v7
- name: Install Rust toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Cache OpenSSL build
uses: actions/cache@v6
with:
path: vendor/openssl/install
key: openssl-3.3.2-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('scripts/build-openssl.sh') }}
- name: Build custom OpenSSL
run: ./scripts/build-openssl.sh
- name: Create virtualenv
run: python -m venv .venv
- name: Build Python extension
env:
PYO3_USE_ABI3_FORWARD_COMPATIBILITY: "1"
run: |
source .venv/bin/activate
# maturin 1.13+ installs `[dependency-groups]` via
# `pip install --group`, which requires pip >= 25.1. The
# Python versions shipped with actions/setup-python ship
# older pip (23.x on 3.10); upgrade first so `develop`
# doesn't fail on an unknown `--group` flag.
pip install --upgrade pip
pip install maturin
maturin develop --release
- name: Verify module
run: |
source .venv/bin/activate
python -c "import blasthttp; print(f'blasthttp {blasthttp.__version__}')"
- name: Install test dependencies
run: |
source .venv/bin/activate
pip install 'pytest>=8' 'pytest-asyncio>=0.23'
- name: Run Python tests
run: |
source .venv/bin/activate
pytest tests/python/ -v
version-check:
needs: python-tests
if: github.event_name == 'push' && github.ref == 'refs/heads/stable'
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.check.outputs.new_version }}
steps:
- uses: actions/checkout@v7
- name: Check if version already on PyPI
id: check
run: |
VERSION=$(grep -m1 '^version' pyproject.toml | sed 's/.*"\(.*\)".*/\1/')
echo "version=$VERSION"
if curl -sf -o /dev/null "https://pypi.org/pypi/blasthttp/$VERSION/json"; then
echo "new_version=no" >> "$GITHUB_OUTPUT"
echo "Version $VERSION already on PyPI — skipping wheel builds"
else
echo "new_version=yes" >> "$GITHUB_OUTPUT"
echo "Version $VERSION not on PyPI — will build and publish"
fi
linux-build:
needs: version-check
if: needs.version-check.outputs.new_version == 'yes'
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: ubuntu-24.04
target: x86_64
- runner: ubuntu-24.04
target: x86
- runner: ubuntu-24.04
target: aarch64
- runner: ubuntu-24.04
target: armv7
- runner: ubuntu-24.04
target: s390x
- runner: ubuntu-24.04
target: ppc64le
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v6
with:
python-version: 3.x
- name: Build wheels
uses: PyO3/maturin-action@v1
env:
PYO3_USE_ABI3_FORWARD_COMPATIBILITY: "1"
with:
target: ${{ matrix.platform.target }}
args: --release --out dist -i python3.10 -i python3.11 -i python3.12 -i python3.13 -i python3.14
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
manylinux: manylinux_2_28
before-script-linux: |
set -e
# Install OpenSSL build dependencies
if command -v apk >/dev/null 2>&1; then
apk add --no-cache perl make gcc musl-dev linux-headers curl bash
elif command -v yum >/dev/null 2>&1; then
yum install -y perl-core 2>/dev/null || true
elif command -v apt-get >/dev/null 2>&1; then
apt-get update && apt-get install -y perl make gcc curl 2>/dev/null || true
fi
# Build custom OpenSSL with weak cipher support
./scripts/build-openssl.sh
# Override target-specific OPENSSL_DIR env vars set by maturin containers
# (openssl-sys checks <TARGET>_OPENSSL_DIR before OPENSSL_DIR)
OPENSSL_INSTALL="$(pwd)/vendor/openssl/install"
export OPENSSL_DIR="$OPENSSL_INSTALL"
export OPENSSL_STATIC=1
export OPENSSL_NO_VENDOR=1
for var in $(env | grep '_OPENSSL_DIR=' | cut -d= -f1); do
export "$var=$OPENSSL_INSTALL"
done
- name: Upload wheels
uses: actions/upload-artifact@v7
with:
name: wheels-linux-${{ matrix.platform.target }}
path: dist
musllinux-build:
needs: version-check
if: needs.version-check.outputs.new_version == 'yes'
runs-on: ${{ matrix.platform.runner }}
strategy:
matrix:
platform:
- runner: ubuntu-24.04
target: x86_64
- runner: ubuntu-24.04
target: x86
- runner: ubuntu-24.04
target: aarch64
- runner: ubuntu-24.04
target: armv7
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v6
with:
python-version: 3.x
- name: Build wheels
uses: PyO3/maturin-action@v1
env:
PYO3_USE_ABI3_FORWARD_COMPATIBILITY: "1"
with:
target: ${{ matrix.platform.target }}
args: --release --out dist -i python3.10 -i python3.11 -i python3.12 -i python3.13 -i python3.14
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
manylinux: musllinux_1_2
before-script-linux: |
set -e
# Install OpenSSL build dependencies
if command -v apk >/dev/null 2>&1; then
apk add --no-cache perl make gcc musl-dev linux-headers curl bash
elif command -v yum >/dev/null 2>&1; then
yum install -y perl-core 2>/dev/null || true
elif command -v apt-get >/dev/null 2>&1; then
apt-get update && apt-get install -y perl make gcc curl 2>/dev/null || true
fi
# Build custom OpenSSL with weak cipher support
./scripts/build-openssl.sh
# Override target-specific OPENSSL_DIR env vars set by maturin containers
OPENSSL_INSTALL="$(pwd)/vendor/openssl/install"
export OPENSSL_DIR="$OPENSSL_INSTALL"
export OPENSSL_STATIC=1
export OPENSSL_NO_VENDOR=1
for var in $(env | grep '_OPENSSL_DIR=' | cut -d= -f1); do
export "$var=$OPENSSL_INSTALL"
done
- name: Upload wheels
uses: actions/upload-artifact@v7
with:
name: wheels-musllinux-${{ matrix.platform.target }}
path: dist
sdist-build:
needs: version-check
runs-on: ubuntu-latest
if: needs.version-check.outputs.new_version == 'yes'
steps:
- uses: actions/checkout@v7
- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
- name: Upload sdist
uses: actions/upload-artifact@v7
with:
name: wheels-sdist
path: dist
release:
name: Release
needs:
- linux-build
- musllinux-build
- sdist-build
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
attestations: write
steps:
- uses: actions/download-artifact@v8
- name: Generate artifact attestation
if: ${{ !github.event.repository.private }}
uses: actions/attest-build-provenance@v4
with:
subject-path: 'wheels-*/*'
- name: Publish to PyPI
uses: PyO3/maturin-action@v1
env:
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
with:
command: upload
args: --non-interactive --skip-existing wheels-*/*