name: Run Pytest

on:
  push:
    branches: [master]
  pull_request:
    branches: [master]

jobs:
  test:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ['3.11', '3.12']
    steps:
      - uses: actions/checkout@v6

      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v6
        with:
          python-version: ${{ matrix.python-version }}
          cache: 'pip'                     # speeds up successive runs

      - name: Install project + deps
        run: |
          python -m pip install --upgrade pip
          pip install -r requirements.txt
          pip install -e .                # editable install of this repo

      - name: Check dependency conflicts
        run: |
          pip install pipdeptree
          pipdeptree --warn fail

      - name: Run tests
        run: python -m pytest tests/ --junitxml=report.xml

      - name: Upload test report
        if: always()
        uses: actions/upload-artifact@v5
        with:
          name: pytest-report-${{ matrix.python-version }}   # unique per job
          path: report.xml
