parameters:
  name: ''
  vmImage: ''
  matrix: []

jobs:
- job: ${{ parameters.name }}
  pool:
    vmImage: ${{ parameters.vmImage }}
  strategy:
    matrix:
      ${{ insert }}: ${{ parameters.matrix }}

  steps:
    - script: |
        echo "Installing catchsegv"
        sudo apt-get update -qq
        sudo apt-get install -y glibc-tools
      displayName: 'Install catchsegv (provided by glibc-tools)'
      condition: eq('${{ parameters.name }}', 'Linux')

    - script: |
        set -e
        echo "Installing Miniconda"
        buildscripts/incremental/install_miniconda.sh
        export PATH=$HOME/miniconda3/bin:$PATH
        echo "Setting up Conda environment"
        buildscripts/incremental/setup_conda_environment.sh
      displayName: 'Before Install'

    - script: |
        set -e
        export PATH=$HOME/miniconda3/bin:$PATH
        buildscripts/incremental/build.sh
      displayName: 'Build'

    - script: |
        set -e
        export PATH=$HOME/miniconda3/bin:$PATH
        conda install -y flake8
        flake8 -j auto numba
      displayName: 'Flake8'
      condition: eq(variables['RUN_FLAKE8'], 'yes')

    - script: |
        set -e
        export PATH=$HOME/miniconda3/bin:$PATH
        # using conda-forge because main only have version < 1.0
        conda create -n mypy311 -y -c conda-forge python=3.11 mypy 
        conda run -n mypy311 mypy
      displayName: 'Mypy'
      condition: eq(variables['RUN_MYPY'], 'yes')

    - script: |
        set -e
        export PATH=$HOME/miniconda3/bin:$PATH
        buildscripts/incremental/test.sh
      displayName: 'Test'
