-
Notifications
You must be signed in to change notification settings - Fork 2
144 lines (115 loc) · 5.15 KB
/
Copy pathci.yml
File metadata and controls
144 lines (115 loc) · 5.15 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
name: CI
on:
push:
branches: [main]
pull_request:
env:
CARGO_TERM_COLOR: always
# gxhash's AES/SSE2 target features are set arch-scoped in `.cargo/config.toml`
# (`cfg(target_arch = "x86_64")`), so we do NOT set a global RUSTFLAGS here:
# `-C target-feature=+aes,+sse2` is invalid on aarch64 (macos-latest) and
# would break that runner. The config applies the flags only on x86_64.
# The `pre-commit` job runs the full prek hook suite (rustfmt, clippy,
# cargo check, ruff, ty, hawkeye, and the file hygiene hooks). Every other
# job `needs:` it, so if the hooks fail nothing else runs — the lint/format
# gate is a hard prerequisite, which keeps `main` in compliance and avoids
# spending Actions minutes on tests when the cheap checks already fail.
jobs:
pre-commit:
name: pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Toolchain for the cargo-fmt / cargo-check / cargo-clippy hooks.
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
# `uv` backs the `uvx ruff …` and `uvx ty …` hooks.
- uses: astral-sh/setup-uv@v5
# Installs the mise-managed tools from mise.toml: `prek` (the hook
# runner) and `hawkeye` (used by the license-header hook via
# `mise exec -- hawkeye check`).
- uses: jdx/mise-action@v2
# `ty` resolves third-party imports (numpy, bloqade, kirin, …) and the
# `ppvm_python_native` extension through the project venv, so it must
# exist before the hooks run. This also builds the native module.
- name: Sync Python environment
run: uv sync --project ppvm-python --group dev
- name: Run all pre-commit hooks
# `no-commit-to-branch` is a local-only guard that fails by design on
# `main`; skip it in CI (prek honours the pre-commit `SKIP` env var).
env:
SKIP: no-commit-to-branch
run: mise exec -- prek run --all-files
rust-tests:
name: Rust tests
needs: pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- name: Run workspace tests
run: cargo test --workspace
- name: Run ppvm-stim tests with rayon feature
run: cargo test -p ppvm-stim --features rayon
# Cross-compile the whole workspace for browser wasm so a wasm regression
# surfaces in CI. Three crates are never browser-wasm targets and are
# excluded: `ppvm-python-native` (a CPython extension), `ppvm-cli` (a terminal
# binary), and `ppvm-tui` (its ratatui/crossterm terminal UI). The reusable
# engine lives in the library crates, which stay covered. Native-only
# acceleration deps (gxhash, dashmap →
# rayon, ahash) are pruned automatically by the `cfg(not(target_arch =
# "wasm32"))` dependency tables, and `rand`'s entropy uses the getrandom
# `wasm_js` backend wired in `.cargo/config.toml` — so no extra flags here.
wasm-build:
name: wasm32 build (browser)
needs: pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown
- uses: Swatinem/rust-cache@v2
- name: Build workspace for wasm32-unknown-unknown
run: cargo build --target wasm32-unknown-unknown --workspace --exclude ppvm-python-native --exclude ppvm-cli --exclude ppvm-tui
python-tests:
name: Python tests
needs: pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: astral-sh/setup-uv@v5
- name: Run Python tests
run: uv run --project ppvm-python --group dev pytest ppvm-python/test/ docs/examples/
# The pure-Rust crates are platform-agnostic and fully verified on Linux by
# the jobs above. The PyO3 extension is the only OS-sensitive artifact (macOS
# `-undefined dynamic_lookup`, Windows `python3.lib`), so it is the only thing
# rebuilt on other OSes — and building it via maturin compiles the entire
# crate tree on that OS as a side effect, so a cross-OS compile regression
# still surfaces here. `needs:` the Linux test jobs so macOS/Windows runners
# only spin up once Linux is green (no point paying for them otherwise).
extension-cross-platform:
name: Extension (${{ matrix.os }})
needs: [rust-tests, python-tests]
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
- uses: astral-sh/setup-uv@v5
# Compiles ppvm-python-native and its whole dependency tree, then links
# the abi3 extension the per-OS way (maturin handles dynamic_lookup /
# python3.lib for us).
- name: Build the extension (maturin via uv)
run: uv sync --project ppvm-python --group dev
- name: Run the extension's Python tests
run: uv run --project ppvm-python --group dev pytest ppvm-python/test/