parameters:
  platform: none
  installer: none

steps:
  - task: UsePythonVersion@0
    inputs:
      versionSpec: "$(python.version)"
      architecture: "x64"
    displayName: "Use Python $(python.version)"
    condition: and(succeeded(), ne(variables['python.version'], 'Pre'))

  - ${{ if eq(parameters.installer, 'brew') }}:
    - script: |
        brew install open-mpi
      displayName: 'Install brew dependencies'
  - ${{ if eq(parameters.installer, 'apt') }}:
    - script: |
        sudo apt-get update
        sudo apt-get install openmpi-bin libopenmpi-dev
      displayName: 'Install apt dependencies'

  - script: |
      python -m pip install --upgrade pip
      pip install tox codecov twine wheel
    displayName: "Install pip dependencies"

  - task: TwineAuthenticate@0
    inputs:
      externalFeeds: "pypi"
    condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/')

  - script: env
    displayName: "print env"

  - script: |
      tox
    displayName: "tox"

  #- script: |
  #    codecov
  #  displayName: 'codecov'
  # hopefully the bash uploader will work
  - script: |
      bash <(curl -s https://codecov.io/bash)
    displayName: "Upload to codecov.io"

  - script: |
      python setup.py sdist bdist_wheel
      twine upload --skip-existing -r pypi --config-file $(PYPIRC_PATH) dist/*
    displayName: "Upload to PyPI"
    condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/')
