name: Test Suite

on:
  push:
    branches:
      - main
  pull_request:

permissions:
  contents: read

jobs:
  test:
    runs-on: ubuntu-latest
    timeout-minutes: 30

    strategy:
      matrix:
        python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

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

      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip setuptools wheel
          pip install -e ".[dev]"

      - name: Run test suite
        run: |
          pytest tests/ -v --tb=short

      - name: Generate coverage report (if pytest-cov installed)
        run: |
          pytest tests/ --cov=baselinr --cov-report=xml --cov-report=term || pytest tests/ -v
        continue-on-error: true

      - name: Upload coverage to Codecov
        if: matrix.python-version == '3.14'
        uses: codecov/codecov-action@v4
        with:
          file: ./coverage.xml
          flags: unittests
          name: codecov-umbrella
          fail_ci_if_error: false
        continue-on-error: true

