pool:
  vmImage: 'ubuntu-22.04'

trigger:
  branches:
    exclude:
    - master
    # - ci/*
    # include:
    # - ci/azure*

jobs:
- job: clang_analysis
  timeoutInMinutes: 120
  variables:
    CC: clang-14
    CXX: clang++-14
    CFLAGS: -Wextra -Werror
    CXXFLAGS: -Wextra -Werror
  steps:
  - script: uname -a && cat /proc/cpuinfo /proc/meminfo
    displayName: System Information
  - script: sudo add-apt-repository 'ppa:ubuntu-toolchain-r/test' && sudo apt-get update && sudo apt-get install -y ninja-build ninja-build python3-pip python3-setuptools python3-wheel clang-14 clang-tools-14
    displayName: Install APT Dependencies
  - script: pip3 install -v meson==0.55.0
    displayName: Install pip Dependencies
  - script: scan-build-14 /home/vsts/.local/bin/meson setup build -Db_sanitize=address,undefined
    displayName: Configure
  - script: scan-build-14 ninja -C build -v
    displayName: Build
  - script: ninja -C build -v test
    displayName: Test
  - task: PublishTestResults@2
    inputs:
      testResultsFormat: 'JUnit'
      testResultsFiles: 'build/meson-logs/testlog.junit.xml'

- job: gcc_analysis
  timeoutInMinutes: 120
  variables:
    CC: gcc-10
    CXX: g++-10
    CFLAGS: -fanalyzer -Wextra -Werror
    CXXFLAGS: -fanalyzer -Wextra -Werror
  steps:
  - script: uname -a && cat /proc/cpuinfo /proc/meminfo
    displayName: System Information
  - script: sudo add-apt-repository 'ppa:ubuntu-toolchain-r/test' && sudo apt-get update && sudo apt-get install -y ninja-build ninja-build python3-pip python3-setuptools python3-wheel gcc-10 g++-10
    displayName: Install APT Dependencies
  - script: pip3 install meson==0.55.0
    displayName: Install pip Dependencies
  - script: /home/vsts/.local/bin/meson setup build -Db_sanitize=address,undefined
    displayName: Configure
  - script: ninja -C build -v
    displayName: Build
  - script: ninja -C build -v test
    displayName: Test
  - task: PublishTestResults@2
    inputs:
      testResultsFormat: 'JUnit'
      testResultsFiles: 'build/meson-logs/testlog.junit.xml'

# - job: loongson3a
#   container:
#     image: debian:unstable
#     options: "--name ci-container -v /usr/bin/docker:/tmp/docker:ro"
#   steps:
#   # https://github.com/Microsoft/azure-pipelines-agent/issues/2043
#   - script: /tmp/docker exec -t -u 0 ci-container sh -c "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::="--force-confold" -y install sudo"
#     displayName: 'Install Sudo in container'
#   - script: uname -a && cat /proc/cpuinfo /proc/meminfo
#     displayName: System Information
#   - script: sudo dpkg --add-architecture mips64el && sudo apt-get update && sudo apt-get install -y ninja-build ninja-build python3-pip python3-setuptools python3-wheel libc6:mips64el gcc-10-mips64el-linux-gnuabi64 g++-10-mips64el-linux-gnuabi64 qemu-user-static
#     displayName: Install APT Dependencies
#   - script: pip3 install meson=0.55.0
#     displayName: Install pip Dependencies
#   - script: /home/vsts/.local/bin/meson setup build --cross-file=docker/cross-files/loongson-gcc-10.cross
#     displayName: Configure
#   - script: ninja -C build -v
#     displayName: Build
#   - script: ninja -C build -v test
#     displayName: Test
