Skip to content
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

Add formatting checks to Travis-CI #17

Merged
merged 2 commits into from
Jan 24, 2017
Merged
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
25 changes: 25 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ env:
- BORINGSSL_HOME="$HOME/boringssl"
- CC=clang
- CXX=clang++
- GOOGLE_JAVA_FORMAT_VERSION=1.1

cache:
directories:
Expand Down Expand Up @@ -36,9 +37,11 @@ matrix:
apt:
sources:
- kalakris-cmake
- llvm-toolchain-precise-3.8 # for clang-format-3.8
- ubuntu-toolchain-r-test
packages:
- clang
- clang-format-3.8 # for style checks
- cmake
- g++-multilib
- gcc-multilib
Expand All @@ -61,6 +64,9 @@ before_cache:
- rm -rf $HOME/.gradle/caches/[1-9]*

before_script:
# Get Google Java Format
- curl -L https://github.com/google/google-java-format/releases/download/google-java-format-1.1/google-java-format-${GOOGLE_JAVA_FORMAT_VERSION}-all-deps.jar -o $HOME/gjf.jar

# get BoringSSL
- mkdir $BORINGSSL_HOME
- git clone --depth 1 https://boringssl.googlesource.com/boringssl $BORINGSSL_HOME
Expand All @@ -71,6 +77,15 @@ before_script:
- ninja
- popd

# Get git-clang-format
- mkdir $HOME/bin
- curl -L https://llvm.org/svn/llvm-project/cfe/trunk/tools/clang-format/git-clang-format -o $HOME/bin/git-clang-format
- chmod 0755 $HOME/bin/git-clang-format
- export PATH="$HOME/bin:$PATH"

# We need this to find the merge-base
- git fetch origin +refs/heads/master:refs/remotes/origin/master

# TODO(nathanmittler): Need to figure out how to make 32-bit builds work
# Build BoringSSL for 32-bit
# - if [[ "$TRAVIS_OS_NAME" == "linux" ]];
Expand All @@ -95,6 +110,16 @@ before_script:
- echo 'android.builder.sdkDownload=false' > gradle.properties

script:
# MacOS (BSD) xargs is missing some nice features that make this easy, so skip it.
- if [[ "$TRAVIS_OS_NAME" == "linux" ]];
then
git rev-list $(git merge-base HEAD origin/master)..HEAD | xargs -i git clang-format --binary=$(which clang-format-3.8) --style=file {} && git diff --exit-code || { git reset --hard; false; }
fi
- if [[ "$TRAVIS_OS_NAME" == "linux" ]];
then
git rev-list $(git merge-base HEAD origin/master)..HEAD | xargs -i git diff-tree --no-commit-id --name-only -r {} | grep -E '\.java$' | xargs -r git ls-files | xargs -r java -jar $HOME/gjf.jar -a -i --fix-imports-only && git diff --exit-code || { git reset --hard; false; }
fi

- ./gradlew --stacktrace --info build

after_script:
Expand Down