name: Run Pytest with different Python versions
on: 
  workflow_call:
    inputs:
      BEC_CORE_BRANCH:
        description: 'Branch of BEC Core to install'
        required: false
        default: 'main'
        type: string
      OPHYD_DEVICES_BRANCH:
        description: 'Branch of Ophyd Devices to install'
        required: false
        default: 'main'
        type: string

jobs:
  pytest-matrix:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ["3.11", "3.12", "3.13"]

    steps:

      - name: Checkout BEC Ophyd Devices
        uses: actions/checkout@v4
        with:
          repository: bec-project/ophyd_devices
          ref: ${{ inputs.OPHYD_DEVICES_BRANCH }}

      - name: Install Ophyd Devices and dependencies
        uses: ./.github/actions/ophyd_devices_install
        with:
          BEC_CORE_BRANCH: ${{ inputs.BEC_CORE_BRANCH }}
          OPHYD_DEVICES_BRANCH: ${{ inputs.OPHYD_DEVICES_BRANCH }}
          PYTHON_VERSION: ${{ matrix.python-version }}

      - name: Run Pytest
        run: |
          cd ./ophyd_devices
          pip install pytest pytest-random-order
          pytest -v --maxfail=2 --junitxml=report.xml --random-order ./tests
