Skip to content

Commit 1254a72

Browse files
authored
Add Python CI (#25)
1 parent b997244 commit 1254a72

File tree

4 files changed

+362
-10
lines changed

4 files changed

+362
-10
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@ name: Build
22

33
on:
44
push:
5+
branches:
6+
- main
7+
tags:
8+
- '*'
59
pull_request:
10+
branches:
11+
- main
612
workflow_dispatch:
713

8-
jobs:
9-
pre_ci:
10-
uses: dtolnay/.github/.github/workflows/pre_ci.yml@master
1114

15+
jobs:
1216
build:
1317
name: ${{matrix.name || format('Rust {0}', matrix.rust)}}
14-
needs: pre_ci
15-
if: needs.pre_ci.outputs.continue
1618
runs-on: ${{matrix.os}}-latest
1719
strategy:
1820
fail-fast: false

.github/workflows/python.yml

Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
# This file is autogenerated by maturin v1.8.3
2+
# To update, run
3+
#
4+
# maturin generate-ci github
5+
#
6+
name: Wheels
7+
8+
on:
9+
push:
10+
branches:
11+
- main
12+
tags:
13+
- '*'
14+
pull_request:
15+
branches:
16+
- main
17+
workflow_dispatch:
18+
19+
permissions:
20+
contents: read
21+
22+
jobs:
23+
linux:
24+
runs-on: ${{ matrix.platform.runner }}
25+
strategy:
26+
matrix:
27+
platform:
28+
- runner: ubuntu-22.04
29+
target: x86_64
30+
steps:
31+
- uses: actions/checkout@v4
32+
with:
33+
submodules: true
34+
- uses: actions/setup-python@v5
35+
with:
36+
python-version: 3.x
37+
- name: Build wheels
38+
uses: PyO3/maturin-action@v1
39+
with:
40+
target: ${{ matrix.platform.target }}
41+
args: --release --out dist --find-interpreter
42+
working-directory: crackers_python
43+
manylinux: manylinux2_28
44+
before-script-linux: |
45+
curl -LsSf https://astral.sh/uv/install.sh | sh
46+
uv venv
47+
source .venv/bin/activate
48+
python3 gh_actions_setup.py ${{ matrix.platform.target }}
49+
if [ -f .z3env ]; then
50+
# shellcheck disable=SC1091
51+
. .z3env
52+
echo "✅ Loaded Z3_SYS_Z3_HEADER from .z3env"
53+
else
54+
echo "❌ .z3env not found. Please run the installer script first."
55+
fi
56+
# sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
57+
- name: Upload wheels
58+
uses: actions/upload-artifact@v4
59+
with:
60+
name: wheels-linux-${{ matrix.platform.target }}
61+
path: crackers_python/dist
62+
63+
linux-arm:
64+
if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
65+
name: Build wheel on ${{ matrix.platform.name }}
66+
runs-on: ubuntu-latest
67+
strategy:
68+
matrix:
69+
platform:
70+
- name: arm64
71+
arch: aarch64
72+
73+
steps:
74+
- name: Checkout code
75+
uses: actions/checkout@v4
76+
with:
77+
submodules: true
78+
79+
- name: Set up QEMU
80+
uses: docker/setup-qemu-action@v3
81+
82+
- name: Run on ARM using run-on-arch-action
83+
uses: uraimo/run-on-arch-action@v3
84+
with:
85+
arch: ${{ matrix.platform.arch }}
86+
distro: ubuntu20.04
87+
githubToken: ${{ github.token }}
88+
run: |
89+
set -eux
90+
cd crackers_python
91+
92+
# Install dependencies
93+
apt update
94+
apt install -y curl build-essential python3 python3-pip python3-venv libclang-dev llvm-dev clang libz3-dev
95+
96+
# Install Rust
97+
curl https://sh.rustup.rs -sSf | sh -s -- -y
98+
source "$HOME/.cargo/env"
99+
100+
# Install Maturin
101+
pip3 install maturin[patchelf]
102+
103+
# Build the wheel
104+
maturin build --release --out dist --find-interpreter --manylinux 2_31
105+
106+
- name: Upload wheels
107+
uses: actions/upload-artifact@v4
108+
with:
109+
name: wheels-linux-${{ matrix.platform.arch }}
110+
path: crackers_python/dist
111+
112+
# windows:
113+
# runs-on: ${{ matrix.platform.runner }}
114+
# strategy:
115+
# matrix:
116+
# platform:
117+
# - runner: windows-latest
118+
# target: x64
119+
# steps:
120+
# - uses: actions/checkout@v4
121+
# with:
122+
# submodules: true
123+
# - name: Install Z3 using Chocolatey
124+
# run: |
125+
# choco install z3
126+
# - name: Set Z3 environment variables
127+
# run: |
128+
# echo ::set-env name=Z3_INCLUDE_PATH::C:\tools\z3\include
129+
# echo ::set-env name=Z3_LIB_PATH::C:\tools\z3\lib
130+
# - uses: actions/setup-python@v5
131+
# with:
132+
# python-version: 3.x
133+
# architecture: ${{ matrix.platform.target }}
134+
# - name: Build wheels
135+
# uses: PyO3/maturin-action@v1
136+
# with:
137+
# target: ${{ matrix.platform.target }}
138+
# args: --release --out dist --find-interpreter
139+
# working-directory: crackers_python
140+
# # sccache: ${{ !startsWith(github.ref, 'refs/tags/') }}
141+
# env:
142+
# Z3_SYS_Z3_PATH: "C:/Program Files/Z3/include"
143+
# - name: Upload wheels
144+
# uses: actions/upload-artifact@v4
145+
# with:
146+
# name: wheels-windows-${{ matrix.platform.target }}
147+
# path: crackers_python/dist
148+
149+
macos:
150+
runs-on: ${{ matrix.platform.runner }}
151+
strategy:
152+
matrix:
153+
platform:
154+
- runner: macos-14
155+
target: aarch64
156+
python: [ '3.11', '3.12', '3.13' ]
157+
steps:
158+
- uses: actions/checkout@v4
159+
with:
160+
submodules: true
161+
- uses: actions/setup-python@v5
162+
with:
163+
python-version: 3.x
164+
- name: "Initialize python environment"
165+
run: |
166+
curl -LsSf https://astral.sh/uv/install.sh | sh
167+
uv venv --python ${{matrix.python}}
168+
source .venv/bin/activate
169+
uv sync --no-install-project --project crackers_python --active
170+
export Z3_SYS_Z3_HEADER=$(python crackers_python/find_venv_library_path.py)/z3/include/z3.h
171+
uv build --project crackers_python --wheel --out-dir dist
172+
- name: Upload wheels
173+
uses: actions/upload-artifact@v4
174+
with:
175+
name: wheels-macos-${{ matrix.platform.target }}-$${{matrix.python}}
176+
path: dist
177+
178+
sdist:
179+
runs-on: ubuntu-latest
180+
steps:
181+
- uses: actions/checkout@v4
182+
with:
183+
submodules: true
184+
- name: Build sdist
185+
uses: PyO3/maturin-action@v1
186+
with:
187+
command: sdist
188+
args: --out dist
189+
working-directory: crackers_python
190+
- name: Upload sdist
191+
uses: actions/upload-artifact@v4
192+
with:
193+
name: wheels-sdist
194+
path: crackers_python/dist
195+
196+
# release:
197+
# name: Release
198+
# runs-on: ubuntu-latest
199+
# if: ${{ startsWith(github.ref, 'refs/tags/') || github.event_name == 'workflow_dispatch' }}
200+
# needs: [ linux, linux-arm, macos, sdist ]
201+
# permissions:
202+
# # Use to sign the release artifacts
203+
# id-token: write
204+
# # Used to upload release artifacts
205+
# contents: write
206+
# # Used to generate artifact attestation
207+
# attestations: write
208+
# steps:
209+
# - uses: actions/download-artifact@v4
210+
# - name: Generate artifact attestation
211+
# uses: actions/attest-build-provenance@v2
212+
# with:
213+
# subject-path: 'wheels-*/*'
214+
# - name: Publish to PyPI
215+
# if: ${{ startsWith(github.ref, 'refs/tags/') }}
216+
# uses: PyO3/maturin-action@v1
217+
# env:
218+
# MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
219+
# with:
220+
# command: upload
221+
# args: --non-interactive --skip-existing wheels-*/*
222+
# working-directory: crackers_python
223+
#

.github/workflows/style.yml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@ name: Style
22

33
on:
44
push:
5+
branches:
6+
- main
7+
tags:
8+
- '*'
59
pull_request:
10+
branches:
11+
- main
612
workflow_dispatch:
713

814
jobs:
9-
pre_ci:
10-
uses: dtolnay/.github/.github/workflows/pre_ci.yml@master
11-
1215
build:
1316
name: ${{matrix.name || format('Rust {0}', matrix.rust)}}
14-
needs: pre_ci
15-
if: needs.pre_ci.outputs.continue
1617
runs-on: ${{matrix.os}}-latest
1718
strategy:
1819
fail-fast: false

0 commit comments

Comments
 (0)