os: linux
dist: trusty
sudo: false

language: cpp

addons:
  apt:
    packages: &common_packages
      - ninja-build
      - liblzma-dev
      - libz-dev
    sources: &common_sources
      - ubuntu-toolchain-r-test

env:
  global: CLANG_VERSION=7 GCC_VERSION=7

matrix:
  include:
    - env: BUILD_TYPE=Release CC_COMPILER=clang-${CLANG_VERSION} CXX_COMPILER=clang++-${CLANG_VERSION}
      addons: &clang
        apt:
          packages:
            - *common_packages
            - clang-7
          sources:
            - *common_sources
            - sourceline: 'deb http://apt.llvm.org/jessie/ llvm-toolchain-jessie main'
              key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'

    - env: BUILD_TYPE=Debug CC_COMPILER=clang-${CLANG_VERSION} CXX_COMPILER=clang++-${CLANG_VERSION}
      addons: *clang

    - env: BUILD_TYPE=Release CC_COMPILER=gcc-${GCC_VERSION} CXX_COMPILER=g++-${GCC_VERSION}
      addons: &gcc
        apt:
          packages:
            - *common_packages
            - g++-7
            - gcc-7
          sources:
            - *common_sources

install:
  - mkdir -p deps && cd deps
  - travis_retry wget --no-check-certificate --quiet -O - https://cmake.org/files/v3.7/cmake-3.7.1-Linux-x86_64.tar.gz | tar --strip-components=1 -xz
  - export PATH=${TRAVIS_BUILD_DIR}/deps/bin:${PATH}
  - cd -

before_script:
  - travis_retry wget --quiet -O - https://raw.githubusercontent.com/cpplint/cpplint/master/cpplint.py | python - --recursive src examples
  - mkdir -p build && cd build
  - rm -rf *
  - cmake .. -GNinja -DLIB_PROTO_MUTATOR_WITH_ASAN=ON -DLIB_PROTO_MUTATOR_DOWNLOAD_PROTOBUF=ON -DCMAKE_C_COMPILER=${CC_COMPILER} -DCMAKE_CXX_COMPILER=${CXX_COMPILER} -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DLIB_PROTO_MUTATOR_CTEST_JOBS=8

script:
  - export ASAN_OPTIONS=detect_leaks=0
  - ninja
  - ninja check
