Skip to content

Commit c80c0d3

Browse files
committed
refactor: extract Yaml helper, pytest emitters, and move snapshots to files
- Add `Yaml` struct for indentation-tracked YAML writing - Add `gha_expr()` helper and constants to avoid `${{{{ }}}}` escaping noise - Extract pytest generation into `emit_pytest_steps()` with per-platform helpers - Deduplicate uv-based pytest (manylinux host/windows/macos) via `emit_uv_pytest()` - Move 7 inline `expect!` snapshots to `src/ci/__snapshots__/` using `expect_file!` - Reduces `github.rs` from ~2600 to ~1420 lines
1 parent 2bc0242 commit c80c0d3

File tree

8 files changed

+1691
-1554
lines changed

8 files changed

+1691
-1554
lines changed
Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
tags:
9+
- '*'
10+
pull_request:
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
linux:
18+
runs-on: ${{ matrix.platform.runner }}
19+
strategy:
20+
matrix:
21+
platform:
22+
- runner: ubuntu-22.04
23+
target: x86_64
24+
- runner: ubuntu-22.04
25+
target: x86
26+
- runner: ubuntu-22.04
27+
target: aarch64
28+
- runner: ubuntu-22.04
29+
target: armv7
30+
- runner: ubuntu-22.04
31+
target: s390x
32+
- runner: ubuntu-22.04
33+
target: ppc64le
34+
steps:
35+
- uses: actions/checkout@v6
36+
- uses: actions/setup-python@v6
37+
with:
38+
python-version: 3.x
39+
- name: Build wheels
40+
uses: PyO3/maturin-action@v1
41+
with:
42+
target: ${{ matrix.platform.target }}
43+
args: --release --out dist
44+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
45+
manylinux: auto
46+
- name: Build free-threaded wheels
47+
uses: PyO3/maturin-action@v1
48+
with:
49+
target: ${{ matrix.platform.target }}
50+
args: --release --out dist -i python3.14t
51+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
52+
manylinux: auto
53+
- name: Upload wheels
54+
uses: actions/upload-artifact@v6
55+
with:
56+
name: wheels-linux-${{ matrix.platform.target }}
57+
path: dist
58+
59+
musllinux:
60+
runs-on: ${{ matrix.platform.runner }}
61+
strategy:
62+
matrix:
63+
platform:
64+
- runner: ubuntu-22.04
65+
target: x86_64
66+
- runner: ubuntu-22.04
67+
target: x86
68+
- runner: ubuntu-22.04
69+
target: aarch64
70+
- runner: ubuntu-22.04
71+
target: armv7
72+
steps:
73+
- uses: actions/checkout@v6
74+
- uses: actions/setup-python@v6
75+
with:
76+
python-version: 3.x
77+
- name: Build wheels
78+
uses: PyO3/maturin-action@v1
79+
with:
80+
target: ${{ matrix.platform.target }}
81+
args: --release --out dist
82+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
83+
manylinux: musllinux_1_2
84+
- name: Build free-threaded wheels
85+
uses: PyO3/maturin-action@v1
86+
with:
87+
target: ${{ matrix.platform.target }}
88+
args: --release --out dist -i python3.14t
89+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
90+
manylinux: musllinux_1_2
91+
- name: Upload wheels
92+
uses: actions/upload-artifact@v6
93+
with:
94+
name: wheels-musllinux-${{ matrix.platform.target }}
95+
path: dist
96+
97+
windows:
98+
runs-on: ${{ matrix.platform.runner }}
99+
strategy:
100+
matrix:
101+
platform:
102+
- runner: windows-latest
103+
target: x64
104+
python_arch: x64
105+
- runner: windows-latest
106+
target: x86
107+
python_arch: x86
108+
- runner: windows-11-arm
109+
target: aarch64
110+
python_arch: arm64
111+
steps:
112+
- uses: actions/checkout@v6
113+
- uses: actions/setup-python@v6
114+
with:
115+
python-version: 3.13
116+
architecture: ${{ matrix.platform.python_arch }}
117+
- name: Build wheels
118+
uses: PyO3/maturin-action@v1
119+
with:
120+
target: ${{ matrix.platform.target }}
121+
args: --release --out dist
122+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
123+
- uses: actions/setup-python@v6
124+
with:
125+
python-version: 3.14t
126+
architecture: ${{ matrix.platform.python_arch }}
127+
- name: Build free-threaded wheels
128+
uses: PyO3/maturin-action@v1
129+
with:
130+
target: ${{ matrix.platform.target }}
131+
args: --release --out dist -i python3.14t
132+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
133+
- name: Upload wheels
134+
uses: actions/upload-artifact@v6
135+
with:
136+
name: wheels-windows-${{ matrix.platform.target }}
137+
path: dist
138+
139+
macos:
140+
runs-on: ${{ matrix.platform.runner }}
141+
strategy:
142+
matrix:
143+
platform:
144+
- runner: macos-15-intel
145+
target: x86_64
146+
- runner: macos-latest
147+
target: aarch64
148+
steps:
149+
- uses: actions/checkout@v6
150+
- uses: actions/setup-python@v6
151+
with:
152+
python-version: 3.x
153+
- name: Build wheels
154+
uses: PyO3/maturin-action@v1
155+
with:
156+
target: ${{ matrix.platform.target }}
157+
args: --release --out dist
158+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
159+
- name: Build free-threaded wheels
160+
uses: PyO3/maturin-action@v1
161+
with:
162+
target: ${{ matrix.platform.target }}
163+
args: --release --out dist -i python3.14t
164+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
165+
- name: Upload wheels
166+
uses: actions/upload-artifact@v6
167+
with:
168+
name: wheels-macos-${{ matrix.platform.target }}
169+
path: dist
170+
171+
release:
172+
name: Release
173+
runs-on: ubuntu-latest
174+
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
175+
needs: [linux, musllinux, windows, macos]
176+
permissions:
177+
# Use to sign the release artifacts
178+
id-token: write
179+
# Used to upload release artifacts
180+
contents: write
181+
# Used to generate artifact attestation
182+
attestations: write
183+
steps:
184+
- uses: actions/download-artifact@v7
185+
- name: Generate artifact attestation
186+
uses: actions/attest-build-provenance@v3
187+
with:
188+
subject-path: 'wheels-*/*'
189+
- name: Install uv
190+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
191+
uses: astral-sh/setup-uv@v7
192+
- name: Publish to PyPI
193+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
194+
run: uv publish 'wheels-*/*'
195+
env:
196+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- master
8+
tags:
9+
- '*'
10+
pull_request:
11+
workflow_dispatch:
12+
13+
permissions:
14+
contents: read
15+
16+
jobs:
17+
linux:
18+
runs-on: ${{ matrix.platform.runner }}
19+
strategy:
20+
matrix:
21+
platform:
22+
- runner: ubuntu-22.04
23+
target: x86_64
24+
- runner: ubuntu-22.04
25+
target: x86
26+
- runner: ubuntu-22.04
27+
target: aarch64
28+
- runner: ubuntu-22.04
29+
target: armv7
30+
- runner: ubuntu-22.04
31+
target: s390x
32+
- runner: ubuntu-22.04
33+
target: ppc64le
34+
steps:
35+
- uses: actions/checkout@v6
36+
- name: Build wheels
37+
uses: PyO3/maturin-action@v1
38+
with:
39+
target: ${{ matrix.platform.target }}
40+
args: --release --out dist
41+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
42+
manylinux: auto
43+
- name: Upload wheels
44+
uses: actions/upload-artifact@v6
45+
with:
46+
name: wheels-linux-${{ matrix.platform.target }}
47+
path: dist
48+
49+
musllinux:
50+
runs-on: ${{ matrix.platform.runner }}
51+
strategy:
52+
matrix:
53+
platform:
54+
- runner: ubuntu-22.04
55+
target: x86_64
56+
- runner: ubuntu-22.04
57+
target: x86
58+
- runner: ubuntu-22.04
59+
target: aarch64
60+
- runner: ubuntu-22.04
61+
target: armv7
62+
steps:
63+
- uses: actions/checkout@v6
64+
- name: Build wheels
65+
uses: PyO3/maturin-action@v1
66+
with:
67+
target: ${{ matrix.platform.target }}
68+
args: --release --out dist
69+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
70+
manylinux: musllinux_1_2
71+
- name: Upload wheels
72+
uses: actions/upload-artifact@v6
73+
with:
74+
name: wheels-musllinux-${{ matrix.platform.target }}
75+
path: dist
76+
77+
windows:
78+
runs-on: ${{ matrix.platform.runner }}
79+
strategy:
80+
matrix:
81+
platform:
82+
- runner: windows-latest
83+
target: x64
84+
python_arch: x64
85+
- runner: windows-latest
86+
target: x86
87+
python_arch: x86
88+
- runner: windows-11-arm
89+
target: aarch64
90+
python_arch: arm64
91+
steps:
92+
- uses: actions/checkout@v6
93+
- name: Build wheels
94+
uses: PyO3/maturin-action@v1
95+
with:
96+
target: ${{ matrix.platform.target }}
97+
args: --release --out dist
98+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
99+
- name: Upload wheels
100+
uses: actions/upload-artifact@v6
101+
with:
102+
name: wheels-windows-${{ matrix.platform.target }}
103+
path: dist
104+
105+
macos:
106+
runs-on: ${{ matrix.platform.runner }}
107+
strategy:
108+
matrix:
109+
platform:
110+
- runner: macos-15-intel
111+
target: x86_64
112+
- runner: macos-latest
113+
target: aarch64
114+
steps:
115+
- uses: actions/checkout@v6
116+
- name: Build wheels
117+
uses: PyO3/maturin-action@v1
118+
with:
119+
target: ${{ matrix.platform.target }}
120+
args: --release --out dist
121+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
122+
- name: Upload wheels
123+
uses: actions/upload-artifact@v6
124+
with:
125+
name: wheels-macos-${{ matrix.platform.target }}
126+
path: dist
127+
128+
sdist:
129+
runs-on: ubuntu-latest
130+
steps:
131+
- uses: actions/checkout@v6
132+
- name: Build sdist
133+
uses: PyO3/maturin-action@v1
134+
with:
135+
command: sdist
136+
args: --out dist
137+
- name: Upload sdist
138+
uses: actions/upload-artifact@v6
139+
with:
140+
name: wheels-sdist
141+
path: dist
142+
143+
release:
144+
name: Release
145+
runs-on: ubuntu-latest
146+
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
147+
needs: [linux, musllinux, windows, macos, sdist]
148+
permissions:
149+
# Use to sign the release artifacts
150+
id-token: write
151+
# Used to upload release artifacts
152+
contents: write
153+
# Used to generate artifact attestation
154+
attestations: write
155+
steps:
156+
- uses: actions/download-artifact@v7
157+
- name: Generate artifact attestation
158+
uses: actions/attest-build-provenance@v3
159+
with:
160+
subject-path: 'wheels-*/*'
161+
- name: Install uv
162+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
163+
uses: astral-sh/setup-uv@v7
164+
- name: Publish to PyPI
165+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
166+
run: uv publish 'wheels-*/*'
167+
env:
168+
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}

0 commit comments

Comments
 (0)