# Use a C++11 distro
dist: trusty
sudo: required

# Enable C++ support
language: cpp

# Compiler selection
compiler: gcc

env:
  global:
    # coverity key
    - secure: "NKZbBnMALGIIQJy/s2kc3EST/stw+gjhtrGq0jkbsWr7Wx3FH+lmLeHNsDXRnD1VbpG02c5YsLllqz9OVu+0yxWGepvKNmCz1cNITIALEHbrax8/Af9LzPRL/QZxS/Qe11sMuySp4X16mFBUyxMd/X+I9i96Xf1vKkZABklYD1Q="

# addons
addons:
  apt:
    packages:
      - gcc-6
      - g++-6
    sources:
      - ubuntu-toolchain-r-test

  coverity_scan:
    project:
      name: "mpaland/printf"
      description: "Tiny printf implementation"
    notification_email: marco@paland.com
    build_command_prepend: "make clean"
    build_command: "make"
    branch_pattern: master

before_install:
  # install coveralls
  - pip install --user cpp-coveralls
  # connect coverity
  - echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-

# Active branches
branches:
  only:
   - master

script:
  # Link gcc-6 and g++-6 to their standard commands
  - sudo rm /usr/bin/gcc
  - sudo rm /usr/bin/g++
  - sudo ln -s /usr/bin/gcc-6 /usr/bin/gcc
  - sudo ln -s /usr/bin/g++-6 /usr/bin/g++
  # Export CC and CXX
  - export CC=/usr/bin/gcc-6
  - export CXX=/usr/bin/g++-6
  # Check versions of gcc, g++
  - gcc -v && g++ -v
  # Run build commands
  - make
  # execute the text suite
  - bin/test_suite -d yes
  # coverall profiling
  - tmp/cov/test_suite

after_success:
  # Report to coveralls
  - coveralls --build-root ${TRAVIS_BUILD_DIR} --include printf.cpp --gcov 'gcov-6' --gcov-options '\-lp'
