name: Build and test

on:
  pull_request:
    branches:
      - main
      - develop
  workflow_dispatch:

jobs:

  macos:
    name: Build and test (MacOS)
    runs-on: macos-latest
    strategy:
      matrix:
        python-version: ['3.8', '3.9', '3.10']
    steps:
    - uses: actions/checkout@v2
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v2
      with:
        python-version: ${{ matrix.python-version }}
    - name: Build qermit
      if: github.event_name == 'pull_request'
      run: |
        pip install -e . -v
    - name: Run mypy
      if: github.event_name == 'pull_request'
      run: |
        python3 -m pip install -U mypy==0.901
        mypy -p qermit 
    - name: Test qermit 
      if: github.event_name == 'pull_request'
      run: |
        cd tests
        pip install -r test_requirements.txt
        pytest
  linux:
    name: Build and test (Linux)
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ['3.8', '3.9', '3.10']
    steps:
    - uses: actions/checkout@v2
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v2
      with:
        python-version: ${{ matrix.python-version }}
    - name: Build qermit
      if: github.event_name == 'pull_request'
      run: |
        pip install -e . -v
    - name: Test qermit 
      if: github.event_name == 'pull_request'
      run: |
        cd tests
        pip install -r test_requirements.txt
        pytest
      
  windows:
    name: Build and test (Windows)
    runs-on: windows-latest
    strategy:
      matrix:
        python-version: ['3.8', '3.9', '3.10']
    steps:
    - uses: actions/checkout@v2
    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v2
      with:
        python-version: ${{ matrix.python-version }}
    - name: Build qermit
      if: github.event_name == 'pull_request'
      run: |
        pip install -e . -v
    - name: Test qermit 
      if: github.event_name == 'pull_request'
      run: |
        cd tests
        pip install -r test_requirements.txt
        pytest
