# This workflow runs a moderate test suite on bugfix and automatically merges changes into develop
# This includes all versions of supported Python, no MacOS, only unit tests,
# and only tests environments with Cython in them

name: Build and run tests (bugfix)

on:
  push:
    branches: [ "bugfix" ]
  workflow_dispatch: # Allow manual running from GitHub

jobs:
  build:
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest] # No Mac
        python-version: [3.9, '3.10', '3.11', '3.12']
        use-cython: ['true', 'false']
    uses: ./.github/workflows/reuseable-main.yml
    name: Run pyGSTi tests
    with:
      os: ${{ matrix.os }}
      python-version: ${{ matrix.python-version }}
      use-cython: 'true' # Cython only
      run-unit-tests: 'true'
      run-extra-tests: 'false' # No integration tests
      run-notebook-tests: 'false' # No notebook tests 

  push: # Push to stable "beta" branch on successful build
    runs-on: ubuntu-latest

    if: github.ref == 'refs/heads/bugfix' && github.event_name == 'push'

    steps:
    - uses: actions/checkout@v4
      with:
        fetch-depth: 0
        token: ${{ secrets.PYGSTI_TOKEN }}
    - name: Merge changes to develop branch
      run: |
        git config --global user.name 'PyGSTi'
        git config --global user.email 'pygsti@noreply.github.com'
        git checkout develop
        git merge --ff-only ${GITHUB_SHA} && git push origin develop





