Skip to content

Commit

Permalink
Add clang-format to CI.
Browse files Browse the repository at this point in the history
  • Loading branch information
jovany-wang committed Sep 2, 2018
1 parent 2bc32e8 commit c331d97
Show file tree
Hide file tree
Showing 4 changed files with 542 additions and 9 deletions.
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: 160
IndentWidth: 4
DerivePointerAlignment: false
IndentCaseLabels: false
PointerAlignment: Right
SpaceAfterCStyleCast: true
36 changes: 27 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
sudo: required

language: cpp
compiler: g++
before_install:
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- sudo apt-get update -qq
install:
- sudo apt-get install -qq g++-4.8
- export CXX="g++-4.8"
script: make && sudo ./handy_test
notifications:
email: true

matrix:
include:
# Job1: This is the job of building project in linux os.
- os: linux
dist: trusty
before_install:
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- sudo apt-get update -qq
install:
- sudo apt-get install -qq g++-4.8
- export CXX="g++-4.8"
script: make && sudo ./handy_test
notifications:
email: true

# Job2: This is the job of checking code style.
- 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 bash .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

0 comments on commit c331d97

Please sign in to comment.