name: Run Pytest on Pull Request

on:
  pull_request:
  push:
    branches: [main]

jobs:
  test:
    runs-on: ubuntu-latest

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

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.12"

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

      - name: Run Pytest
        run: |
          pip install -e .
          python -m pytest --full-run --check-config-side-effect -vs --cov src --cov-report term-missing

      - name: Upload test artifacts
        uses: actions/upload-artifact@v4
        with:
          name: optimize-results
          path: tests/testdata/new_optimize_result*
