Skip to content

Commit 1745812

Browse files
authored
Add travis config (#17)
1 parent dadab6a commit 1745812

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed

.travis.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
sudo: required
2+
3+
dist: trusty
4+
5+
addons:
6+
apt:
7+
sources:
8+
- ubuntu-toolchain-r-test
9+
packages:
10+
- gcc-4.9
11+
- g++-4.9
12+
- realpath
13+
- wget
14+
15+
language: cpp
16+
17+
jdk:
18+
- oraclejdk8
19+
20+
env:
21+
- BAZEL_VERSION=0.5.2
22+
23+
cache:
24+
directories:
25+
- $HOME/bazel/install
26+
- $HOME/bazel/outbase
27+
- $HOME/clang
28+
29+
before_install:
30+
- mkdir -p ${HOME}/bazel/install
31+
- cd ${HOME}/bazel/install
32+
- wget --no-clobber "https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-installer-linux-x86_64.sh"
33+
- chmod +x bazel-${BAZEL_VERSION}-installer-linux-x86_64.sh
34+
- sudo ./bazel-${BAZEL_VERSION}-installer-linux-x86_64.sh
35+
- cd ${TRAVIS_BUILD_DIR}
36+
37+
script:
38+
- script/check-style
39+
- CC=/usr/bin/gcc-4.9 CXX=/usr/bin/g++-4.9 bazel --output_base=${HOME}/bazel/outbase test //...

script/check-style

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
#
3+
# Copyright 2016 Istio Authors. All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
#
17+
################################################################################
18+
#
19+
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
20+
21+
# Install required clang version to a folder and cache it.
22+
CLANG_VERSION_REQUIRED="3.8.0"
23+
CLANG_DIRECTORY="${HOME}/clang"
24+
CLANG_FORMAT="${CLANG_DIRECTORY}/bin/clang-format"
25+
26+
CLANG_VERSION="$(${CLANG_FORMAT} -version | cut -d ' ' -f 3)"
27+
if [[ "${CLANG_VERSION}" != "${CLANG_VERSION_REQUIRED}" ]]; then
28+
echo "Installing required clang-format ${CLANG_VERSION_REQUIRED} to ${CLANG_DIRECTORY}"
29+
mkdir -p ${CLANG_DIRECTORY}
30+
curl --silent --show-error --retry 10 \
31+
"http://releases.llvm.org/${CLANG_VERSION_REQUIRED}/clang+llvm-${CLANG_VERSION_REQUIRED}-x86_64-linux-gnu-ubuntu-14.04.tar.xz" \
32+
| tar Jx -C "${CLANG_DIRECTORY}" --strip=1 \
33+
|| { echo "Could not install required clang-format. Skip formating." ; exit 0 ; }
34+
fi
35+
36+
echo "Checking file format ..."
37+
38+
pushd ${ROOT} > /dev/null
39+
40+
SOURCE_FILES=($(git ls-tree -r HEAD --name-only | grep -E '\.(h|c|cc|proto)$'))
41+
"${CLANG_FORMAT}" -style=Google -i "${SOURCE_FILES[@]}" \
42+
|| { echo "Could not run clang-format." ; exit 1 ; }
43+
44+
CHANGED_FILES=($(git diff HEAD --name-only | grep -E '\.(h|c|cc|proto)$'))
45+
46+
if [[ "${#CHANGED_FILES}" -ne 0 ]]; then
47+
echo "Files not formatted: ${CHANGED_FILES[@]}"
48+
exit 1
49+
fi
50+
echo "All files are properly formatted."
51+
52+
popd

0 commit comments

Comments
 (0)