Skip to content

Commit f4afe2f

Browse files
committed
ci: update CI script using maturin
1 parent 3e4b753 commit f4afe2f

File tree

1 file changed

+156
-82
lines changed

1 file changed

+156
-82
lines changed

.github/workflows/ci.yml

+156-82
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# This file is autogenerated by maturin v1.1.0
1+
# This file is autogenerated by maturin v1.8.2
22
# To update, run
33
#
4-
# maturin generate-ci --pytest github
4+
# maturin generate-ci --pytest --platform all --zig github
55
#
66
name: CI
77

@@ -11,7 +11,7 @@ on:
1111
- main
1212
- master
1313
tags:
14-
- '*'
14+
- "*"
1515
pull_request:
1616
workflow_dispatch:
1717

@@ -20,73 +20,150 @@ permissions:
2020

2121
jobs:
2222
linux:
23-
runs-on: ubuntu-latest
23+
runs-on: ${{ matrix.platform.runner }}
2424
strategy:
2525
fail-fast: false
2626
matrix:
27-
# If you update the targets here, be sure to also update the
28-
# download-artifact step in the release job!
29-
target: [x86_64, aarch64]
30-
# pytensor is currently giving me issues on the other targets...
31-
#target: [x86_64, aarch64, s390x, ppc64le]
27+
platform:
28+
- runner: ubuntu-22.04
29+
target: x86_64
30+
- runner: ubuntu-22.04
31+
target: aarch64
3232
steps:
3333
- uses: actions/checkout@v4
3434
- uses: actions/setup-python@v5
3535
with:
36-
python-version: '3.10'
36+
python-version: "3.12"
37+
- name: Install uv
38+
uses: astral-sh/setup-uv@v5
3739
- name: Build wheels
3840
uses: PyO3/maturin-action@v1
3941
with:
40-
target: ${{ matrix.target }}
41-
args: --release --out dist --find-interpreter
42-
manylinux: 2_28
42+
target: ${{ matrix.platform.target }}
43+
args: --release --out dist --find-interpreter --zig
44+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
45+
manylinux: auto
4346
before-script-linux: |
44-
dnf install -y clang-libs clang || apt install llvm-dev libclang-dev clang
45-
47+
dnf install -y clang-libs clang || sudo apt install llvm-dev libclang-dev clang
4648
- name: Upload wheels
4749
uses: actions/upload-artifact@v4
4850
with:
49-
name: linux-${{ matrix.target }}-wheels
51+
name: wheels-linux-${{ matrix.platform.target }}
5052
path: dist
5153
- name: pytest
52-
if: ${{ startsWith(matrix.target, 'x86_64') }}
54+
if: ${{ startsWith(matrix.platform.target, 'x86_64') }}
5355
shell: bash
5456
run: |
5557
set -e
56-
pip install --find-links dist --force-reinstall 'nutpie[all]'
57-
pip install --find-links dist --force-reinstall --no-deps --no-index 'nutpie[all]'
58-
pip install pytest
58+
python3 -m venv .venv
59+
source .venv/bin/activate
60+
uv pip install 'nutpie[all]' --find-links dist --force-reinstall
61+
uv pip install pytest
5962
pytest
6063
- name: pytest
61-
if: ${{ !startsWith(matrix.target, 'x86') }}
62-
uses: uraimo/run-on-arch-action@v2.8.1
64+
if: ${{ !startsWith(matrix.platform.target, 'x86') && matrix.platform.target != 'ppc64' }}
65+
uses: uraimo/run-on-arch-action@v2
6366
with:
64-
arch: ${{ matrix.target }}
65-
distro: fedora_latest
67+
arch: ${{ matrix.platform.target }}
68+
distro: ubuntu22.04
6669
githubToken: ${{ github.token }}
6770
install: |
68-
dnf install -y python3 python3-pip hdf5-devel python3-devel pkg-config curl @development-tools
69-
pip3 install -U pip pytest
71+
apt-get update
72+
apt-get install -y --no-install-recommends python3 python3-pip curl make clang build-essential python3-dev
73+
curl -LsSf https://astral.sh/uv/install.sh | sh
74+
source $HOME/.local/bin/env
7075
run: |
7176
set -e
72-
pip3 install --find-links dist --force-reinstall 'nutpie[all]'
73-
pip3 install 'nutpie[all]' --find-links dist --no-deps --no-index --force-reinstall
77+
source $HOME/.local/bin/env
78+
uv pip install --system -U pip pytest
79+
uv pip install --system 'nutpie[all]' --find-links dist --force-reinstall
7480
pytest
7581
82+
# pyarrow doesn't currently seem to work on musllinux
83+
#musllinux:
84+
# runs-on: ${{ matrix.platform.runner }}
85+
# strategy:
86+
# fail-fast: false
87+
# matrix:
88+
# platform:
89+
# - runner: ubuntu-22.04
90+
# target: x86_64
91+
# - runner: ubuntu-22.04
92+
# target: aarch64
93+
# steps:
94+
# - uses: actions/checkout@v4
95+
# - uses: actions/setup-python@v5
96+
# with:
97+
# python-version: "3.12"
98+
# - name: Install uv
99+
# uses: astral-sh/setup-uv@v5
100+
# - name: Build wheels
101+
# uses: PyO3/maturin-action@v1
102+
# with:
103+
# target: ${{ matrix.platform.target }}
104+
# args: --release --out dist --find-interpreter
105+
# sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
106+
# manylinux: musllinux_1_2
107+
# before-script-linux: |
108+
# dnf install -y clang-libs clang || apt install llvm-dev libclang-dev clang
109+
# - name: Upload wheels
110+
# uses: actions/upload-artifact@v4
111+
# with:
112+
# name: wheels-musllinux-${{ matrix.platform.target }}
113+
# path: dist
114+
# - name: pytest
115+
# if: ${{ startsWith(matrix.platform.target, 'x86_64') }}
116+
# uses: addnab/docker-run-action@v3
117+
# with:
118+
# image: alpine:latest
119+
# options: -v ${{ github.workspace }}:/io -w /io
120+
# run: |
121+
# set -e
122+
# apk add py3-pip py3-virtualenv curl make clang
123+
# curl -LsSf https://astral.sh/uv/install.sh | sh
124+
# source $HOME/.local/bin/env
125+
# python3 -m virtualenv .venv
126+
# source .venv/bin/activate
127+
# # No numba packages for alpine
128+
# uv pip install 'nutpie[stan]' --find-links dist --force-reinstall
129+
# uv pip install pytest
130+
# pytest
131+
# - name: pytest
132+
# if: ${{ !startsWith(matrix.platform.target, 'x86') }}
133+
# uses: uraimo/run-on-arch-action@v2
134+
# with:
135+
# arch: ${{ matrix.platform.target }}
136+
# distro: alpine_latest
137+
# githubToken: ${{ github.token }}
138+
# install: |
139+
# apk add py3-virtualenv curl make clang
140+
# curl -LsSf https://astral.sh/uv/install.sh | sh
141+
# source $HOME/.local/bin/env
142+
# run: |
143+
# set -e
144+
# python3 -m virtualenv .venv
145+
# source $HOME/.local/bin/env
146+
# source .venv/bin/activate
147+
# uv pip install pytest
148+
# # No numba packages for alpine
149+
# uv pip install 'nutpie[stan]' --find-links dist --force-reinstall
150+
# pytest
151+
76152
windows:
77-
runs-on: windows-latest
153+
runs-on: ${{ matrix.platform.runner }}
78154
strategy:
79-
fail-fast: false
80155
matrix:
81-
# If you update the targets here, be sure to also update the
82-
# download-artifact step in the release job!
83-
target: [x64]
156+
platform:
157+
- runner: windows-latest
158+
target: x64
84159
steps:
85160
- uses: actions/checkout@v4
86161
- uses: actions/setup-python@v5
87162
with:
88-
python-version: '3.10'
89-
architecture: ${{ matrix.target }}
163+
python-version: "3.12"
164+
architecture: ${{ matrix.platform.target }}
165+
- name: Install uv
166+
uses: astral-sh/setup-uv@v5
90167
- name: Install LLVM and Clang
91168
uses: KyleMayes/install-llvm-action@v2
92169
with:
@@ -101,59 +178,63 @@ jobs:
101178
env:
102179
LIBCLANG_PATH: ${{ runner.temp }}/llvm/lib
103180
with:
104-
target: ${{ matrix.target }}
181+
target: ${{ matrix.platform.target }}
105182
args: --release --out dist --find-interpreter
106-
sccache: 'true'
183+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
107184
- name: Upload wheels
108185
uses: actions/upload-artifact@v4
109186
with:
110-
name: windows-${{ matrix.target }}-wheels
187+
name: wheels-windows-${{ matrix.platform.target }}
111188
path: dist
112189
- name: pytest
113-
if: ${{ !startsWith(matrix.target, 'aarch64') }}
190+
if: ${{ !startsWith(matrix.platform.target, 'aarch64') }}
114191
shell: bash
115192
run: |
116193
set -e
117-
pip install "nutpie[all]" --find-links dist --force-reinstall
118-
pip install --find-links dist --force-reinstall --no-deps --no-index 'nutpie[all]'
119-
pip install pytest
194+
python3 -m venv .venv
195+
source .venv/Scripts/activate
196+
uv pip install "nutpie[all]" --find-links dist --force-reinstall
197+
uv pip install pytest
120198
pytest
121199
122200
macos:
123-
runs-on: macos-latest
201+
runs-on: ${{ matrix.platform.runner }}
124202
strategy:
125203
fail-fast: false
126204
matrix:
127-
# If you update the targets here, be sure to also update the
128-
# download-artifact step in the release job!
129-
target: [x86_64, aarch64]
205+
platform:
206+
- runner: macos-13
207+
target: x86_64
208+
- runner: macos-14
209+
target: aarch64
130210
steps:
131211
- uses: actions/checkout@v4
132212
- uses: actions/setup-python@v5
133213
with:
134-
python-version: '3.10'
214+
python-version: "3.12"
215+
- name: Install uv
216+
uses: astral-sh/setup-uv@v5
135217
- uses: maxim-lobanov/setup-xcode@v1
136218
with:
137219
xcode-version: latest-stable
138220
- name: Build wheels
139221
uses: PyO3/maturin-action@v1
140222
with:
141-
target: ${{ matrix.target }}
223+
target: ${{ matrix.platform.target }}
142224
args: --release --out dist --find-interpreter
143-
sccache: 'true'
225+
sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
144226
- name: Upload wheels
145227
uses: actions/upload-artifact@v4
146228
with:
147-
name: macos-${{ matrix.target }}-wheels
229+
name: wheels-macos-${{ matrix.platform.target }}
148230
path: dist
149231
- name: pytest
150-
if: ${{ startsWith(matrix.target, 'aarch64') }}
151-
shell: bash
152232
run: |
153233
set -e
154-
pip install 'nutpie[all]' --find-links dist --force-reinstall
155-
pip install --find-links dist --force-reinstall --no-deps --no-index 'nutpie[all]'
156-
pip install pytest
234+
python3 -m venv .venv
235+
source .venv/bin/activate
236+
uv pip install 'nutpie[all]' --find-links dist --force-reinstall
237+
uv pip install pytest
157238
pytest
158239
159240
sdist:
@@ -168,45 +249,38 @@ jobs:
168249
- name: Upload sdist
169250
uses: actions/upload-artifact@v4
170251
with:
171-
name: sdist
252+
name: wheels-sdist
172253
path: dist
173254

174255
release:
175256
name: Release
176257
runs-on: ubuntu-latest
177-
if: "startsWith(github.ref, 'refs/tags/')"
258+
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
178259
needs: [linux, windows, macos, sdist]
260+
permissions:
261+
# Use to sign the release artifacts
262+
id-token: write
263+
# Used to upload release artifacts
264+
contents: write
265+
# Used to generate artifact attestation
266+
attestations: write
179267
steps:
180-
# Combine all the wheels and sdists into a single directory
181-
- name: Download artifacts
182-
uses: actions/download-artifact@v4
183-
with:
184-
name: linux-x86_64-wheels
185-
path: dist
186-
- uses: actions/download-artifact@v4
187-
with:
188-
name: linux-aarch64-wheels
189-
path: dist
190268
- uses: actions/download-artifact@v4
269+
- name: Generate artifact attestation
270+
uses: actions/attest-build-provenance@v1
191271
with:
192-
name: windows-x64-wheels
193-
path: dist
194-
- uses: actions/download-artifact@v4
195-
with:
196-
name: macos-x86_64-wheels
197-
path: dist
198-
- uses: actions/download-artifact@v4
199-
with:
200-
name: macos-aarch64-wheels
201-
path: dist
202-
- uses: actions/download-artifact@v4
203-
with:
204-
name: sdist
205-
path: dist
272+
subject-path: "wheels-*/*"
206273
- name: Publish to PyPI
274+
if: ${{ startsWith(github.ref, 'refs/tags/') }}
207275
uses: PyO3/maturin-action@v1
208276
env:
209277
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
210278
with:
211279
command: upload
212-
args: --skip-existing dist/*
280+
args: --non-interactive --skip-existing wheels-*/*
281+
- name: Upload to GitHub Release
282+
uses: softprops/action-gh-release@v1
283+
with:
284+
files: |
285+
wasm-wheels/*.whl
286+
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') }}

0 commit comments

Comments
 (0)