#
# Derived from
# https://github.com/steveno/ctags/blob/master/.travis.yml
#

dist: xenial

language: c

os:
  - linux
  - osx

compiler:
  - gcc
  - clang

env:
  global:
    # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created
    #   via the "travis encrypt" command using the project repo's public key
    - secure: "FZunj1O8PR/2DEEN1tUAFzSxeo3jf2oOLkP7SmOSdeZ8W8QPo/5Nfhlhl0uambYOXOre/p/mCNXjudtsTwKHtq4uP6fejjPJl5cmHBCm/KtIoLnUaDyaSjoq6tKi2duJJhwY9H6X5ILtDxWveRbs5NhmKo9H+c1vHsBg0Wbuslg="

  addons:
    coverity_scan:
      project:
        name: "fishman/ctags"
      description: "Build submitted via Travis CI"
    notification_email: coverityctags@gmail.com
    build_command_prepend: "./autogen.sh ; ./configure ; make clean"
    build_command:   "make -j 4 CFLAGS=-O0"
    branch_pattern: master

addons:
  apt:
    packages:
      - lcov
      - binutils-mingw-w64-i686
      - gcc-mingw-w64-i686
      - libjansson-dev
      - libyaml-dev
      - libseccomp-dev
      - gdb

env:
  - TARGET=Unix
  - TARGET=Mingw32

# Only with gcc get the mingw-w64 cross compilers
before_install:
  - |
    if [ $CC = 'gcc' ] && [ $TRAVIS_OS_NAME = 'linux' ]; then
    	gem install lcoveralls
    fi

# Build and run tests. Only with gcc cross compile
script:
  - ./misc/travis-check.sh

after_success:
  - |
    if [ $CC = 'gcc' ] && [ $TRAVIS_OS_NAME = 'linux' ]; then
        (
            for f in /home/travis/.rvm/gems/ruby-2*/gems/lcoveralls-*/lib/lcoveralls/color_formatter.rb; do
                    sed -i -e 's/severity.capitalize!/severity = severity.capitalize/' $f
            done
        )

        (cd linux-gcc-gcov; lcov -c -b .. -d . -o coverage.info)

        # Upload to coveralls.
        lcoveralls --root . --retry-count 5 linux-gcc-gcov/coverage.info

        # Upload to codecov.
        bash <(curl -s https://codecov.io/bash) -f linux-gcc-gcov/coverage.info -Z -X gcov -X coveragepy -X search -X xcode -X gcovout -n travis-$TRAVIS_OS_NAME
    fi

# Build Matrix configuration
# By default Travis CI runs all possible environment/target combinations.
# This setting allows the exclusion of undesired combination.
# For more information:
# http://docs.travis-ci.com/user/customizing-the-build/#Build-Matrix
matrix:
  exclude:
    - compiler: clang
      env: TARGET=Mingw32
    - os: osx
      env: TARGET=Mingw32
