steps:

- checkout: self
  clean: true
  fetchDepth: 1

- bash: source .azure/install-$(MPI).sh
  displayName: 'Install MPI'

- task: UsePythonVersion@0
  inputs:
    versionSpec:  $(PYTHON_VERSION)
    architecture: $(PYTHON_ARCH)
  displayName: 'Use Python $(PYTHON_VERSION)'
- script: python -m pip install --upgrade setuptools pip wheel
  displayName: 'Install packaging tools'

- script: python -m pip install --upgrade cython
  displayName: 'Install build dependencies'
- script: python -m pip wheel -vvv --wheel-dir=dist .
  displayName: 'Build package'

- script: python -m pip install --upgrade numpy cffi pyyaml
  displayName: 'Install test dependencies'
- script: python -m pip install --no-index --find-links=dist mpi4py
  displayName: 'Install package for testing'
- script: mpiexec -n 1 python test/runtests.py -v
  displayName: 'Test package'
- script: mpiexec -n 2 python test/runtests.py -v -f -e spawn
  displayName: 'Test package'
- script: mpiexec -n 1 python demo/futures/test_futures.py -v
  displayName: 'Test subpackage'
- script: mpiexec -n 2 python demo/futures/test_futures.py -v
  displayName: 'Test subpackage'
- script: python -m pip uninstall --yes mpi4py
  displayName: 'Uninstall package after testing'
