Skip to content
Snippets Groups Projects
.travis.yml 1.24 KiB
Newer Older
sudo: false

language: cpp

addons: &addons
  apt:
    packages: timeout
    sources: &sources
      - llvm-toolchain-precise-3.9

cache:
  apt: true
  ccache: true

# Do not build our sync branch.
branches:
  only:
    - master

matrix:
  # Abort all builds on a single failing matrix entry.
  fast_finish: true

  include:
    # There seems to be a hard limit to how many machines a Travis build will
    # across all platforms. By interleaving OS X, the hope is to get in the
    # queue faster while not blocking Linux builds from occuring.
    - os: linux
      addons:
        apt:
          sources: *sources
          packages: ['clang-3.9', 'clang-format-3.9']
      compiler: clang

script:
- |
  if [ "$TRAVIS_PULL_REQUEST" == "true" ]; then
    BASE_COMMIT="$TRAVIS_BRANCH"
    echo "Running clang-format against branch $BASE_COMMIT, with hash $(git rev-parse $BASE_COMMIT)"
    RESULT_OUTPUT="$(git-clang-format --commit $BASE_COMMIT --diff --exclude ^interpreter/)"
    
    if [ "$RESULT_OUTPUT" == "no modified files to format" ] \
      || [ "$RESULT_OUTPUT" == "clang-format did not modify any files" ] ; then

      echo "clang-format passed."
      exit 0
    else
      echo "clang-format failed:"
      echo "$RESULT_OUTPUT"
      exit 1
    fi
  fi