trigger:
  branches:
    include:
    - master
    - release*
variables:
  ExternalDataVersion: 4.13.1
jobs:
- job: macOS
  timeoutInMinutes: 0
  cancelTimeoutInMinutes: 300
  pool:
    vmImage: 'macOS 10.13'
  steps:
    - checkout: self
      clean: true
      fetchDepth: 5
    - bash: |
        set -x
        if [ -n "$(System.PullRequest.SourceCommitId)" ]; then
          git checkout $(System.PullRequest.SourceCommitId)
        fi
      displayName: Checkout pull request HEAD

    - task: UsePythonVersion@0
      inputs:
        versionSpec: '3.7'

    - bash: |
        set -x

        sudo pip3 install ninja numpy

      displayName: Install dependencies
    - bash: |
        set -x

        git clone -b dashboard --single-branch https://github.com/InsightSoftwareConsortium/ITK.git ITK-dashboard

        curl -L https://github.com/InsightSoftwareConsortium/ITK/releases/download/v$(ExternalDataVersion)/InsightData-$(ExternalDataVersion).tar.gz -O
        cmake -E tar xfz InsightData-$(ExternalDataVersion).tar.gz
        cmake -E rename InsightToolkit-$(ExternalDataVersion)/.ExternalData/MD5 $(Build.SourcesDirectory)/.ExternalData/MD5

      displayName: Download dashboard script and testing data
      workingDirectory: $(Agent.BuildDirectory)
    - bash: |
        set -x

        c++ --version
        cmake --version

        export BUILD_EXAMPLES=OFF
        export CTEST_BUILD_CONFIGURATION=MinSizeRelease
        export ITK_WRAP_PYTHON=ON
        export CTEST_OUTPUT_ON_FAILURE=1

        ctest -S ITK-dashboard/azure_dashboard.cmake -V -j 4
      displayName: Build and test
      workingDirectory: $(Agent.BuildDirectory)
