Skip to content

Commit 7199a2a

Browse files
feat: rewrite panics into python exceptions (#92)
* feat: remove all `panic` with exceptions * Update lib.rs * feat: fix failing tests * Update CI.yaml * Update pyproject.toml
1 parent 66149e1 commit 7199a2a

File tree

5 files changed

+228
-220
lines changed

5 files changed

+228
-220
lines changed

.github/workflows/CI.yaml

Lines changed: 184 additions & 188 deletions
Original file line numberDiff line numberDiff line change
@@ -6,204 +6,200 @@
66
name: CI
77

88
on:
9-
push:
10-
branches:
11-
- main
12-
- master
13-
tags:
14-
- '*'
15-
pull_request:
16-
workflow_dispatch:
9+
push:
10+
branches:
11+
- main
12+
- master
13+
tags:
14+
- '*'
15+
pull_request:
16+
workflow_dispatch:
1717

1818
permissions:
19-
contents: read
19+
contents: read
2020

2121
jobs:
22-
linux:
23-
runs-on: ${{ matrix.platform.runner }}
24-
strategy:
25-
matrix:
26-
platform:
27-
- runner: ubuntu-22.04
28-
target: x86_64
29-
- runner: ubuntu-22.04
30-
target: x86
31-
- runner: ubuntu-22.04
32-
target: aarch64
33-
- runner: ubuntu-22.04
34-
target: armv7
35-
- runner: ubuntu-22.04
36-
target: s390x
37-
- runner: ubuntu-22.04
38-
target: ppc64le
39-
steps:
40-
- uses: actions/checkout@v6
41-
- uses: actions/setup-python@v6
42-
with:
43-
python-version: 3.x
44-
- name: Build wheels
45-
uses: PyO3/maturin-action@v1
46-
with:
47-
target: ${{ matrix.platform.target }}
48-
args: --release --out dist --find-interpreter
49-
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
50-
manylinux: auto
51-
- name: Upload wheels
52-
uses: actions/upload-artifact@v6
53-
with:
54-
name: wheels-linux-${{ matrix.platform.target }}
55-
path: dist
22+
linux:
23+
runs-on: ${{ matrix.platform.runner }}
24+
strategy:
25+
matrix:
26+
platform:
27+
- runner: ubuntu-22.04
28+
target: x86_64
29+
- runner: ubuntu-22.04
30+
target: x86
31+
- runner: ubuntu-22.04
32+
target: aarch64
33+
- runner: ubuntu-22.04
34+
target: armv7
35+
- runner: ubuntu-22.04
36+
target: s390x
37+
- runner: ubuntu-22.04
38+
target: ppc64le
39+
steps:
40+
- uses: actions/checkout@v6
41+
- uses: actions/setup-python@v6
42+
with:
43+
python-version: 3.x
44+
- name: Build wheels
45+
uses: PyO3/maturin-action@v1
46+
with:
47+
target: ${{ matrix.platform.target }}
48+
args: --release --out dist --find-interpreter
49+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
50+
manylinux: auto
51+
- name: Upload wheels
52+
uses: actions/upload-artifact@v6
53+
with:
54+
name: wheels-linux-${{ matrix.platform.target }}
55+
path: dist
5656

57-
musllinux:
58-
runs-on: ${{ matrix.platform.runner }}
59-
strategy:
60-
matrix:
61-
platform:
62-
- runner: ubuntu-22.04
63-
target: x86_64
64-
- runner: ubuntu-22.04
65-
target: x86
66-
- runner: ubuntu-22.04
67-
target: aarch64
68-
- runner: ubuntu-22.04
69-
target: armv7
70-
steps:
71-
- uses: actions/checkout@v6
72-
- uses: actions/setup-python@v6
73-
with:
74-
python-version: 3.x
75-
- name: Build wheels
76-
uses: PyO3/maturin-action@v1
77-
with:
78-
target: ${{ matrix.platform.target }}
79-
args: --release --out dist --find-interpreter
80-
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
81-
manylinux: musllinux_1_2
82-
- name: Upload wheels
83-
uses: actions/upload-artifact@v6
84-
with:
85-
name: wheels-musllinux-${{ matrix.platform.target }}
86-
path: dist
57+
musllinux:
58+
runs-on: ${{ matrix.platform.runner }}
59+
strategy:
60+
matrix:
61+
platform:
62+
- runner: ubuntu-22.04
63+
target: x86_64
64+
- runner: ubuntu-22.04
65+
target: x86
66+
- runner: ubuntu-22.04
67+
target: aarch64
68+
- runner: ubuntu-22.04
69+
target: armv7
70+
steps:
71+
- uses: actions/checkout@v6
72+
- uses: actions/setup-python@v6
73+
with:
74+
python-version: 3.x
75+
- name: Build wheels
76+
uses: PyO3/maturin-action@v1
77+
with:
78+
target: ${{ matrix.platform.target }}
79+
args: --release --out dist --find-interpreter
80+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
81+
manylinux: musllinux_1_2
82+
- name: Upload wheels
83+
uses: actions/upload-artifact@v6
84+
with:
85+
name: wheels-musllinux-${{ matrix.platform.target }}
86+
path: dist
8787

88-
windows:
89-
runs-on: ${{ matrix.platform.runner }}
90-
strategy:
91-
matrix:
92-
platform:
93-
- runner: windows-latest
94-
target: x64
95-
- runner: windows-latest
96-
target: x86
97-
steps:
98-
- uses: actions/checkout@v6
99-
- uses: actions/setup-python@v6
100-
with:
101-
python-version: 3.x
102-
architecture: ${{ matrix.platform.target }}
103-
- name: Build wheels
104-
uses: PyO3/maturin-action@v1
105-
with:
106-
target: ${{ matrix.platform.target }}
107-
args: --release --out dist --find-interpreter
108-
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
109-
- name: Upload wheels
110-
uses: actions/upload-artifact@v6
111-
with:
112-
name: wheels-windows-${{ matrix.platform.target }}
113-
path: dist
88+
windows:
89+
runs-on: ${{ matrix.platform.runner }}
90+
strategy:
91+
matrix:
92+
platform:
93+
- runner: windows-latest
94+
target: x64
95+
- runner: windows-latest
96+
target: x86
97+
steps:
98+
- uses: actions/checkout@v6
99+
- uses: actions/setup-python@v6
100+
with:
101+
python-version: 3.x
102+
architecture: ${{ matrix.platform.target }}
103+
- name: Build wheels
104+
uses: PyO3/maturin-action@v1
105+
with:
106+
target: ${{ matrix.platform.target }}
107+
args: --release --out dist --find-interpreter
108+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
109+
- name: Upload wheels
110+
uses: actions/upload-artifact@v6
111+
with:
112+
name: wheels-windows-${{ matrix.platform.target }}
113+
path: dist
114114

115-
macos:
116-
runs-on: ${{ matrix.platform.runner }}
117-
strategy:
118-
matrix:
119-
platform:
120-
- runner: macos-15
121-
target: x86_64
122-
- runner: macos-15
123-
target: aarch64
124-
steps:
125-
- uses: actions/checkout@v6
126-
- uses: actions/setup-python@v6
127-
with:
128-
python-version: 3.x
129-
- name: Build wheels
130-
uses: PyO3/maturin-action@v1
131-
with:
132-
target: ${{ matrix.platform.target }}
133-
args: --release --out dist --find-interpreter
134-
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
135-
- name: Upload wheels
136-
uses: actions/upload-artifact@v6
137-
with:
138-
name: wheels-macos-${{ matrix.platform.target }}
139-
path: dist
115+
macos:
116+
runs-on: ${{ matrix.platform.runner }}
117+
strategy:
118+
matrix:
119+
platform:
120+
- runner: macos-15
121+
target: x86_64
122+
- runner: macos-15
123+
target: aarch64
124+
steps:
125+
- uses: actions/checkout@v6
126+
- uses: actions/setup-python@v6
127+
with:
128+
python-version: 3.x
129+
- name: Build wheels
130+
uses: PyO3/maturin-action@v1
131+
with:
132+
target: ${{ matrix.platform.target }}
133+
args: --release --out dist --find-interpreter
134+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
135+
- name: Upload wheels
136+
uses: actions/upload-artifact@v6
137+
with:
138+
name: wheels-macos-${{ matrix.platform.target }}
139+
path: dist
140140

141-
sdist:
142-
runs-on: ubuntu-latest
143-
steps:
144-
- uses: actions/checkout@v6
145-
- name: Build sdist
146-
uses: PyO3/maturin-action@v1
147-
with:
148-
command: sdist
149-
args: --out dist
150-
- name: Upload sdist
151-
uses: actions/upload-artifact@v6
152-
with:
153-
name: wheels-sdist
154-
path: dist
141+
sdist:
142+
runs-on: ubuntu-latest
143+
steps:
144+
- uses: actions/checkout@v6
145+
- name: Build sdist
146+
uses: PyO3/maturin-action@v1
147+
with:
148+
command: sdist
149+
args: --out dist
150+
- name: Upload sdist
151+
uses: actions/upload-artifact@v6
152+
with:
153+
name: wheels-sdist
154+
path: dist
155155

156-
release:
157-
name: Release
158-
runs-on: ubuntu-latest
159-
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
160-
needs: [linux, musllinux, windows, macos, sdist, test]
161-
permissions:
162-
# Use to sign the release artifacts
163-
id-token: write
164-
# Used to upload release artifacts
165-
contents: write
166-
# Used to generate artifact attestation
167-
attestations: write
168-
steps:
169-
- uses: actions/download-artifact@v7
170-
- name: Generate artifact attestation
171-
uses: actions/attest-build-provenance@v3
172-
with:
173-
subject-path: 'wheels-*/*'
174-
- name: Publish to PyPI
175-
if: ${{ startsWith(github.ref, 'refs/tags/') }}
176-
uses: PyO3/maturin-action@v1
177-
env:
178-
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
179-
with:
180-
command: upload
181-
args: --non-interactive --skip-existing wheels-*/*
156+
release:
157+
name: Release
158+
runs-on: ubuntu-latest
159+
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
160+
needs: [linux, musllinux, windows, macos, sdist, test]
161+
permissions:
162+
# Use to sign the release artifacts
163+
id-token: write
164+
# Used to upload release artifacts
165+
contents: write
166+
# Used to generate artifact attestation
167+
attestations: write
168+
steps:
169+
- uses: actions/download-artifact@v7
170+
- name: Generate artifact attestation
171+
uses: actions/attest-build-provenance@v3
172+
with:
173+
subject-path: 'wheels-*/*'
174+
- name: Publish to PyPI
175+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
176+
uses: PyO3/maturin-action@v1
177+
env:
178+
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
179+
with:
180+
command: upload
181+
args: --non-interactive --skip-existing wheels-*/*
182182

183-
test:
184-
name: Run Tests
185-
runs-on: windows-latest
186-
strategy:
187-
matrix:
188-
python-version: ["3.10", "3.11", "3.12","3.13", "3.14"]
189-
steps:
190-
191-
- uses: actions/checkout@v6
192-
193-
- name: Set up Python (uv)
194-
uses: astral-sh/setup-uv@v7
195-
with:
196-
enable-cache: true
197-
python-version: ${{ matrix.python-version }}
198-
cache-dependency-glob: "uv.lock"
199-
200-
- name: Create virtual environment and install dependencies
201-
run: |
202-
uv sync --group dev
203-
204-
- name: Run backend tests
205-
run: |
206-
uv run pytest -v -x -rs
183+
test:
184+
name: Run Tests
185+
runs-on: windows-latest
186+
strategy:
187+
matrix:
188+
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
189+
steps:
190+
- uses: actions/checkout@v6
207191

192+
- name: Set up Python (uv)
193+
uses: astral-sh/setup-uv@v7
194+
with:
195+
enable-cache: true
196+
python-version: ${{ matrix.python-version }}
197+
cache-dependency-glob: 'uv.lock'
208198

199+
- name: Create virtual environment and install dependencies
200+
run: |
201+
uv sync
209202
203+
- name: Run backend tests
204+
run: |
205+
uv run pytest -v -x -rs

0 commit comments

Comments
 (0)