Merge branch 'tor-github/pr/1287'
[tor.git] / .travis.yml
blob94d9bf9cceed141cda57449624a94a3ba3f44d24
1 language: c
3 cache:
4   ccache: true
5   ## cargo: true
6   directories:
7     - $HOME/.cargo
8     ## caching CARGO_TARGET_DIR actually slows down the build over time,
9     ## because old build products are never deleted.
10     ## where we point CARGO_TARGET_DIR in all our cargo invocations
11     #- $TRAVIS_BUILD_DIR/src/rust/target
13 compiler:
14   - gcc
15   - clang
17 os:
18   - linux
19   - osx
21 ## The build matrix in the following stanza expands into builds for each
22 ## OS and compiler.
23 env:
24   global:
25     ## The Travis CI environment allows us two cores, so let's use both.
26     - MAKEFLAGS="-j 2"
27     ## We turn on hardening by default
28     ## Also known as --enable-fragile-hardening in 0.3.0.3-alpha and later
29     - HARDENING_OPTIONS="--enable-expensive-hardening"
30     ## We turn off asciidoc by default, because it's slow
31     - ASCIIDOC_OPTIONS="--disable-asciidoc"
32     ## Our default rust version is the minimum supported version
33     - RUST_VERSION="1.31.0"
34   matrix:
35     ## We want to use each build option at least once
36     ##
37     ## We don't list default variable values, because we set the defaults
38     ## in global (or the default is unset)
39     -
40     ## TOR_RUST_DEPENDENCIES is spelt RUST_DEPENDENCIES in 0.3.2
41     - RUST_OPTIONS="--enable-rust" TOR_RUST_DEPENDENCIES=true
43 matrix:
44   ## include creates builds with gcc, linux
45   include:
46     ## We include a single coverage build with the best options for coverage
47     - env: COVERAGE_OPTIONS="--enable-coverage" HARDENING_OPTIONS="" TOR_TEST_RNG_SEED="636f766572616765"
48     ## We only want to check these build option combinations once
49     ## (they shouldn't vary by compiler or OS)
50     ## We run rust and coverage with hardening off, which seems like enough
51     # - env: HARDENING_OPTIONS=""
52     ## We check asciidoc with distcheck, to make sure we remove doc products
53     - env: DISTCHECK="yes" ASCIIDOC_OPTIONS="" SKIP_MAKE_CHECK="yes"
54     # We also try running a hardened clang build with chutney on Linux.
55     - env: CHUTNEY="yes" SKIP_MAKE_CHECK="yes" CHUTNEY_ALLOW_FAILURES="2"
56       compiler: clang
57     # We clone our stem repo and run `make test-stem`
58     - env: TEST_STEM="yes" SKIP_MAKE_CHECK="yes"
59     ## Check rust online with distcheck, to make sure we remove rust products
60     - env: DISTCHECK="yes" RUST_VERSION="beta" RUST_OPTIONS="--enable-rust --enable-cargo-online-mode"
61     ## Check disable module dirauth with and without rust
62     - env: MODULES_OPTIONS="--disable-module-dirauth" RUST_VERSION="nightly" RUST_OPTIONS="--enable-rust" TOR_RUST_DEPENDENCIES=true
63     - env: MODULES_OPTIONS="--disable-module-dirauth"
64     ## Check NSS
65     - env: NSS_OPTIONS="--enable-nss"
67   ## Uncomment to allow the build to report success (with non-required
68   ## sub-builds continuing to run) if all required sub-builds have
69   ## succeeded.  This is somewhat buggy currently: it can cause
70   ## duplicate notifications and prematurely report success if a
71   ## single sub-build has succeeded.  See
72   ## https://github.com/travis-ci/travis-ci/issues/1696
73   # fast_finish: true
75   ## Careful! We use global envs, which makes it hard to exclude or
76   ## allow failures by env:
77   ## https://docs.travis-ci.com/user/customizing-the-build#matching-jobs-with-allow_failures
78   allow_failures:
79     ## test-stem sometimes hangs on Travis
80     - env: TEST_STEM="yes" SKIP_MAKE_CHECK="yes"
82   exclude:
83     ## gcc on OSX is less useful, because the default compiler is clang.
84     - compiler: gcc
85       os: osx
86     ## gcc on Linux with no env is redundant, because all the custom builds use
87     ## gcc on Linux
88     - compiler: gcc
89       os: linux
90       env:
91     ## offline rust builds for gcc on Linux are redundant, because we do an
92     ## online rust build for gcc on Linux
93     - compiler: gcc
94       os: linux
95       ## TOR_RUST_DEPENDENCIES is spelt RUST_DEPENDENCIES in 0.3.2
96       env: RUST_OPTIONS="--enable-rust" TOR_RUST_DEPENDENCIES=true
98 ## (Linux only) Use the latest Linux image (Ubuntu Trusty)
99 dist: trusty
101 ## Download our dependencies
102 addons:
103   ## (Linux only)
104   apt:
105     packages:
106       ## Required dependencies
107       - libevent-dev
108       ## Ubuntu comes with OpenSSL by default
109       #- libssl-dev
110       - zlib1g-dev
111       ## Optional dependencies
112       - libcap-dev
113       - liblzma-dev
114       - libnss3-dev
115       - libscrypt-dev
116       - libseccomp-dev
117       ## zstd doesn't exist in Ubuntu Trusty
118       #- libzstd
119       - shellcheck
120       ## Conditional build dependencies
121       ## Always installed, so we don't need sudo
122       - asciidoc
123       - docbook-xsl
124       - docbook-xml
125       - xmlto
126       ## Utilities
127       ## preventing or diagnosing hangs
128       - timelimit
129   ## (OSX only)
130   homebrew:
131     packages:
132       ## Required dependencies
133       - libevent
134       ## The OSX version of OpenSSL is way too old
135       - openssl
136       ## OSX comes with zlib by default
137       ## to use a newer zlib, pass the keg path to configure (like OpenSSL)
138       #- zlib
139       ## Optional dependencies
140       - libscrypt
141       - xz
142       - zstd
143       ## Required build dependencies
144       ## Tor needs pkg-config to find some dependencies at build time
145       - pkg-config
146       ## Optional build dependencies
147       - ccache
148       - shellcheck
149       ## Conditional build dependencies
150       ## Always installed, because manual brew installs are hard to get right
151       - asciidoc
152       - xmlto
153       ## Utilities
154       ## preventing or diagnosing hangs
155       - timelimit
157 ## (OSX only) Use the default OSX image
158 ## See https://docs.travis-ci.com/user/reference/osx#os-x-version
159 ## Default is Xcode 9.4 on macOS 10.13 as of August 2018
160 #osx_image: xcode9.4
162 before_install:
163   ## Create empty rust directories for non-Rust builds, so caching succeeds
164   - if [[ "$RUST_OPTIONS" == "" ]]; then mkdir -p $HOME/.cargo $TRAVIS_BUILD_DIR/src/rust/target; fi
166 install:
167   ## If we're on OSX, configure ccache (ccache is automatically installed and configured on Linux)
168   - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PATH="/usr/local/opt/ccache/libexec:$PATH"; fi
169   ## If we're on OSX, OpenSSL is keg-only, so tor 0.2.9 and later need to be configured --with-openssl-dir= to build
170   - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then OPENSSL_OPTIONS=--with-openssl-dir=`brew --prefix openssl`; fi
171   ## Install conditional features
172   ## Install coveralls
173   - if [[ "$COVERAGE_OPTIONS" != "" ]]; then pip install --user cpp-coveralls; fi
174   ## If we're on OSX, and using asciidoc, configure asciidoc
175   - if [[ "$ASCIIDOC_OPTIONS" == "" ]] && [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export XML_CATALOG_FILES="/usr/local/etc/xml/catalog"; fi
176   ## If we're using Rust, download rustup
177   - if [[ "$RUST_OPTIONS" != "" ]]; then curl -Ssf -o rustup.sh https://sh.rustup.rs; fi
178   ## Install the stable channels of rustc and cargo and setup our toolchain environment
179   - if [[ "$RUST_OPTIONS" != "" ]]; then sh rustup.sh -y --default-toolchain $RUST_VERSION; fi
180   - if [[ "$RUST_OPTIONS" != "" ]]; then source $HOME/.cargo/env; fi
181   ## If we're testing rust builds in offline-mode, then set up our vendored dependencies
182   - if [[ "$TOR_RUST_DEPENDENCIES" == "true" ]]; then export TOR_RUST_DEPENDENCIES=$PWD/src/ext/rust/crates; fi
183   ## If we're running chutney, install it.
184   - if [[ "$CHUTNEY" != "" ]]; then git clone --depth 1 https://github.com/torproject/chutney.git ; export CHUTNEY_PATH="$(pwd)/chutney"; fi
185   ## If we're running stem, install it.
186   - if [[ "$TEST_STEM" != "" ]]; then git clone --depth 1 https://github.com/torproject/stem.git ; export STEM_SOURCE_DIR=`pwd`/stem; fi
187   ##
188   ## Finally, list installed package versions
189   - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then dpkg-query --show; fi
190   - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew list --versions; fi
191   ## Get some info about rustup, rustc and cargo
192   - if [[ "$RUST_OPTIONS" != "" ]]; then which rustup; fi
193   - if [[ "$RUST_OPTIONS" != "" ]]; then which rustc; fi
194   - if [[ "$RUST_OPTIONS" != "" ]]; then which cargo; fi
195   - if [[ "$RUST_OPTIONS" != "" ]]; then rustup --version; fi
196   - if [[ "$RUST_OPTIONS" != "" ]]; then rustc --version; fi
197   - if [[ "$RUST_OPTIONS" != "" ]]; then cargo --version; fi
198   ## Get python version
199   - python --version
200   ## If we're running chutney, show the chutney commit
201   - if [[ "$CHUTNEY" != "" ]]; then pushd "$CHUTNEY_PATH"; git log -1 ; popd ; fi
202   ## If we're running stem, show the stem version and commit
203   - if [[ "$TEST_STEM" != "" ]]; then pushd stem; python -c "from stem import stem; print(stem.__version__);"; git log -1; popd; fi
204   ## We don't want Tor tests to depend on default configuration file at
205   ## ~/.torrc. So we put some random bytes in there, to make sure we get build
206   ## failures in case Tor is reading it during CI jobs.
207   - dd ibs=1 count=1024 if=/dev/urandom > ~/.torrc
209 script:
210   # Skip test_rebind on macOS
211   - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export TOR_SKIP_TEST_REBIND=true; fi
212   - ./autogen.sh
213   - CONFIGURE_FLAGS="$ASCIIDOC_OPTIONS $COVERAGE_OPTIONS $HARDENING_OPTIONS $MODULES_OPTIONS $NSS_OPTIONS $OPENSSL_OPTIONS $RUST_OPTIONS --enable-fatal-warnings --disable-silent-rules"
214   - echo "Configure flags are $CONFIGURE_FLAGS"
215   - ./configure $CONFIGURE_FLAGS
216   ## We run `make check` because that's what https://jenkins.torproject.org does.
217   - if [[ "$SKIP_MAKE_CHECK" == "" ]]; then make check; fi
218   - if [[ "$DISTCHECK" != "" ]]; then make distcheck DISTCHECK_CONFIGURE_FLAGS="$CONFIGURE_FLAGS"; fi
219   - if [[ "$CHUTNEY" != "" ]]; then make test-network-all; fi
220   ## Diagnostic for bug 29437: kill stem if it hangs for 9.5 minutes
221   ## Travis will kill the job after 10 minutes with no output
222   - if [[ "$TEST_STEM" != "" ]]; then make src/app/tor; timelimit -p -t 540 -s USR1 -T 30 -S ABRT python3 "$STEM_SOURCE_DIR"/run_tests.py --tor src/app/tor --integ --test control.controller --test control.base_controller --test process --log TRACE --log-file stem.log; fi
223   ## If this build was one that produced coverage, upload it.
224   - if [[ "$COVERAGE_OPTIONS" != "" ]]; then coveralls -b . --exclude src/test --exclude src/trunnel --gcov-options '\-p' || echo "Coverage failed"; fi
226 after_failure:
227   ## configure will leave a log file with more details of config failures.
228   ## But the log is too long for travis' rendered view, so tail it.
229   - tail -1000 config.log || echo "tail failed"
230   ## `make check` will leave a log file with more details of test failures.
231   - if [[ "$SKIP_MAKE_CHECK" == "" ]]; then cat test-suite.log || echo "cat failed"; fi
232   ## `make distcheck` puts it somewhere different.
233   - if [[ "$DISTCHECK" != "" ]]; then make show-distdir-testlog || echo "make failed"; fi
234   - if [[ "$DISTCHECK" != "" ]]; then make show-distdir-core || echo "make failed"; fi
235   - if [[ "$CHUTNEY" != "" ]]; then ls test_network_log || echo "ls failed"; cat test_network_log/* || echo "cat failed"; fi
236   - if [[ "$TEST_STEM" != "" ]]; then tail -1000 "$STEM_SOURCE_DIR"/test/data/tor_log || echo "tail failed"; fi
237   - if [[ "$TEST_STEM" != "" ]]; then grep -v "SocketClosed" stem.log | tail -1000 || echo "grep | tail failed"; fi
239 before_cache:
240   ## Delete all gcov files.
241   - if [[ "$COVERAGE_OPTIONS" != "" ]]; then make reset-gcov; fi
242   ## Delete the cargo registry before caching .cargo, because it's cheaper to
243   ## download the registry and throw it away, rather than caching it
244   - rm -rf $HOME/.cargo/registry
246 notifications:
247   irc:
248     channels:
249       - "irc.oftc.net#tor-ci"
250     template:
251       - "%{repository} %{branch} %{commit} - %{author}: %{commit_subject}"
252       - "Build #%{build_number} %{result}. Details: %{build_url}"
253     on_success: change
254     on_failure: change
255   email:
256     on_success: never
257     on_failure: change