Skip to content

Enable clang format in CI #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
BasedOnStyle: Chromium
ColumnLimit: 120
IndentWidth: 4
DerivePointerAlignment: false
IndentCaseLabels: false
PointerAlignment: Right
SpaceAfterCStyleCast: true
13 changes: 12 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,15 @@ script:
matrix:
include:
- os: linux
env: CUSTOM_JDK="oraclejdk8"
env: CUSTOM_JDK="oraclejdk8"

# This is the job to check code format.
- os: linux
dist: trusty
env: LINT=1 PYTHON=2.7
before_install:
- sudo apt-get update -qq
- sudo apt-get install -qq clang-format-3.8
install: []
script:
- sudo sh .travis/check-git-clang-format.sh
18 changes: 18 additions & 0 deletions .travis/check-git-clang-format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

if [ "$TRAVIS_PULL_REQUEST" == "true" ] ; then
base_commit="$TRAVIS_BRANCH"
else
base_commit="HEAD^"
fi

output="$(sudo python .travis/git-clang-format --binary clang-format-3.8 --commit $base_commit --diff)"

if [ "$output" == "no modified files to format" ] || [ "$output" == "clang-format did not modify any files" ] ; then
echo "clang-format passed."
exit 0
else
echo "clang-format failed."
echo "$output"
exit 1
fi
Loading