name: Run Tests on Pull Request

on:
  pull_request:
    branches:
      - '**'  # Triggers on PRs to any branch

jobs:
  test:
    runs-on: ubuntu-latest

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

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.10'  # or your required version

      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt
          pip install -e .

      - name: Run tests
        run: |
          pytest tests/
      
      - name: Upload coverage reports to Codecov
        uses: codecov/codecov-action@v4
        with:
          file: ./coverage.xml
          flags: unittests
          name: codecov-gaitsetpy
        env:
          CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}