version: v1.0
name: Build
agent:
  machine:
    type: e1-standard-2
    os_image: ubuntu2004
blocks:
  - name: CI
    skip:
      when: "branch = 'master' OR (branch !~ '^ci/semaphore(/.*)?' AND branch =~ '^ci/.+')"
    task:
      jobs:
        - name: GCC
          matrix:
            - env_var: GCC_VERSION
              values: ['8', '7']
          commands:
            - cat /proc/cpuinfo
            - checkout
            - git submodule update --init
            - sudo apt-get update
            - sudo apt-get install -y ninja-build python3-pip python3-setuptools gcovr gcc-${GCC_VERSION} g++-${GCC_VERSION}
            - pip3 install meson==0.55.0
            - mkdir build
            - CC="gcc-${GCC_VERSION}" CXX="g++-${GCC_VERSION}" ~/.local/bin/meson setup build -Db_coverage=true --optimization $(expr $RANDOM % 3)
            - ~/.local/bin/meson compile -C build --ninja-args=-v
            - ~/.local/bin/meson test -C build --print-errorlogs $(~/.local/bin/meson test -C build --list | grep -v emul)
            - ninja -C build coverage-xml
          env_vars:
            - name: CFLAGS
              value: -Wextra -Werror -march=native
            - name: CXXFLAGS
              value: -Wextra -Werror -march=native

        - name: clang
          matrix:
            - env_var: CLANG_VERSION
              values: ['10', '8', '6.0']
          commands:
            - cat /proc/cpuinfo
            - checkout
            - git submodule update --init
            - sudo apt-get update
            - sudo apt-get install -y ninja-build python3-pip python3-setuptools gcovr clang-${CLANG_VERSION}
            - pip3 install meson==0.55.0
            - mkdir build
            - CC="clang-${CLANG_VERSION}" CXX="clang++-${CLANG_VERSION}" ~/.local/bin/meson setup build -Db_coverage=true
            - ~/.local/bin/meson compile -C build --ninja-args=-v
            - ~/.local/bin/meson test -C build --print-errorlogs $(~/.local/bin/meson test -C build --list | grep -v emul)
            - ninja -C build coverage-xml
          env_vars:
            - name: CFLAGS
              value: -Weverything -Werror -march=native
            - name: CXXFLAGS
              value: -Weverything -Werror -march=native
