diff options
| -rwxr-xr-x | .travis-build.sh | 44 | ||||
| -rw-r--r-- | .travis.yml | 2 |
2 files changed, 31 insertions, 15 deletions
diff --git a/.travis-build.sh b/.travis-build.sh index 407ea3e55..b8562cb02 100755 --- a/.travis-build.sh +++ b/.travis-build.sh | |||
| @@ -9,23 +9,37 @@ if grep -nr '\s$' src *.yml *.txt *.md Doxyfile .gitignore .gitmodules .travis* | |||
| 9 | exit 1 | 9 | exit 1 |
| 10 | fi | 10 | fi |
| 11 | 11 | ||
| 12 | for f in $(git diff --name-only --diff-filter=ACMRTUXB --cached); do | 12 | # Only run clang-format on Linux because we don't have 4.0 on OS X images |
| 13 | if ! echo "$f" | egrep -q "[.](cpp|h)$"; then | 13 | if [ "$TRAVIS_OS_NAME" = "linux" ]; then |
| 14 | continue | 14 | # Default clang-format points to default 3.5 version one |
| 15 | fi | 15 | CLANG_FORMAT=clang-format-4.0 |
| 16 | if ! echo "$f" | egrep -q "^src/"; then | 16 | $CLANG_FORMAT --version |
| 17 | continue | 17 | |
| 18 | fi | 18 | if [ "$TRAVIS_EVENT_TYPE" = "pull_request" ]; then |
| 19 | d=$(diff -u "$f" <(clang-format "$f")) | 19 | # Get list of every file modified in this pull request |
| 20 | if ! [ -z "$d" ]; then | 20 | files_to_lint="$(git diff --name-only --diff-filter=ACMRTUXB $TRAVIS_COMMIT_RANGE | grep '^src/[^.]*[.]\(cpp\|h\)$')" |
| 21 | echo "!!! $f not compliant to coding style, here is the fix:" | 21 | else |
| 22 | echo "$d" | 22 | # Check everything for branch pushes |
| 23 | fail=1 | 23 | files_to_lint="$(find src/ -name '*.cpp' -or -name '*.h')" |
| 24 | fi | 24 | fi |
| 25 | done | ||
| 26 | 25 | ||
| 27 | if [ "$fail" = 1 ]; then | 26 | # Turn off tracing for this because it's too verbose |
| 28 | exit 1 | 27 | set +x |
| 28 | |||
| 29 | for f in $files_to_lint; do | ||
| 30 | d=$(diff -u "$f" <($CLANG_FORMAT "$f")) | ||
| 31 | if ! [ -z "$d" ]; then | ||
| 32 | echo "!!! $f not compliant to coding style, here is the fix:" | ||
| 33 | echo "$d" | ||
| 34 | fail=1 | ||
| 35 | fi | ||
| 36 | done | ||
| 37 | |||
| 38 | set -x | ||
| 39 | |||
| 40 | if [ "$fail" = 1 ]; then | ||
| 41 | exit 1 | ||
| 42 | fi | ||
| 29 | fi | 43 | fi |
| 30 | 44 | ||
| 31 | #if OS is linux or is not set | 45 | #if OS is linux or is not set |
diff --git a/.travis.yml b/.travis.yml index 69f9ef273..ea99be2c4 100644 --- a/.travis.yml +++ b/.travis.yml | |||
| @@ -17,6 +17,7 @@ addons: | |||
| 17 | apt: | 17 | apt: |
| 18 | sources: | 18 | sources: |
| 19 | - ubuntu-toolchain-r-test | 19 | - ubuntu-toolchain-r-test |
| 20 | - llvm-toolchain-precise | ||
| 20 | packages: | 21 | packages: |
| 21 | - gcc-6 | 22 | - gcc-6 |
| 22 | - g++-6 | 23 | - g++-6 |
| @@ -25,6 +26,7 @@ addons: | |||
| 25 | - xorg-dev | 26 | - xorg-dev |
| 26 | - lib32stdc++6 # For CMake | 27 | - lib32stdc++6 # For CMake |
| 27 | - lftp # To upload builds | 28 | - lftp # To upload builds |
| 29 | - clang-format-4.0 | ||
| 28 | 30 | ||
| 29 | cache: | 31 | cache: |
| 30 | directories: | 32 | directories: |