Merge branch 'maint-0.3.4' into release-0.3.4
[tor.git] / .travis.yml
blob34b7595eb356123297f1c645e0f04e4bd2e3cece
1 language: c
3 cache:
4   ccache: true
5   ## cargo: true
6   directories:
7     - $HOME/.cargo
8     ## where we point CARGO_TARGET_DIR in all our cargo invocations
9     - $TRAVIS_BUILD_DIR/src/rust/target
11 compiler:
12   - gcc
13   - clang
15 os:
16   - linux
17   - osx
19 ## The build matrix in the following stanza expands into builds for each
20 ## OS and compiler.
21 env:
22   global:
23     ## The Travis CI environment allows us two cores, so let's use both.
24     - MAKEFLAGS="-j 2"
25     ## We turn on hardening by default
26     ## Also known as --enable-fragile-hardening in 0.3.0.3-alpha and later
27     - HARDENING_OPTIONS="--enable-expensive-hardening"
28     ## We turn off asciidoc by default, because it's slow
29     - ASCIIDOC_OPTIONS="--disable-asciidoc"
30   matrix:
31     ## We want to use each build option at least once
32     ##
33     ## We don't list default variable values, because we set the defaults
34     ## in global (or the default is unset)
35     -
36     ## We turn off hardening for Rust builds, because they are incompatible,
37     ## and it's going to take a while for them to be fixed. See:
38     ##   https:/trac.torproject.org/projects/tor/ticket/25386
39     ##   https:/trac.torproject.org/projects/tor/ticket/26398
40     ## TOR_RUST_DEPENDENCIES is spelt RUST_DEPENDENCIES in 0.3.2
41     - RUST_OPTIONS="--enable-rust" TOR_RUST_DEPENDENCIES=true HARDENING_OPTIONS=""
43 matrix:
44   ## include creates builds with gcc, linux, sudo: false
45   include:
46     ## We include a single coverage build with the best options for coverage
47     - env: COVERAGE_OPTIONS="--enable-coverage" HARDENING_OPTIONS=""
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=""
54     ## Check rust online with distcheck, to make sure we remove rust products
55     ## But without hardening (see above)
56     - env: DISTCHECK="yes" RUST_OPTIONS="--enable-rust --enable-cargo-online-mode" HARDENING_OPTIONS=""
57     ## Check disable module dirauth with and without rust
58     - env: MODULES_OPTIONS="--disable-module-dirauth" RUST_OPTIONS="--enable-rust" TOR_RUST_DEPENDENCIES=true HARDENING_OPTIONS=""
59     - env: MODULES_OPTIONS="--disable-module-dirauth"
61   ## Uncomment to allow the build to report success (with non-required
62   ## sub-builds continuing to run) if all required sub-builds have
63   ## succeeded.  This is somewhat buggy currently: it can cause
64   ## duplicate notifications and prematurely report success if a
65   ## single sub-build has succeeded.  See
66   ## https://github.com/travis-ci/travis-ci/issues/1696
67   # fast_finish: true
69   ## Careful! We use global envs, which makes it hard to exclude or
70   ## allow failures by env:
71   ## https://docs.travis-ci.com/user/customizing-the-build#matching-jobs-with-allow_failures
72   exclude:
73     ## Clang doesn't work in containerized builds, see below.
74     - compiler: clang
75       sudo: false
76     ## Non-containerized gcc are slow and redundant.
77     - compiler: gcc
78       sudo: required
79     ## gcc on OSX is less useful, because the default compiler is clang.
80     - compiler: gcc
81       os: osx
82     ## gcc on Linux with no env is redundant, because all the custom builds use
83     ## gcc on Linux
84     - compiler: gcc
85       os: linux
86       env:
87     ## offline rust builds for gcc on Linux are redundant, because we do an
88     ## online rust build for gcc on Linux
89     - compiler: gcc
90       os: linux
91       ## TOR_RUST_DEPENDENCIES is spelt RUST_DEPENDENCIES in 0.3.2
92       env: RUST_OPTIONS="--enable-rust" TOR_RUST_DEPENDENCIES=true HARDENING_OPTIONS=""
94 ## We don't need sudo. (The "apt:" stanza after this allows us to not need
95 ## sudo; otherwise, we would need it for getting dependencies.)
97 ## But we use "sudo: required" to force non-containerized builds, working
98 ## around a Travis CI environment issue: clang LeakAnalyzer fails
99 ## because it requires ptrace and the containerized environment no
100 ## longer allows ptrace.
101 ## https://github.com/travis-ci/travis-ci/issues/9033
103 ## In the matrix above, we exclude redundant combinations.
104 sudo:
105   - false
106   - required
108 ## (Linux only) Use the latest Linux image (Ubuntu Trusty)
109 dist: trusty
111 ## (Linux only) Download our dependencies
112 addons:
113   apt:
114     packages:
115       ## Required dependencies
116       - libevent-dev
117       - zlib1g-dev
118       ## Optional dependencies
119       - libcap-dev
120       - liblzma-dev
121       - libscrypt-dev
122       - libseccomp-dev
123       ## zstd doesn't exist in Ubuntu Trusty
124       #- libzstd
125       ## Conditional dependencies
126       ## Always installed, so we don't need sudo
127       - asciidoc
128       - docbook-xsl
129       - docbook-xml
130       - xmlto
132 ## (OSX only) Use the default OSX image
133 ## See https://docs.travis-ci.com/user/reference/osx#os-x-version
134 ## Default is Xcode 9.4 on macOS 10.13 as of August 2018
135 #osx_image: xcode9.4
137 before_install:
138   ## If we're on OSX, homebrew usually needs to be updated first
139   - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi
140   ## We might be upgrading some useless packages, but that's better than missing an upgrade
141   - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew upgrade; fi
142   ## Create empty rust directories for non-Rust builds, so caching succeeds
143   - if [[ "$RUST_OPTIONS" == "" ]]; then mkdir -p $HOME/.cargo $TRAVIS_BUILD_DIR/src/rust/target; fi
145 install:
146   ## If we're on OSX use brew to install ccache (ccache is automatically installed on Linux)
147   - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install ccache; fi
148   - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PATH="/usr/local/opt/ccache/libexec:$PATH"; fi
149   ## If we're on OSX use brew to install required dependencies (for Linux, see the "apt:" section above)
150   - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install libevent; fi
151   - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install openssl; fi
152   - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install pkg-config; fi
153   ## macOS comes with zlib by default, so the homebrew install is keg-only
154   # - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install zlib; fi
155   ## If we're on OSX also install the optional dependencies
156   - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install libscrypt; fi
157   - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install xz; fi
158   - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install zstd; fi
159   ## 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
160   - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then OPENSSL_OPTIONS=--with-openssl-dir=`brew --prefix openssl`; fi
161   ## Install conditional features
162   ## Install coveralls
163   - if [[ "$COVERAGE_OPTIONS" != "" ]]; then pip install --user cpp-coveralls; fi
164   ## If we're on OSX, and using asciidoc, install asciidoc
165   - if [[ "$ASCIIDOC_OPTIONS" == "" ]] && [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install asciidoc; fi
166   - if [[ "$ASCIIDOC_OPTIONS" == "" ]] && [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install xmlto; fi
167   - if [[ "$ASCIIDOC_OPTIONS" == "" ]] && [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export XML_CATALOG_FILES="/usr/local/etc/xml/catalog"; fi
168   ## If we're using Rust, download rustup
169   - if [[ "$RUST_OPTIONS" != "" ]]; then curl -Ssf -o rustup.sh https://sh.rustup.rs; fi
170   ## Install the stable channels of rustc and cargo and setup our toolchain environment
171   - if [[ "$RUST_OPTIONS" != "" ]]; then sh rustup.sh -y --default-toolchain stable; fi
172   - if [[ "$RUST_OPTIONS" != "" ]]; then source $HOME/.cargo/env; fi
173   ## If we're testing rust builds in offline-mode, then set up our vendored dependencies
174   - if [[ "$TOR_RUST_DEPENDENCIES" == "true" ]]; then export TOR_RUST_DEPENDENCIES=$PWD/src/ext/rust/crates; fi
175   ##
176   ## Finally, list installed package versions
177   - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then dpkg-query --show; fi
178   - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew list --versions; fi
179   ## Get some info about rustup, rustc and cargo
180   - if [[ "$RUST_OPTIONS" != "" ]]; then which rustup; fi
181   - if [[ "$RUST_OPTIONS" != "" ]]; then which rustc; fi
182   - if [[ "$RUST_OPTIONS" != "" ]]; then which cargo; fi
183   - if [[ "$RUST_OPTIONS" != "" ]]; then rustup --version; fi
184   - if [[ "$RUST_OPTIONS" != "" ]]; then rustc --version; fi
185   - if [[ "$RUST_OPTIONS" != "" ]]; then cargo --version; fi
187 script:
188   - ./autogen.sh
189   - CONFIGURE_FLAGS="$ASCIIDOC_OPTIONS $COVERAGE_OPTIONS $HARDENING_OPTIONS $MODULES_OPTIONS $OPENSSL_OPTIONS $RUST_OPTIONS --enable-fatal-warnings --disable-silent-rules"
190   - echo "Configure flags are $CONFIGURE_FLAGS"
191   - ./configure $CONFIGURE_FLAGS
192   ## We run `make check` because that's what https://jenkins.torproject.org does.
193   - if [[ "$DISTCHECK" == "" ]]; then make check; fi
194   - if [[ "$DISTCHECK" != "" ]]; then make distcheck DISTCHECK_CONFIGURE_FLAGS="$CONFIGURE_FLAGS"; fi
196 after_failure:
197   ## configure will leave a log file with more details of config failures.
198   ## But the log is too long for travis' rendered view, so tail it.
199   - tail -1000 config.log || echo "tail failed"
200   ## `make check` will leave a log file with more details of test failures.
201   - if [[ "$DISTCHECK" == "" ]]; then cat test-suite.log || echo "cat failed"; fi
202   ## `make distcheck` puts it somewhere different.
203   - if [[ "$DISTCHECK" != "" ]]; then make show-distdir-testlog || echo "make failed"; fi
205 after_success:
206   ## If this build was one that produced coverage, upload it.
207   - if [[ "$COVERAGE_OPTIONS" != "" ]]; then coveralls -b . --exclude src/test --exclude src/trunnel --gcov-options '\-p'; fi
209 notifications:
210   irc:
211     channels:
212       - "irc.oftc.net#tor-ci"
213     template:
214       - "%{repository} %{branch} %{commit} - %{author}: %{commit_subject}"
215       - "Build #%{build_number} %{result}. Details: %{build_url}"
216     on_success: change
217     on_failure: change
218   email:
219     on_success: never
220     on_failure: change