66 - main
77 tags :
88 - " *"
9- pull_request :
109 workflow_dispatch :
1110
1211permissions :
1312 contents : read
1413
1514jobs :
1615 lint :
17- name : Lint
18- runs-on : ubuntu-24.04
19- steps :
20- - uses : actions/checkout@v6
21- - uses : astral-sh/ruff-action@v3
22- - run : |
23- ruff check
24- ruff format --check
16+ uses : ./.github/workflows/lint.yml
2517
2618 rust_tests :
2719 name : Rust tests - ${{ matrix.platform.name }}
@@ -44,48 +36,10 @@ jobs:
4436 runner : macos-15
4537 steps :
4638 - uses : actions/checkout@v6
47- - name : Cache Rust build
48- uses : actions/cache@v4
49- with :
50- path : |
51- target
52- ~/.cargo/registry
53- ~/.cargo/git
54- key : ${{ runner.os }}-test-${{ runner.arch }}-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
55- restore-keys : |
56- ${{ runner.os }}-test-${{ runner.arch }}-
57-
58- - name : Install uv
59- uses : astral-sh/setup-uv@v7
60- with :
61- version : " 0.9.11"
62- enable-cache : true
63- cache-dependency-glob : " **/uv.lock"
64- # python-version: "3.12"
65-
66- - name : Install required python dependencies
67- run : uv sync --no-install-project
68- shell : bash
69-
70- - name : Run cargo tests
71- run : |
72- # pyo3 and uv do not work well together...
73- PY_LIBDIR=$(uv run --no-sync python -c "import sysconfig; print(sysconfig.get_config_var('LIBDIR'))")
74- echo "Python libdir: $PY_LIBDIR"
75- # setting LD_LIBRARY_PATH for Linux: https://github.com/astral-sh/uv/issues/11006#issuecomment-2672486381
76- export LD_LIBRARY_PATH="$PY_LIBDIR${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}" # LINUX
77- if [[ "$RUNNER_OS" == "Windows" ]]; then
78- uv run --no-sync python -c "import sys; print(sys.path)"
79- uv run --no-sync where python
80- export PYTHONPATH="$(echo .venv/Lib/site-packages)"
81- else
82- # setting PYTHONHOME and PYTHONPATH seem to be the best solution for macOS at the moment
83- # https://github.com/PyO3/pyo3/issues/1741#issuecomment-955805634
84- export PYTHONHOME="$(uv run --no-sync python -c 'import sys; print(sys.base_prefix)')" # MACOS
85- export PYTHONPATH="$(echo .venv/lib/python*/site-packages)" # MACOS
86- fi
87- uv run --no-sync cargo test --no-default-features
88- shell : bash
39+ - uses : ./.github/actions/cache-rust-build
40+ - uses : ./.github/actions/install-uv
41+ - uses : ./.github/actions/install-python-deps
42+ - uses : ./.github/actions/run-cargo-tests
8943
9044 build :
9145 needs : rust_tests
@@ -141,27 +95,14 @@ jobs:
14195 is-musl : false
14296 steps :
14397 - uses : actions/checkout@v6
144- - name : Cache Rust build
145- uses : actions/cache@v4
146- with :
147- path : |
148- target
149- ~/.cargo/registry
150- ~/.cargo/git
151- key : ${{ runner.os }}-build-${{ matrix.platform.name }}-${{ hashFiles('**/Cargo.lock', '**/Cargo.toml') }}
152- restore-keys : |
153- ${{ runner.os }}-build-${{ matrix.platform.name }}-
154- - name : Build wheels
155- uses : PyO3/maturin-action@v1
98+ - uses : ./.github/actions/cache-rust-build
99+ - uses : ./.github/actions/build-wheel
156100 with :
157- maturin-version : 1.9.6
158101 target : ${{ matrix.platform.target }}
159102 args : --release --out dist --find-interpreter
160103 manylinux : ${{ matrix.platform.manylinux }}
161- container : ${{ matrix.platform.is-musl == true && 'off' || '' }}
162104 before-script-linux : ${{ matrix.platform.before-script }}
163- - name : Upload wheels
164- uses : actions/upload-artifact@v4
105+ - uses : ./.github/actions/upload-wheels
165106 with :
166107 name : wheels-${{ matrix.platform.name }}
167108 path : dist
@@ -171,13 +112,12 @@ jobs:
171112 steps :
172113 - uses : actions/checkout@v6
173114 - name : Build sdist
174- uses : PyO3/maturin-action@v1
115+ uses : ./.github/actions/build-wheel
175116 with :
176- maturin-version : 1.9.6
177117 command : sdist
178118 args : --out dist
179119 - name : Upload sdist
180- uses : actions/upload-artifact@v4
120+ uses : ./.github/ actions/upload-wheels
181121 with :
182122 name : wheels-sdist
183123 path : dist
@@ -265,44 +205,17 @@ jobs:
265205 python-version : " 3.10"
266206 is-min-deps : true
267207 steps :
268- # Use the test composite action
269208 - uses : actions/checkout@v6
270-
271- - name : Install uv
272- uses : astral-sh/setup-uv@v7
209+ - uses : ./.github/actions/install-uv
273210 with :
274- version : " 0.9.11"
275- enable-cache : " true"
276- cache-dependency-glob : " **/uv.lock"
277211 python-version : ${{ matrix.config.python-version }}
278-
279- - name : Download wheels
280- uses : actions/download-artifact@v4
212+ - uses : ./.github/actions/download-wheels
281213 with :
282214 name : wheels-${{ matrix.config.platform-name }}
283215 path : dist
284-
285- # Regular tests (non-musl platforms)
286- - name : Run regular tests
287- if : ${{ !matrix.config.is-min-deps && !matrix.config.is-musl }}
288- shell : bash
289- run : |
290- WHEEL_PATH=$(ls dist/*.whl)
291- uv venv
292- uv sync --no-install-project --no-default-groups --group=test
293- uv pip install --force-reinstall "$WHEEL_PATH"
294- uv run --no-sync pytest tests/
295-
296- # Minimum dependencies test
297- - name : Run tests with minimum dependencies
298- if : ${{ matrix.config.is-min-deps }}
299- shell : bash
300- run : |
301- WHEEL_PATH=$(ls dist/*.whl)
302- uv venv
303- uv sync --resolution lowest-direct --no-install-project --no-default-groups --group=test
304- uv pip install --no-deps --force-reinstall "$WHEEL_PATH"
305- uv run --no-sync --no-default-groups --group=test pytest tests/
216+ - uses : ./.github/actions/run-python-tests
217+ with :
218+ min-deps : ${{ matrix.config.is-min-deps }}
306219
307220 test-musl :
308221 needs : build
@@ -317,25 +230,13 @@ jobs:
317230 run : |
318231 apk add tar python3 py3-pip py3-psutil gcc python3-dev musl-dev linux-headers
319232
320- - name : Install uv
321- uses : astral-sh/setup-uv@v7
233+ - uses : ./.github/actions/install-uv
322234 with :
323- version : " 0.9.11"
324- enable-cache : " true"
325- cache-dependency-glob : " **/uv.lock"
326235 python-version : " 3.12"
327-
328- - name : Download wheels
329- uses : actions/download-artifact@v4
236+ - uses : ./.github/actions/download-wheels
330237 with :
331238 name : wheels-linux-musl-x86_64
332239 path : dist
333240
334241 - name : Run musl tests
335- shell : sh
336- run : |
337- WHEEL_PATH=$(ls dist/*.whl)
338- uv venv
339- uv sync --no-install-project --no-default-groups --group=test
340- uv pip install --force-reinstall "$WHEEL_PATH"
341- uv run --no-sync pytest tests/
242+ uses : ./.github/actions/run-python-tests
0 commit comments