Skip to content

[codex] feat(stim): mirror stim simulator api after crate split #5

[codex] feat(stim): mirror stim simulator api after crate split

[codex] feat(stim): mirror stim simulator api after crate split #5

Workflow file for this run

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
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/
# Verify the workspace and the PyO3 extension compile, link, and test on all
# three desktop OSes. The deep test suites above run on Linux only; this job
# is the cross-platform compilation/linking gate.
cross-platform:
name: Build (${{ matrix.os }})
needs: pre-commit
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: Swatinem/rust-cache@v2
# Compiles every crate and target (lib, tests, benches, examples) without
# linking — the portable "does it build" gate, identical on each OS.
- name: Check the workspace compiles
run: cargo check --workspace --all-targets
# Links the cdylib too, which exercises the macOS `-undefined
# dynamic_lookup` flag from ppvm-python-native's build.rs. Skipped on
# Windows, where linking the extension needs python3.lib — that path is
# covered by the maturin build below instead.
- name: Build the workspace
if: runner.os != 'Windows'
run: cargo build --workspace
- uses: astral-sh/setup-uv@v5
# maturin links the abi3 extension the per-OS way (dynamic_lookup on
# macOS, python3.lib on Windows); pytest confirms it imports and runs.
- name: Build the extension via maturin
run: uv sync --project ppvm-python --group dev
- name: Run Python tests
run: uv run --project ppvm-python --group dev pytest ppvm-python/test/