qvass 0.1.1

A quantum circuit simulator in Rust.
Documentation
name: CI
on:
  push:
  pull_request:
  workflow_dispatch:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

env:
  CARGO_TERM_COLOR: always
  CARGO_INCREMENTAL: 0
  RUST_BACKTRACE: 1

jobs:
  verify:
    name: Verify (${{ matrix.os }}, ${{ matrix.config.name }})
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
        config:
          # Reference environment - comprehensive validation
          - name: Locked
            locked: true

          # Rust compiler compatibility - catch new lints and breaking changes
          - name: Stable Locked
            locked: true
            stable: true

          # Dependency compatibility - simulate downstream usage
          - name: Stable Unlocked
            stable: true
    runs-on: ${{ matrix.os }}
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.11'
          cache: 'pip'

      - name: Install Python dependencies
        run: python -m pip install -r scripts/requirements.txt

      - name: Check generated code
        run: |
          python scripts/make_rust_vectors.py
          git diff --exit-code

      - name: Install Rust toolchain (stable)
        if: matrix.config.stable
        uses: dtolnay/rust-toolchain@stable
        with:
          toolchain: stable
          components: rustfmt, clippy

      - name: Install Rust toolchain (from rust-toolchain.toml)
        if: '!matrix.config.stable'
        uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt, clippy

      - name: Cache Rust dependencies
        uses: actions/cache@v4
        with:
          path: |
            ~/.cargo/bin/
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
            target/
          key: ${{ runner.os }}-${{ matrix.config.name }}-${{ hashFiles('**/rust-toolchain.toml', '**/Cargo.lock', '**/Cargo.toml') }}
          restore-keys: |
            ${{ runner.os }}-${{ matrix.config.name }}-
            ${{ runner.os }}-

      - name: Cache cargo-vet binary
        if: "!matrix.config.stable && matrix.os == 'ubuntu-latest'"
        uses: actions/cache@v4
        with:
          path: ~/.cargo/bin/cargo-vet
          key: cargo-vet-${{ runner.os }}

      - name: Remove lockfile for dependency compatibility test
        if: '!matrix.config.locked'
        shell: bash
        run: rm -f Cargo.lock

      - name: Build
        run: cargo build --all-targets ${{ matrix.config.locked && '--locked' || '' }}

      - name: Run tests
        run: cargo test --all-targets ${{ matrix.config.locked && '--locked' || '' }}

      - name: Run clippy
        if: matrix.config.locked
        run: cargo clippy --all-targets --locked -- -D warnings

      - name: Build docs and examples
        if: '!matrix.config.stable'
        run: |
          echo "--- Building documentation ---"
          cargo doc --no-deps --locked

          echo "--- Building examples ---"
          cargo build --examples --locked

      - name: Run comprehensive checks (fmt, vet, no_std)
        if: "!matrix.config.stable && matrix.os == 'ubuntu-latest'"
        run: |
          echo "--- Checking formatting ---"
          cargo fmt -- --check

          echo "--- Installing cargo-vet if needed ---"
          if ! command -v cargo-vet &>/dev/null; then
            cargo install cargo-vet --locked
          fi

          echo "--- Auditing with cargo-vet ---"
          cargo vet

          echo "--- Installing targets for no_std compatibility ---"
          rustup target add riscv64gc-unknown-none-elf
          rustup target add wasm32-unknown-unknown

          echo "--- Checking no_std compatibility (embedded) ---"
          cargo check --target riscv64gc-unknown-none-elf --locked

          echo "--- Checking no_std compatibility (WASM) ---"
          cargo check --target wasm32-unknown-unknown --locked