-
Notifications
You must be signed in to change notification settings - Fork 0
184 lines (160 loc) · 5.59 KB
/
python.yml
File metadata and controls
184 lines (160 loc) · 5.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
name: Python (jacs)
on:
push:
branches: ["main"]
paths:
- "jacspy/**"
- "jacs/**"
- "binding-core/**"
- "Cargo.toml"
- "Cargo.lock"
- ".github/workflows/python.yml"
pull_request:
branches: ["main"]
paths:
- "jacspy/**"
- "jacs/**"
- "binding-core/**"
- "Cargo.toml"
- "Cargo.lock"
- ".github/workflows/python.yml"
workflow_dispatch: # Allows manual triggering
concurrency:
group: python-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
# Job to run tests on every push/PR (jacspy = local dir name; package on PyPI is jacs)
test-jacs:
name: Test jacs (x86_64)
runs-on: ubuntu-latest # Docker is available on ubuntu-latest runners (x86_64)
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image for testing (x86_64)
uses: docker/build-push-action@v5
with:
context: jacspy
file: jacspy/DockerfileBuilder
tags: jacs-build-x86_64
load: true
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Run jacs tests in Docker (x86_64)
working-directory: jacspy # To match PWD context if needed by scripts
env:
RUST_BACKTRACE: "1"
run: |
docker run --rm \
-v "$(pwd)/..:/workspace" \
jacs-build-x86_64 \
bash -c "\
cd /workspace/jacspy && \
/opt/python/cp311-cp311/bin/python3.11 -m venv .venv && \
source .venv/bin/activate && \
pip install maturin pytest pytest-asyncio pytest-xdist && \
pip install fastmcp mcp starlette && \
PYTEST_XDIST_WORKERS=4 make test-python-parallel"
- name: Verify sdist build on PR/push
working-directory: jacspy
env:
RUST_BACKTRACE: "1"
run: |
docker run --rm \
-v "$(pwd)/..:/workspace" \
jacs-build-x86_64 \
bash -c "\
cd /workspace/jacspy && \
/opt/python/cp311-cp311/bin/python3.11 -m pip install maturin && \
/opt/python/cp311-cp311/bin/python3.11 -m maturin sdist --out dist-sdist-check"
wheel-smoke-uv:
name: Wheel smoke install (uv)
if: github.event_name == 'push'
needs: test-jacs
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Set up Rust
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: '1.93'
- name: Install uv and maturin
run: python -m pip install uv maturin
- name: Build wheel
working-directory: jacspy
run: UV_NO_SYNC=1 uv run maturin build --release --out dist
- name: Smoke test wheel import in clean venv
working-directory: jacspy
run: |
set -euo pipefail
uv venv /tmp/jacs-wheel-smoke
uv pip install --python /tmp/jacs-wheel-smoke/bin/python dist/jacs-*.whl
/tmp/jacs-wheel-smoke/bin/python - <<'PY'
import jacs
import jacs.simple
print("wheel smoke imports ok")
PY
# Job to build wheels for CI coverage (PyPI package name is jacs)
# macOS wheels built by release-pypi.yml on tagged releases only (macOS = 10x minute multiplier).
build-jacs-wheels:
name: Build jacs wheels on ${{ matrix.os }}
if: github.event_name == 'push'
needs: [test-jacs, wheel-smoke-uv]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Needed for cibuildwheel versioning
- name: Set up QEMU (Linux only)
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v3
with:
platforms: all
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Set up Rust (macOS)
if: runner.os == 'macOS'
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: '1.93'
target: x86_64-apple-darwin,aarch64-apple-darwin
- name: Install cibuildwheel
run: python -m pip install cibuildwheel
- name: Build wheels
run: cibuildwheel --output-dir wheelhouse jacspy
env:
CIBW_ARCHS_LINUX: "x86_64 aarch64"
CIBW_ARCHS_MACOS: "x86_64 arm64"
CIBW_BUILD: "cp311-* cp312-* cp313-*"
# macOS: set minimum deployment target so delocate doesn't reject the wheel
CIBW_ENVIRONMENT_MACOS: 'MACOSX_DEPLOYMENT_TARGET=10.13'
# Linux: install Rust toolchain and OpenSSL inside manylinux containers
CIBW_BEFORE_ALL_LINUX: >-
if command -v yum &>/dev/null; then
yum install -y openssl-devel perl-IPC-Cmd;
elif command -v apk &>/dev/null; then
apk add --no-cache openssl-dev perl musl-dev;
fi &&
curl https://sh.rustup.rs -sSf | sh -s -- -y
CIBW_ENVIRONMENT_LINUX: 'PATH=$HOME/.cargo/bin:$PATH'
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: wheels-jacs-${{ matrix.os }}
# Path is relative to GITHUB_WORKSPACE (repo root)
path: ./wheelhouse/*.whl