# Enable C++ support
language: cpp

matrix:
  include:
    - os: linux
      dist: trusty
      sudo: required
      compiler: gcc
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-7
      env:
        - MATRIX_EVAL="CC=gcc-7 && CXX=g++-7"

    - os: linux
      dist: trusty
      sudo: required
      compiler: clang
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
            - llvm-toolchain-trusty-6.0
            - sourceline: 'ppa:ubuntu-toolchain-r/test'
          packages:
            - g++-7
            - llvm-6.0
            - clang-6.0
            - libstdc++6
      env:
        - MATRIX_EVAL="CC=clang-6.0 && CXX=clang++-6.0"

    - os: osx
      osx_image: xcode9.4
      compiler: clang

before_install: |
  if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
    export CH_SERVER_VERSION="21.3.17.2"
    sudo apt-get install apt-transport-https ca-certificates dirmngr
    sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv E0C56BD4
    echo "deb https://repo.clickhouse.com/deb/stable/ main/" | sudo tee /etc/apt/sources.list.d/clickhouse.list
    sudo apt-get update
    sudo apt-get install -y \
        clickhouse-server=${CH_SERVER_VERSION} \
        clickhouse-client=${CH_SERVER_VERSION} \
        clickhouse-common-static=${CH_SERVER_VERSION}
    sudo service clickhouse-server start
  fi

# Build steps
script: |
  eval "${MATRIX_EVAL}"
  mkdir build
  cd build
  cmake .. -DBUILD_TESTS=ON && make
  if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then ./ut/clickhouse-cpp-ut ; fi
  if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then ./ut/clickhouse-cpp-ut --gtest_filter=-"Client/*:*Performance*" ; fi
