name: CI

permissions:
  contents: read

on:
  push:
  pull_request:

env:
  CARGO_TERM_COLOR: always

jobs:
  muscat:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4

    - name: Setup Rust toolchain
      uses: actions-rust-lang/setup-rust-toolchain@v1

    - name: Build
      run: cargo build --verbose

    - name: Run tests
      run: cargo test --verbose

    - name: Check formatting
      run: cargo fmt --check

    - name: Lint with Clippy
      run: cargo clippy -- -Dwarnings

    - name: Build examples
      run: cargo build --examples

    - name: Build benchmarks
      run: cargo bench --no-run

  muscatpy:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v4

    - name: Setup Rust caching
      uses: Swatinem/rust-cache@v2
      with:
        workspaces: "muscatpy -> target"

    - uses: actions/setup-python@v5
      with:
        python-version: "3.10"

    - name: Build wheels
      uses: PyO3/maturin-action@v1
      with:
        command: build
        args: --manifest-path muscatpy/Cargo.toml --release

    - name: Check formatting
      run: cargo fmt --manifest-path muscatpy/Cargo.toml --check

    - name: Lint with Clippy
      run: cargo clippy --manifest-path muscatpy/Cargo.toml -- -Dwarnings
