name: CI

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

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.11", "3.12", "3.13", "3.14"]

    steps:
      - uses: actions/checkout@v4

      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}

      - name: Install dependencies
        run: pip install -e ".[dev]"

      - name: Lint (ruff check)
        run: ruff check src/ tests/

      - name: Format check (ruff format)
        run: ruff format --check src/ tests/

      - name: Type check (mypy)
        run: mypy --strict src/gentlify

      - name: Test with coverage
        run: pytest --cov=gentlify --cov-report=term-missing --cov-report=xml

      - name: Upload coverage artifact
        if: matrix.python-version == '3.14'
        uses: actions/upload-artifact@v4
        with:
          name: coverage-report
          path: coverage.xml

      - name: Upload to Codecov
        if: matrix.python-version == '3.14'
        uses: codecov/codecov-action@v4
        with:
          files: coverage.xml
          fail_ci_if_error: false
        env:
          CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
