Skip to content

Commit

Permalink
Merge pull request yedf2#45 from jovan-wong/clang_format_2
Browse files Browse the repository at this point in the history
Format code by clang-format tool and enable in CI.
  • Loading branch information
yedf2 authored Sep 2, 2018
2 parents 2bc32e8 + 93608ff commit 530ee48
Show file tree
Hide file tree
Showing 70 changed files with 2,488 additions and 1,763 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 530ee48

Please sign in to comment.