1# Copyright (C) 2017 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15notifications:
16  email: false
17
18language: cpp
19
20# The |CFG| variable name is hooked up by the perfetto-ci.appspot.com frontend.
21# Please keep infra/perfetto-ci.appspot.com/ updated when adding/removing
22# entries below.
23matrix:
24  include:
25# OS X builds are processing too slow and block the queue.
26# Commenting out until the problem is resolved.
27#    - os: osx
28#      osx_image: xcode8.3
29#      compiler: clang
30#      env: CFG=mac-clang-x86_64-release GN_ARGS="is_debug=false"
31#    - os: osx
32#      osx_image: xcode8.3
33#      compiler: clang
34#      env: CFG=mac-clang-x86_64-debug GN_ARGS="is_debug=true"
35#    - os: osx
36#      osx_image: xcode8.3
37#      compiler: clang
38#      env: CFG=mac-clang-x86_64-asan GN_ARGS="is_debug=false is_asan=true"
39#    - os: osx
40#      osx_image: xcode8.3
41#      compiler: clang
42#      env: CFG=mac-clang-x86_64-tsan GN_ARGS="is_debug=false is_tsan=true"
43#    - os: osx
44#      osx_image: xcode8.3
45#      compiler: clang
46#      env: CFG=mac-clang-x86_64-ubsan GN_ARGS="is_debug=false is_ubsan=true"
47    - os: linux
48      dist: trusty
49      sudo: false
50      # When setting compiler: clang Travis pull a newer version of clang than
51      # the version that is shipped with Trusty. This is good for all the other
52      # configs, but we want to keep at least one target in the matrix to match
53      # the default version of clang that we have on our workstations.
54      addons:
55        apt:
56          packages:
57            - clang
58      env: CFG=linux_trusty-clang-x86_64-debug GN_ARGS="is_debug=true is_hermetic_clang=false"
59    - os: linux
60      dist: trusty
61      sudo: false
62      compiler: clang
63      env: CFG=linux_trusty-clang-x86_64-tsan GN_ARGS="is_debug=false is_tsan=true"
64    - os: linux
65      dist: trusty
66      sudo: false
67      compiler: clang
68      env: CFG=linux_trusty-clang-x86_64-msan GN_ARGS="is_debug=false is_msan=true"
69    - os: linux
70      dist: trusty
71      sudo: true
72      compiler: clang
73      env: CFG=linux_trusty-clang-x86_64-ubsan_asan_lsan GN_ARGS="is_debug=false is_ubsan=true is_asan=true is_lsan=true"
74    - os: linux
75      dist: trusty
76      sudo: false
77      addons:
78        apt:
79          sources:
80            - ubuntu-toolchain-r-test
81          packages:
82            - g++-7
83      env: CFG=linux_trusty-gcc7-x86_64-release GN_ARGS="is_debug=false is_clang=false use_custom_libcxx=false cc=\"gcc-7\" cxx=\"g++-7\""
84    - os: linux
85      dist: trusty
86      sudo: false
87      compiler: clang
88      env: CFG=android-clang-arm-release GN_ARGS="is_debug=false target_os=\"android\" target_cpu=\"arm\""
89    - os: linux
90      dist: trusty
91      sudo: true
92      compiler: clang
93      env: CFG=android-clang-arm-asan GN_ARGS="is_debug=false target_os=\"android\" target_cpu=\"arm\" is_asan=true"
94    - os: linux
95      dist: trusty
96      sudo: true
97      compiler: clang
98      env: CFG=linux_trusty-clang-x86_64-libfuzzer GN_ARGS="is_clang=true is_debug=false use_libfuzzer=true is_asan=true"
99
100# Cache the deps that get git-pulled to avoid hitting quota limits (b/68252114).
101# Do not cache NDK/SDK and things that come from .zip files rather than git.
102# Doing that is discouraged (https://docs.travis-ci.com/user/caching/).
103cache:
104  timeout: 1800  # 30 mins
105  directories:
106    - buildtools/benchmark
107    - buildtools/emulator
108    - buildtools/googletest
109    - buildtools/libbacktrace
110    - buildtools/libcxx
111    - buildtools/libcxxabi
112    - buildtools/libunwind
113
114before_install:
115  - set -e
116  - echo "$CFG" && echo "$GN_ARGS"
117  - export ASAN_SYMBOLIZER_PATH="$(which llvm-symbolizer
118      || echo /usr/bin/llvm-symbolizer-*)"
119
120install:
121  - |
122    if [[ "$CFG" != android-* ]]; then
123      tools/install-build-deps --no-android
124    else
125      tools/install-build-deps
126    fi
127  - |
128    if [[ -e buildtools/clang/bin/llvm-symbolizer ]]; then
129      export ASAN_SYMBOLIZER_PATH="buildtools/clang/bin/llvm-symbolizer"
130    fi
131
132script:
133  - tools/gn gen out/dist --args="${GN_ARGS}" --check
134  - tools/ninja -C out/dist -j8 all
135  - |
136    TEST_TARGETS="
137    perfetto_integrationtests
138    perfetto_unittests
139    "
140    if [[ "$CFG" != android-* ]]; then
141      for TEST_TARGET in $TEST_TARGETS; do
142        "out/dist/$TEST_TARGET"
143      done
144      BENCHMARK_FUNCTIONAL_TEST_ONLY=true out/dist/perfetto_benchmarks
145      if [[ "$CFG" == *-libfuzzer ]]; then
146        # Run a single iteration each to make sure they are not crashing.
147        out/dist/end_to_end_shared_memory_fuzzer -runs=1
148        out/dist/buffered_frame_deserializer_fuzzer -runs=1
149      fi
150    else
151      TARGET_ARCH=$(echo $CFG | cut -d- -f3)
152      tools/run_android_emulator --pid /tmp/emulator.pid -v &
153      for TEST_TARGET in $TEST_TARGETS; do
154        tools/run_android_test out/dist "$TEST_TARGET"
155      done
156      tools/run_android_test --env BENCHMARK_FUNCTIONAL_TEST_ONLY=true out/dist "perfetto_benchmarks"
157    fi
158
159after_script:
160  - test -f /tmp/emulator.pid && kill -9 $(cat /tmp/emulator.pid); true
161