pool:
  vmImage: $[ variables.POOL_IMAGE ]

strategy:
  matrix:
    Python27:
      python.version: '2.7'
    Python34:
      python.version: '3.4'
    Python35:
      python.version: '3.5'
    Python36:
      python.version: '3.6'
    Python37:
      python.version: '3.7'
    Docs:
      python.version: '3.6'
      TOXENV: docs
    TZ:
      python.version: '3.6'
      TOXENV: tz
    macOS:
      python.version: '3.6'
      POOL_IMAGE: macos-10.13
    Windows36:
      python.version: '3.6'
      POOL_IMAGE: vs2017-win2016
      installzic: 'windows'
    PyPy:
      python.version: 'pypy2'
    PyPy3:
      python.version: 'pypy3'
    WindowsPyPy2:
      python.version: 'pypy2'
      POOL_IMAGE: vs2017-win2016
      installzic: 'windows'
    WindowsPyPy3:
      python.version: 'pypy3'
      POOL_IMAGE: vs2017-win2016
      installzic: 'windows'

variables:
  TOXENV: py
  POOL_IMAGE: ubuntu-16.04

steps:
- task: UsePythonVersion@0
  inputs:
    versionSpec: $(python.version)

- bash: |
    python -m pip install -U six && python -m pip install -U 'tox < 3.8.0'
    if [[ $PYTHON_VERSION == "3.3" ]]; then pip install 'virtualenv<16.0'; fi
    if [[ $PYTHON_VERSION == "3.3" ]]; then pip install 'setuptools<40.0'; fi
  displayName: Ensure prereqs

- bash: |
    curl https://get.enterprisedb.com/postgresql/postgresql-9.4.20-1-windows-x64-binaries.zip --output postgresql.zip
    unzip -oq postgresql.zip -d postgresql
    echo $PATH
    echo "##vso[task.prependpath]$(System.DefaultWorkingDirectory)\postgresql\pgsql\bin"
  displayName: Install zic on Windows
  condition: eq(variables.installzic, 'windows')

- bash: |
    if [[ $TOXENV == "py" ]]; then
      ./ci_tools/retry.sh python updatezinfo.py
      python -m tox -- tests --cov-config=tox.ini --cov=dateutil --junitxml=unittests/TEST-$(Agent.JobName).xml
      python -m tox -e coverage,codecov || true
    else
      python -m tox
    fi
  displayName: Run tox

- task: PublishTestResults@2
  inputs:
    testResultsFiles: '**/TEST-*.xml'
    testRunTitle: '$(Agent.JobName)'
  condition: and(succeededOrFailed(), not(eq(variables['Agent.JobName'], 'Docs')))
