Skip to content

Commit

Permalink
Add some friendlier printing to the travis log for clang-format failures
Browse files Browse the repository at this point in the history
  • Loading branch information
baldurk committed Jan 4, 2017
1 parent 168b742 commit 116903a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Expand Up @@ -36,8 +36,6 @@ install:
- if [[ "$DOCS_BUILD" == "1" ]]; then . ./scripts/travis/docs_setup.sh ; fi - if [[ "$DOCS_BUILD" == "1" ]]; then . ./scripts/travis/docs_setup.sh ; fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]] && [[ "$CODE_BUILD" == "1" ]]; then . ./scripts/travis/linux_setup.sh ; fi - if [[ "$TRAVIS_OS_NAME" == "linux" ]] && [[ "$CODE_BUILD" == "1" ]]; then . ./scripts/travis/linux_setup.sh ; fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]] && [[ "$CODE_BUILD" == "1" ]]; then . ./scripts/travis/osx_setup.sh ; fi - if [[ "$TRAVIS_OS_NAME" == "osx" ]] && [[ "$CODE_BUILD" == "1" ]]; then . ./scripts/travis/osx_setup.sh ; fi
- git clean -f
- git diff --exit-code


script: script:
- if [[ "$DOCS_BUILD" == "1" ]]; then . ./scripts/travis/docs_compile.sh ; fi - if [[ "$DOCS_BUILD" == "1" ]]; then . ./scripts/travis/docs_compile.sh ; fi
Expand Down
21 changes: 21 additions & 0 deletions scripts/travis/linux_setup.sh
Expand Up @@ -8,4 +8,25 @@ wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-get update -qq sudo apt-get update -qq
sudo apt-get install --allow-unauthenticated -y -qq libx11-dev mesa-common-dev libgl1-mesa-dev qt56base qt56x11extras libxcb-keysyms1-dev gdb clang-format-3.8 sudo apt-get install --allow-unauthenticated -y -qq libx11-dev mesa-common-dev libgl1-mesa-dev qt56base qt56x11extras libxcb-keysyms1-dev gdb clang-format-3.8


# check formatting matches clang-format-3.8. Since newer versions can have
# changes in formatting even without any rule changes, we have to fix on a
# single version.

clang-format-3.8 -i -style=file $(find pdblocate/ qrenderdoc/ renderdoc/ renderdoccmd/ renderdocshim/ -type f -regex '.*\(/3rdparty/\|/official/\|resource.h\).*' -prune -o -regex '.*\.\(c\|cpp\|h\)$' -print) clang-format-3.8 -i -style=file $(find pdblocate/ qrenderdoc/ renderdoc/ renderdoccmd/ renderdocshim/ -type f -regex '.*\(/3rdparty/\|/official/\|resource.h\).*' -prune -o -regex '.*\.\(c\|cpp\|h\)$' -print)

git clean -f

# this swallows the exit code so we won't fail until we print the diff in
# the next line, but allows us to print a friendlier message to anyone
# looking at the build log
git diff --quiet || (
echo "***************************************************";
echo "*** The code is not clean against clang-format ***";
echo "*** Please run clang-format-3.8 and fix the ***";
echo "*** differences then rebase/squash them into ***";
echo "*** the relevant commits. Do not add a commit ***";
echo "*** for just formatting fixes. Thanks! ***";
echo "***************************************************";
)

git diff --exit-code

0 comments on commit 116903a

Please sign in to comment.