# from matplotlib's azure setup

variables:
  HDF5_CACHE_DIR: $(Pipeline.Workspace)/cache/hdf5
  PIP_CACHE_DIR: $(Pipeline.Workspace)/cache/pip
  CCACHE_DIR: $(Pipeline.Workspace)/cache/ccache

jobs:
- job: 'static_checks'
  pool:
    vmImage: ubuntu-20.04
  variables:
    TOXENV: docs,checkreadme,pre-commit,rever
  steps:
    - task: UsePythonVersion@0
      inputs:
        versionSpec: '3.8'
        architecture: 'x64'
    - script: |
        pip install tox
      displayName: Install tox
    - script: |
        tox
      displayName: tox

- job: 'linux_wheels'
  pool:
    vmImage: ubuntu-20.04
  variables:
    CIBW_BUILD: cp3[789]-manylinux_x86_64
    CIBW_MANYLINUX_X86_64_IMAGE: ghcr.io/h5py/manylinux2010_x86_64-hdf5
    # Include less debugging info for smaller wheels (default is -g2)
    CIBW_ENVIRONMENT: "CFLAGS=-g1"
  steps:
    - template: ci/azure-pipelines-wheels.yml
      parameters:
        platform: linux

- job: 'windows_wheels'
  pool:
    vmImage: vs2017-win2016
  variables:
    HDF5_VERSION: 1.12.0
    HDF5_DIR: $(HDF5_CACHE_DIR)/$(HDF5_VERSION)
    HDF5_VSVERSION: "15-64"
    CIBW_BUILD: cp3[789]-win_amd64
  steps:
    - template: ci/azure-pipelines-wheels.yml
      parameters:
        platform: windows

- job: 'macos_wheels'
  pool:
    vmImage: macOS-10.15
  variables:
    MACOSX_DEPLOYMENT_TARGET: 10.9
    HDF5_VERSION: 1.12.0
    HDF5_DIR: $(HDF5_CACHE_DIR)/$(HDF5_VERSION)
    CIBW_BUILD: cp3[789]-macosx_x86_64
  steps:
    - template: ci/azure-pipelines-wheels.yml
      parameters:
        platform: macos

- job: 'ubuntu1604'
  pool:
    vmImage: ubuntu-20.04
  strategy:
    matrix:
      # -deps : test with default (latest) versions of dependencies
      # -mindeps : test with oldest supported version of (python) dependencies
      # -deps-pre : test pre-release versions of (python) dependencies)
      # -tables : also check compatibility with pytables
      py37:  # HDF5 1.8 installed from apt on Ubuntu
        python.version: '3.7'
        TOXENV: py37-test-deps,py37-test-mindeps,py37-test-deps-tables
    # test when we're not in a unicode locale
      py37-Clocale:
        python.version: '3.7'
        TOXENV: py37-test-deps
        TOX_TESTENV_PASSENV: LANG LC_ALL
        LANG: C
        LC_ALL: C
        H5PY_ENFORCE_COVERAGE: yes
    # Build HDF5 1.10 or 1.12 in the test environment
      py37-deps-hdf51103:
        python.version: '3.7'
        TOXENV: py37-test-deps
        HDF5_VERSION: 1.10.3
        HDF5_DIR: $(HDF5_CACHE_DIR)/$(HDF5_VERSION)
        H5PY_ENFORCE_COVERAGE: yes
      py37-deps-hdf51106:
        python.version: '3.7'
        TOXENV: py37-test-deps
        HDF5_VERSION: 1.10.6
        HDF5_DIR: $(HDF5_CACHE_DIR)/$(HDF5_VERSION)
        H5PY_ENFORCE_COVERAGE: yes
      py38-deps-hdf51107:
        python.version: '3.8'
        TOXENV: py38-test-deps
        HDF5_VERSION: 1.10.7
        HDF5_DIR: $(HDF5_CACHE_DIR)/$(HDF5_VERSION)
        H5PY_ENFORCE_COVERAGE: yes
      py38-deps-hdf51120:
        python.version: '3.8'
        TOXENV: py38-test-deps
        HDF5_VERSION: 1.12.0
        HDF5_DIR: $(HDF5_CACHE_DIR)/$(HDF5_VERSION)
        H5PY_ENFORCE_COVERAGE: yes
      py39-deps-hdf51120:
        python.version: '3.9'
        TOXENV: py39-test-deps
        HDF5_VERSION: 1.12.0
        HDF5_DIR: $(HDF5_CACHE_DIR)/$(HDF5_VERSION)
        H5PY_ENFORCE_COVERAGE: yes
    # do mpi tests
      py37-deps-hdf51105-mpi:
        python.version: '3.7'
        TOXENV: py37-test-mindeps-mpi4py
        HDF5_VERSION: 1.10.5
        HDF5_DIR: $(HDF5_CACHE_DIR)/$(HDF5_VERSION)
        HDF5_MPI: ON
        CC: mpicc
    maxParallel: 4

  steps:
    - template: ci/azure-pipelines-steps.yml
      parameters:
        platform: linux
        installer: apt
        shell: unix



- job: 'test_linux_wheels'
  dependsOn: linux_wheels
  pool:
    vmImage: ubuntu-20.04
  variables:
    H5PY_TEST_CHECK_FILTERS: 1

  strategy:
    matrix:
      py37:
        python.version: '3.7'
        TOXENV: py37-test-deps,py37-test-mindeps,py37-test-deps-pre,py37-test-deps-tables
        WHL_FILE: h5py*-cp37-*manylinux2010_x86_64.whl
      py38:
        python.version: '3.8'
        TOXENV: py38-test-deps,py38-test-mindeps,py38-test-deps-pre
        WHL_FILE: h5py*-cp38-*manylinux2010_x86_64.whl
      py39:
        python.version: '3.9'
        TOXENV: py39-test-deps,py39-test-mindeps,py39-test-deps-pre
        WHL_FILE: h5py*-cp39-*manylinux2010_x86_64.whl

  steps:
    - template: ci/azure-pipelines-test-wheels.yml
      parameters:
        platform: linux


- job: 'Windows'
  pool:
    vmImage: vs2017-win2016
  strategy:
    matrix:
    # -deps : test with default (latest) versions of dependencies
    # -mindeps : test with oldest supported version of (python) dependencies
    # -deps-pre : test pre-release versions of (python) dependencies)
    #
    # 64 bit - HDF5 1.8
      py37-hdf518:
        python.version: '3.7'
        TOXENV: py37-test-deps,py37-test-deps-pre
        HDF5_VERSION: 1.8.17
        HDF5_DIR: $(HDF5_CACHE_DIR)/$(HDF5_VERSION)
        HDF5_VSVERSION: "15-64"
        H5PY_ENFORCE_COVERAGE: yes
    # 64 bit - HDF5 1.10
      py38-hdf5110:
        python.version: '3.8'
        TOXENV: py38-test-deps,py38-test-mindeps,py38-test-deps-pre
        HDF5_VERSION: 1.10.6
        HDF5_DIR: $(HDF5_CACHE_DIR)/$(HDF5_VERSION)
        HDF5_VSVERSION: "15-64"
        H5PY_ENFORCE_COVERAGE: yes
      py39-hdf5110:
        python.version: '3.9'
        TOXENV: py39-test-deps,py39-test-mindeps,py39-test-deps-pre
        HDF5_VERSION: 1.10.6
        HDF5_DIR: $(HDF5_CACHE_DIR)/$(HDF5_VERSION)
        HDF5_VSVERSION: "15-64"
        H5PY_ENFORCE_COVERAGE: yes
    # 64 bit - HDF5 1.12
    # Fewer combinations here; test_windows_wheels also tests HDF5 1.12
      py38-hdf5112:
        python.version: '3.8'
        TOXENV: py38-test-deps
        HDF5_VERSION: 1.12.0
        HDF5_DIR: $(HDF5_CACHE_DIR)/$(HDF5_VERSION)
        HDF5_VSVERSION: "15-64"
        H5PY_ENFORCE_COVERAGE: yes
    maxParallel: 4

  steps:
    - template: ci/azure-pipelines-steps.yml
      parameters:
        platform: windows
        installer: nuget
        shell: cmd

- job: 'test_windows_wheels'
  dependsOn: windows_wheels
  pool:
    vmImage: vs2017-win2016
  variables:
    H5PY_TEST_CHECK_FILTERS: 1

  strategy:
    matrix:
      py37:
        python.version: '3.7'
        TOXENV: py37-test-deps,py37-test-mindeps,py37-test-deps-tables
        WHL_FILE: h5py*-cp37-*.whl
      py38:
        python.version: '3.8'
        TOXENV: py38-test-deps,py38-test-mindeps,py38-test-deps-pre
        WHL_FILE: h5py*-cp38-*.whl
      py39:
        python.version: '3.9'
        TOXENV: py39-test-deps,py39-test-mindeps,py39-test-deps-pre
        WHL_FILE: h5py*-cp39-*.whl

  steps:
    - template: ci/azure-pipelines-test-wheels.yml
      parameters:
        platform: windows

- job: 'macOS1015'
  pool:
    vmImage: macOS-10.15
  strategy:
    matrix:
      # -deps : test with default (latest) versions of dependencies
      # -mindeps : test with oldest supported version of (python) dependencies
      # -deps-pre : test pre-release versions of (python) dependencies)
      py37:
        python.version: '3.7'
        TOXENV: py37-test-deps,py37-test-mindeps
        H5PY_ENFORCE_COVERAGE: yes
      py38:
        python.version: '3.8'
        TOXENV: py38-test-deps,py38-test-mindeps,py38-test-deps-pre
        H5PY_ENFORCE_COVERAGE: yes
      py39:
        python.version: '3.9'
        TOXENV: py39-test-deps,py39-test-mindeps,py39-test-deps-pre
        H5PY_ENFORCE_COVERAGE: yes
    # test against newer HDF5
#      py37-deps-hdf51103:
#        python.version: '3.7'
#        TOXENV: py37-test-deps
#        HDF5_VERSION: 1.10.3
#        HDF5_DIR: $(HDF5_CACHE_DIR)/$(HDF5_VERSION)
#      py37-deps-hdf51104:
#        python.version: '3.7'
#        TOXENV: py37-test-deps
#        HDF5_VERSION: 1.10.4
#        HDF5_DIR: $(HDF5_CACHE_DIR)/$(HDF5_VERSION)
#      py37-deps-hdf51105:
#        python.version: '3.7'
#        TOXENV: py37-test-deps
#        HDF5_VERSION: 1.10.5
#        HDF5_DIR: $(HDF5_CACHE_DIR)/$(HDF5_VERSION)
    maxParallel: 4

  steps:
    - template: ci/azure-pipelines-steps.yml
      parameters:
        platform: macos
        installer: brew
        shell: unix

- job: 'test_macos_wheels'
  dependsOn: macos_wheels
  pool:
    vmImage: macOS-10.15
  variables:
    H5PY_TEST_CHECK_FILTERS: 1

  strategy:
    matrix:
      py37:
        python.version: '3.7'
        TOXENV: py37-test-deps,py37-test-mindeps,py37-test-deps-tables
        WHL_FILE: h5py*-cp37-*.whl
      py38:
        python.version: '3.8'
        TOXENV: py38-test-deps,py38-test-mindeps,py38-test-deps-pre
        WHL_FILE: h5py*-cp38-*.whl
      py39:
        python.version: '3.9'
        TOXENV: py39-test-deps,py39-test-mindeps,py39-test-deps-pre
        WHL_FILE: h5py*-cp39-*.whl

  steps:
    - template: ci/azure-pipelines-test-wheels.yml
      parameters:
        platform: macos
