name: CI

on:
  push:
    branches: ["**"]
    tags-ignore: ["v*"]
  pull_request:

permissions:
  contents: read

jobs:
  test:
    name: Test / ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
    runs-on: ${{ matrix.os }}

    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt, clippy

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

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

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

  python-smoke:
    name: Python smoke test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

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

      - uses: astral-sh/setup-uv@v5

      - name: Install dependencies
        run: uv pip install --system maturin polars

      - name: Build wheel
        run: maturin build --release -o dist

      - name: Install and smoke test
        run: |
          uv pip install --system dist/*.whl
          python -c "import ambers; print('ambers imported successfully')"
