name: tests

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: astral-sh/setup-uv@v7
      - name: Run ruff check
        run: uvx "ruff>=0.5" check src/ tests/

  test:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.11", "3.12", "3.13"]
    steps:
      - uses: actions/checkout@v5
      - name: Install uv
        uses: astral-sh/setup-uv@v7
        with:
          enable-cache: true
      - name: Set up Python ${{ matrix.python-version }}
        run: uv python install ${{ matrix.python-version }}
      - name: Sync dependencies
        run: uv sync --extra dev
      - name: Install package
        run: uv pip install -e .
      - name: Run unit tests
        run: uv run pytest -q

  build:
    runs-on: ubuntu-latest
    needs: test
    steps:
      - uses: actions/checkout@v5
      - name: Install uv
        uses: astral-sh/setup-uv@v7
      - name: Build wheel + sdist
        run: uv build
      - name: Verify wheel installs cleanly
        run: |
          uv run --isolated --with ./dist/*.whl python -c \
            "import abs_mcp.server as s; n = len(s.list_curated()); assert n >= 5, f'expected >=5 curated, got {n}'; print(f'OK ({n} curated dataflows)')"
      - uses: actions/upload-artifact@v5
        with:
          name: dist
          path: dist/
