traits-2: rebuild the trait tower, engine, tableau and symbolic ring as ppvm-*-2
#265
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| - name: Run ppvm-stim tests on traits-2 backend | |
| run: cargo test -p ppvm-stim --no-default-features --features traits-2 | |
| - name: Run ppvm-stim traits-2 tests with rayon | |
| run: cargo test -p ppvm-stim --no-default-features --features traits-2,rayon | |
| - name: Run ppvm-vihaco tests on traits-2 backend | |
| run: cargo test -p ppvm-vihaco --no-default-features --features traits-2 | |
| - name: Run ppvm-vihaco traits-2 tests with rayon | |
| run: cargo test -p ppvm-vihaco --no-default-features --features traits-2,rayon | |
| - name: Run traits-2 frontend tests | |
| run: | | |
| cargo test -p ppvm-tui --no-default-features --features traits-2 | |
| cargo test -p ppvm-cli --all-targets --no-default-features --features traits-2,rayon | |
| # Cross-compile the whole workspace for browser wasm so a wasm regression | |
| # surfaces in CI. Four crates are never browser-wasm targets and are | |
| # excluded: `ppvm-python-native` (a CPython extension), `ppvm-cli` (a terminal | |
| # binary), `ppvm-tui` (its ratatui/crossterm terminal UI), and | |
| # `ppvm-conformance-2` (a `publish = false` differential-test/Criterion crate | |
| # that links both engines). 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. | |
| # | |
| # `ppvm-conformance-2` must be excluded rather than merely skipped, because a | |
| # workspace build UNIFIES features: it depends on `ppvm-tableau-sum` with | |
| # `features = ["rayon"]`, which propagates to `ppvm-tableau/rayon`. That | |
| # crate declares the feature globally but its `rayon` *dependency* only under | |
| # `cfg(not(target_arch = "wasm32"))`, so on wasm the `#[cfg(feature = | |
| # "rayon")]` bodies compile with no `rayon` crate to link (E0433). Nothing | |
| # enabled that feature before this crate existed, which is why the latent | |
| # mismatch in `ppvm-tableau` only surfaced now. | |
| 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 --exclude ppvm-conformance-2 | |
| # Criterion's benchmark targets are native-only (its dependency enables | |
| # Rayon), so cross-check the selected browser library rather than | |
| # `--all-targets`. | |
| - name: Check ppvm-stim traits-2 library for wasm32 | |
| run: cargo check -p ppvm-stim --target wasm32-unknown-unknown --no-default-features --features traits-2 --lib | |
| - name: Check ppvm-vihaco traits-2 library for wasm32 | |
| run: cargo check -p ppvm-vihaco --target wasm32-unknown-unknown --no-default-features --features traits-2 --lib | |
| 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/ |