integrate 0.2.0

Small, lightweight Rust library for performing numerical integration.
Documentation
name: CI

on:
  push:
    branches: ["main"]
  pull_request:
    branches: ["main"]
  # Allow release.yml to reuse this workflow as a CI gate before publishing.
  workflow_call:

# Cancel in-progress runs for the same branch/PR when a new commit is pushed.
concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: true

env:
  CARGO_TERM_COLOR: always

jobs:
  # ── Test matrix ────────────────────────────────────────────────────────────
  test:
    name: Test (${{ matrix.os }} / ${{ matrix.toolchain }})
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
        toolchain: [stable]
        include:
          # MSRV: keep in sync with rust-version in Cargo.toml
          - os: ubuntu-latest
            toolchain: "1.74"
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust ${{ matrix.toolchain }}
        uses: dtolnay/rust-toolchain@master
        with:
          toolchain: ${{ matrix.toolchain }}

      - uses: Swatinem/rust-cache@v2

      - name: Build
        run: cargo build --verbose

      - name: Test
        run: cargo test --verbose

  # ── Lint ───────────────────────────────────────────────────────────────────
  lint:
    name: Lint
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust stable (rustfmt + clippy)
        uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt, clippy

      - uses: Swatinem/rust-cache@v2

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

      - name: Clippy
        run: cargo clippy --all-targets -- -D warnings

  # ── Python bindings ────────────────────────────────────────────────────────
  test-python:
    name: Test Python bindings
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust stable
        if: hashFiles('python/Cargo.toml') != ''
        uses: dtolnay/rust-toolchain@stable

      - uses: Swatinem/rust-cache@v2
        if: hashFiles('python/Cargo.toml') != ''

      - name: Set up Python
        if: hashFiles('python/Cargo.toml') != ''
        uses: actions/setup-python@v5
        with:
          python-version: "3.12"

      - name: Install Python dependencies
        if: hashFiles('python/Cargo.toml') != ''
        run: pip install maturin pytest pytest-benchmark scipy numpy

      - name: Build and install integrate-py
        if: hashFiles('python/Cargo.toml') != ''
        working-directory: python
        run: maturin build --release && pip install target/wheels/*.whl

      - name: Run correctness tests
        if: hashFiles('python/Cargo.toml') != ''
        run: pytest python/tests/test_integrate.py -v -k "not bench"

  # ── Docs ───────────────────────────────────────────────────────────────────
  docs:
    name: Docs
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Rust stable
        uses: dtolnay/rust-toolchain@stable

      - uses: Swatinem/rust-cache@v2

      - name: Build rustdoc
        run: cargo doc --no-deps