#===============================================================================
# Copyright 2019-2024 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#===============================================================================

# Reference:
# https://learn.microsoft.com/en-us/azure/devops/pipelines/yaml-schema

trigger:
  batch: true
  branches:
    include: [ main, 'rls-*' ]
  paths:
    include:
      - .github
      - cmake
      - examples
      - include
      - src
      - tests
      - CMakeLists.txt
    exclude:
      - src/gpu
      - src/cpu/aarch64
      - src/cpu/ppc64
      - src/cpu/rv64
      - src/cpu/s390x
      - src/xpu

pr:
  autoCancel: true
  branches:
    include: [ main, 'rls-*' ]
  paths:
    include:
      - .github
      - cmake
      - examples
      - include
      - src
      - tests
      - CMakeLists.txt
    exclude:
      - src/gpu
      - src/cpu/aarch64
      - src/cpu/ppc64
      - src/cpu/rv64
      - src/cpu/s390x
      - src/xpu

jobs:
  - job: 'Ubuntu20'
    timeoutInMinutes: 120
    pool:
      vmImage: 'ubuntu-20.04'
    strategy:
      matrix: 
        clang:
          CC: clang
          CXX: clang++
        gcc:
          CC: gcc
          CXX: g++
    steps:
      - script: |
          if [ "$(CC)" == "clang" ]; then
            .github/automation/env/clang.sh 9
          fi
        displayName: "Init_Env"
      - script: |
          .github/automation/build.sh --threading omp --mode Release --source-dir $(pwd) --build-dir $(pwd)/build
        displayName: 'build'
      - script: |
          .github/automation/test.sh --build-dir $(pwd)/build --report-dir $(pwd)/report
        displayName: 'test'
        failOnStderr: true
  - job: 'Ubuntu22'
    timeoutInMinutes: 120
    pool:
      vmImage: 'ubuntu-22.04'
    strategy:
      matrix: 
        clang:
          CC: clang
          CXX: clang++
        gcc:
          CC: gcc
          CXX: g++
    steps:
      - script: |
          if [ "$(CC)" == "clang" ]; then
            .github/automation/env/clang.sh 15
          fi
        displayName: "Init_Env"
      - script: |
          .github/automation/build.sh --threading omp --mode Release --source-dir $(pwd) --build-dir $(pwd)/build
        displayName: 'build'
      - script: |
          .github/automation/test.sh --build-dir $(pwd)/build --report-dir $(pwd)/report
        displayName: 'test'
        failOnStderr: true
  - job: 'macOS13'
    timeoutInMinutes: 120
    pool:
      vmImage: 'macOS-13'
    steps:
      - script: |
          .github/automation/build.sh --threading omp --mode Release --source-dir $(pwd) --build-dir $(pwd)/build
        displayName: 'build'
      - script: |
          .github/automation/test.sh --build-dir $(pwd)/build --report-dir $(pwd)/report
        displayName: 'test'
        failOnStderr: true
  - job: 'macOS14'
    timeoutInMinutes: 120
    pool:
      vmImage: 'macOS-14'
    steps:
      - script: |
          .github/automation/build.sh --threading omp --mode Release --source-dir $(pwd) --build-dir $(pwd)/build
        displayName: 'build'
      - script: |
          .github/automation/test.sh --build-dir $(pwd)/build --report-dir $(pwd)/report
        displayName: 'test'
        failOnStderr: true
  - job: 'Windows_Server_2022'
    timeoutInMinutes: 120
    pool:
      vmImage: 'windows-2022'
    steps:
      - script: |
          .github\automation\build.bat /THREADING omp /MODE Release /VSVERSION vs2022 /SOURCEDIR %CD% /BUILDDIR %CD%\build
        displayName: 'build'
      - script: |
          .github\automation\test.bat /BUILDDIR %CD%\build /MODE Release /REPORTDIR %CD%\report
        displayName: 'test'
        failOnStderr: true
  - job: 'Windows_Server_2019'
    timeoutInMinutes: 120
    pool:
      vmImage: 'windows-2019'
    steps:
      - script: |
          .github\automation\build.bat /THREADING omp /MODE Release /VSVERSION vs2019 /SOURCEDIR %CD% /BUILDDIR %CD%\build
        displayName: 'build'
      - script: |
         .github\automation\test.bat /BUILDDIR %CD%\build /MODE Release /REPORTDIR %CD%\report
        displayName: 'test'
        failOnStderr: true
