Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

Commit 5fc3560

Browse files
authored
Travis: add gcc and CMake. (#255)
* Move scripts from .travis.yaml to tools/travis/*.sh. * Run format.sh first, and separately from build tests. * Run cmake_format on Travis. * Build and test with bazel + gcc (previously only clang). * Build and test with CMake.
1 parent 9bbda4b commit 5fc3560

File tree

4 files changed

+110
-32
lines changed

4 files changed

+110
-32
lines changed

.travis.yml

Lines changed: 21 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,35 @@
11
language: cpp
2+
compiler: clang
3+
24
matrix:
35
include:
46
- os: linux
57
dist: trusty
68
sudo: false
9+
name: "check format"
10+
script: tools/travis/check_format.sh
11+
- os: linux
12+
dist: trusty
13+
sudo: false
14+
env: BAZEL_OS=linux
15+
script: tools/travis/build_bazel.sh
16+
- os: linux
17+
dist: trusty
18+
sudo: false
19+
compiler: gcc
720
env: BAZEL_OS=linux
21+
script: tools/travis/build_bazel.sh
22+
- os: linux
23+
dist: trusty
24+
sudo: false
25+
env: CMAKE_OS=linux
26+
script: tools/travis/build_cmake.sh
827
- os: osx
928
env: BAZEL_OS=darwin
10-
11-
compiler: clang
12-
13-
# - Limit memory.
14-
# - Enable thread safety analysis (only works with clang).
15-
env: BAZEL_OPTIONS="--local_resources=4096,2,1.0 --copt=-Werror=thread-safety"
29+
script: tools/travis/build_bazel.sh
1630

1731
cache:
1832
directories:
33+
- $HOME/.ccache
1934
- $HOME/bazel-cache
2035
- $HOME/gopath/bin
21-
22-
before_install:
23-
# Install buildifier if it's not present. It needs at least go 1.8.
24-
# Skip format on OS X: it doesn't have clang-format by default, and has a different sed.
25-
- if \[ "$TRAVIS_OS_NAME" == "linux" \]; then
26-
if ! which buildifier >/dev/null; then
27-
eval "$(gimme 1.11)";
28-
go get -v github.com/bazelbuild/buildtools/buildifier;
29-
fi;
30-
tools/format.sh;
31-
fi
32-
- wget https://github.com/bazelbuild/bazel/releases/download/0.20.0/bazel-0.20.0-installer-${BAZEL_OS}-x86_64.sh
33-
- chmod +x bazel-0.20.0-installer-${BAZEL_OS}-x86_64.sh
34-
- ./bazel-0.20.0-installer-${BAZEL_OS}-x86_64.sh --user
35-
- echo "build --disk_cache=$HOME/bazel-cache" > ~/.bazelrc
36-
- echo "build --experimental_strict_action_env" >> ~/.bazelrc
37-
38-
script:
39-
# Limit the amount of progress output. We can't use --noshow_progress because
40-
# Travis terminates the build after 10 mins without output.
41-
- bazel build $BAZEL_OPTIONS --experimental_ui_actions_shown=1 -k $(bazel query "kind(rule, //...)" | grep -v :_)
42-
- bazel test $BAZEL_OPTIONS --experimental_ui_actions_shown=1 -k $(bazel query "kind(test, //...) except attr('tags', 'manual|noci', //...)" | grep -v :_)
43-
44-
before_cache:
45-
# Before uploading cache, report its size.
46-
- du -sk $HOME/bazel-cache

tools/travis/build_bazel.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2018, OpenCensus Authors
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
set -e
16+
set -x
17+
18+
# Limit memory.
19+
export BAZEL_OPTIONS="--local_resources=4096,2,1.0"
20+
21+
# Limit the amount of progress output. We can't use --noshow_progress because
22+
# Travis terminates the build after 10 mins without output.
23+
export BAZEL_OPTIONS="$BAZEL_OPTIONS --experimental_ui_actions_shown=1"
24+
25+
# Enable thread safety analysis (only works with clang).
26+
if [[ "$TRAVIS_COMPILER" = "clang" ]]; then
27+
export BAZEL_OPTIONS="$BAZEL_OPTIONS --copt=-Werror=thread-safety"
28+
fi
29+
30+
wget https://github.com/bazelbuild/bazel/releases/download/0.20.0/bazel-0.20.0-installer-${BAZEL_OS}-x86_64.sh
31+
chmod +x bazel-0.20.0-installer-${BAZEL_OS}-x86_64.sh
32+
./bazel-0.20.0-installer-${BAZEL_OS}-x86_64.sh --user
33+
echo "build --disk_cache=$HOME/bazel-cache" > ~/.bazelrc
34+
echo "build --experimental_strict_action_env" >> ~/.bazelrc
35+
du -sk $HOME/bazel-cache || true
36+
37+
bazel build $BAZEL_OPTIONS --experimental_ui_actions_shown=1 -k $(bazel query "kind(rule, //...)" | grep -v :_)
38+
bazel test $BAZEL_OPTIONS --experimental_ui_actions_shown=1 -k $(bazel query "kind(test, //...) except attr('tags', 'manual|noci', //...)" | grep -v :_)
39+
40+
du -sk $HOME/bazel-cache || true

tools/travis/build_cmake.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2018, OpenCensus Authors
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
set -e
16+
set -x
17+
18+
ccache -s
19+
ccache -z
20+
cmake -H. -B.build
21+
cmake --build .build
22+
(cd .build && ctest --output-on-failure)
23+
ccache -s

tools/travis/check_format.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2018, OpenCensus Authors
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
set -e
16+
set -x
17+
18+
# Install buildifier if it's not present. It needs at least go 1.8.
19+
if ! which buildifier >/dev/null; then
20+
eval "$(gimme 1.11)"
21+
go get -v github.com/bazelbuild/buildtools/buildifier
22+
fi
23+
# Install cmake-format.
24+
pip install --user cmake_format
25+
# Check format.
26+
tools/format.sh

0 commit comments

Comments
 (0)