language: node_js
sudo: required
dist: trusty
services:
- docker
matrix:
  include:
  - node_js: 6.9.4
  - node_js: 6.9.4
    env: SAUCE=true
  - node_js: 6.9.4
    env: INTEGRATION=true
before_install:
- npm install -g npm@'>=2.13.5'
script:
- |
  echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
  echo "machine github.com login stellar-jenkins password $GITHUB_TOKEN" >~/.netrc
  git config --global user.name "Travis CI"
  git config --global user.email "travis@stellar.org"
  if [ "${SAUCE}" = "true" ]; then
    if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then
      gulp test:sauce
    else
      echo "Pull request - skip Sauce Labs testing..."
    fi
  elif [ "${INTEGRATION}" = "true" ]; then
    # Ugly but it's the only way to make istanbul generate coverage report
    babel-node ./node_modules/gulp/bin/gulp.js test:integration
  else
    gulp test:unit
  fi
after_success:
- |
  # Send report to coveralls but only once
  if [ "${INTEGRATION}" = "true" ] && [ "${TRAVIS_BRANCH}" = "master" ] ; then
    gulp submit-coverage
  fi
env:
  global:
  - secure: Pc3DwkXywnOGAhUdBZiUCKjyljzrQzPoqm9EEr+UL2BaeaDniFLCLEkuU+ViiuJBo8oPyOIl7I+d86Mi5q06fQx55+xH7DmiW/aj4qKVB2U6Ghn6A3QWkQuvRB1o8SP7iTYRCX480ULZs6AGrMd9y1PFRx/L93fBrO+J/bOtEmg=
  - CXX=g++-4.8
addons:
  apt:
    sources:
    - ubuntu-toolchain-r-test
    packages:
    - gcc-4.8
    - g++-4.8
notifications:
  slack:
    secure: CgXxNEQrQ82EatyF/wSdF0P5rXcWPL+fFZ1lb1aBb8RbVt5gwddJ6xWVD/nYSr6tIJvIYHYhoYsIDPENwezIPsesG7kWXerQhydsEcA34JKxzsStd/TmU6Moxuwy6KTN7yzmL6586nSvoAw9TNPgvRkJFkH07asjGIc9Rlaq7/Y=
before_deploy: gulp build
after_deploy: "./after_deploy.sh"
deploy:
  - provider: npm
    email: npm@stellar.org
    api_key: "$NPM_TOKEN"
    skip_cleanup: true
    on:
      tags: true
      repo: stellar/js-stellar-sdk
      node: 6.9.4
      condition: "$INTEGRATION = true"
  - provider: script
    script: "./bower_publish.sh"
    skip_cleanup: true
    on:
      tags: true
      repo: stellar/js-stellar-sdk
      node: 6.9.4
      condition: "$INTEGRATION = true"
