language: cpp

sudo: false

git:
  depth: 10

# don't re-build for tags so that [publish binary] is not re-run
# https://github.com/travis-ci/travis-ci/issues/1532
branches:
  except:
    - /^v[0-9]/

env:
  global:
   - JOBS: "8"
   - secure: F42vcZEgWgCMDvQXlmyYmWwFo86fUjlJbsvXEwyliaMfasjCNsbmeILU61aScn8daiCGD+vRUaRlmv+XxUSS2G8FaoI8ZjwgMo2guMwthAQJ1ohTvf4bZI0JqVYKnnZpzhGPv2zD0DTdt31l30qn2GZnnGrF4yFpPU1HW2HcMuE=
   - secure: WRWrn3KjCaevRo2htdvn26euALTZNCDtcSlQvtH6Bc7yLdhlH5apj+qSuWqlN59f1cprFH+5aQ2zmBkVmAV2DT4IbsfszMIR6k6EetuY6VOugo/qsPW2x/MQbpFgjCbl95bYty4eUH9Bcf70Pz/S+XVewABXHWikJiLUiZBbLyE=

addons:
  apt:
    sources:
     - ubuntu-toolchain-r-test
     - llvm-toolchain-precise-3.5
    packages:
     - clang-3.5

matrix:
  include:
     # Coverage
     - os: osx
       osx_image: xcode7
       compiler: clang
       env: NODE_VERSION="4" COVERAGE=true NPM_FLAGS="--debug" PUBLISHABLE=false # node abi 46
     # Linux
     - os: linux
       compiler: clang
       env: NODE_VERSION="5" PUBLISHABLE=true # node abi 47
     - os: linux
       compiler: clang
       env: NODE_VERSION="4" PUBLISHABLE=true # node abi 46
     - os: linux
       compiler: clang
       env: NODE_VERSION="0.10" NPM_FLAGS="--debug" PUBLISHABLE=true # node abi 11
     - os: linux
       compiler: clang
       env: NODE_VERSION="0.10" PUBLISHABLE=true # node abi 11
     # OS X
     - os: osx
       osx_image: xcode7
       compiler: clang
       env: NODE_VERSION="5" PUBLISHABLE=true # node abi 47
     - os: osx
       osx_image: xcode7
       compiler: clang
       env: NODE_VERSION="4" PUBLISHABLE=true # node abi 46
     - os: osx
       osx_image: xcode7
       compiler: clang
       env: NODE_VERSION="0.10" NPM_FLAGS="--debug" PUBLISHABLE=true # node abi 11
     - os: osx
       osx_image: xcode7
       compiler: clang
       env: NODE_VERSION="0.10" PUBLISHABLE=true # node abi 11

before_install:
 - scripts/validate_tag.sh
 - export COVERAGE=${COVERAGE:-false}
 - if [[ $(uname -s) == 'Linux' ]]; then
     export CXX="clang++-3.5";
     export CC="clang-3.5";
     export PYTHONPATH=$(pwd)/mason_packages/.link/lib/python2.7/site-packages;
   else
     export PYTHONPATH=$(pwd)/mason_packages/.link/lib/python/site-packages;
   fi;
 - source ./scripts/install_node.sh ${NODE_VERSION}
 - export PATH=./node_modules/.bin/:$PATH

install:
 - COMMIT_MESSAGE=$(git log --format=%B --no-merges -n 1 | tr -d '\n')
 - echo ${COMMIT_MESSAGE}
 - if [[ ${COVERAGE} == true ]]; then
     if [[ $(uname -s) == 'Linux' ]]; then
       PYTHONUSERBASE=$(pwd)/mason_packages/.link pip install --user cpp-coveralls;
     else
       PYTHONUSERBASE=$(pwd)/mason_packages/.link easy_install --user cpp-coveralls;
     fi;
     ./scripts/build_against_sdk.sh ${NPM_FLAGS};
   else
     ./scripts/build_against_sdk.sh ${NPM_FLAGS};
   fi
 - node-pre-gyp package testpackage ${NPM_FLAGS}
 - npm test

before_script:
- if [[ ${PUBLISHABLE} == true ]]; then
    ./scripts/publish.sh;
  fi;

script:
 - if [[ ${COVERAGE} == true ]]; then ./mason_packages/.link/bin/cpp-coveralls --exclude __nvm --exclude node_modules --exclude tests --build-root build --gcov-options '\-lp' --exclude tools --exclude docs --exclude sdk --exclude build/Debug/obj/gen --exclude build/Release/obj/gen --exclude src/mapnik_featureset.hpp --exclude src/mapnik_logger.hpp --exclude src/mapnik_image_view.hpp --exclude src/mapnik_geometry.hpp --exclude deps > /dev/null; fi;
 #- node --expose-gc bench/error/test_vt_abort2.js
 # ugh: always killed by travis
 #- nice -n 19 node --expose-gc bench/error/test_vt_abort.js

notifications:
  slack:
    secure: wLpScQaDoEsVe0Bu28b62FGZBfmX3s/NK8DWcuSxEFx80k8RKPNgnMg8htamG0zRSf5htF+X6jy2P0IeUvbeupIaJwqtXvHaJYtlMTmemG/xuXLTpLp6k6giT2mWm/lp+ykuaF/PvUcZWUhSf1zhS6vwIekrMYIcDYvNXjO8DNw=
