Skip to content

Commit

Permalink
Simplify Travis CI builds.
Browse files Browse the repository at this point in the history
Have one script per build. This means more duplication between the
scripts, but it's much easier to understand and to run locally.
  • Loading branch information
iphydf committed Jun 25, 2018
1 parent ae7899c commit d703c92
Show file tree
Hide file tree
Showing 9 changed files with 296 additions and 168 deletions.
48 changes: 40 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ matrix:
env: JOB=toxcore ENV=linux
compiler: gcc
addons:
apt: &apt-dependencies
apt:
packages:
- libconfig-dev # For tox-bootstrapd.
- libcv-dev # For av_test.
Expand All @@ -23,69 +23,101 @@ matrix:
- libgtest-dev # For unit tests.
- libvpx-dev # For toxav.
- portaudio19-dev # For av_test.
install: .travis/cmake-linux install
script: .travis/cmake-linux script
after_script: .travis/upload-coverage
- stage: "Stage 1"
if: type IN (push, api, cron)
env: JOB=autotools ENV=linux
compiler: clang
addons:
apt: *apt-dependencies
apt:
packages:
- libconfig-dev # For tox-bootstrapd.
- libopus-dev # For toxav.
- libvpx-dev # For toxav.
install: .travis/autotools-linux install
script: .travis/autotools-linux script
- stage: "Stage 1"
if: type IN (push, api, cron)
env: JOB=toxcore ENV=windows ARCH=i686
group: deprecated-2017Q4
services:
- docker
install: other/travis/phase $JOB $ENV install
script: other/travis/phase $JOB $ENV script
after_script: other/travis/phase $JOB $ENV after_script
after_failure: other/travis/phase $JOB $ENV after_failure
- stage: "Stage 1"
if: type IN (push, api, cron)
env: JOB=toxcore ENV=windows ARCH=x86_64
group: deprecated-2017Q4
services:
- docker
install: other/travis/phase $JOB $ENV install
script: other/travis/phase $JOB $ENV script
after_script: other/travis/phase $JOB $ENV after_script
after_failure: other/travis/phase $JOB $ENV after_failure
- stage: "Stage 1"
if: type IN (push, api, cron)
env: JOB=installmd ENV=windows SUPPORT_ARCH_i686=true SUPPORT_ARCH_x86_64=false SUPPORT_TEST=true ENABLE_ARCH_i686=true ENABLE_ARCH_x86_64=false ENABLE_TEST=true ALLOW_TEST_FAILURE=true
services:
- docker
install: other/travis/phase $JOB $ENV install
script: other/travis/phase $JOB $ENV script
after_script: other/travis/phase $JOB $ENV after_script
after_failure: other/travis/phase $JOB $ENV after_failure
- stage: "Stage 1"
if: type IN (push, api, cron)
env: JOB=installmd ENV=windows SUPPORT_ARCH_i686=false SUPPORT_ARCH_x86_64=true SUPPORT_TEST=true ENABLE_ARCH_i686=false ENABLE_ARCH_x86_64=true ENABLE_TEST=true ALLOW_TEST_FAILURE=true
services:
- docker
install: other/travis/phase $JOB $ENV install
script: other/travis/phase $JOB $ENV script
after_script: other/travis/phase $JOB $ENV after_script
after_failure: other/travis/phase $JOB $ENV after_failure
- stage: "Stage 1"
if: type IN (push, api, cron)
env: JOB=toxcore ENV=freebsd
dist: trusty
sudo: required
install: other/travis/phase $JOB $ENV install stage1
script: other/travis/phase $JOB $ENV script stage1
after_script: other/travis/phase $JOB $ENV after_script
after_failure: other/travis/phase $JOB $ENV after_failure
- stage: "Stage 1"
if: type IN (push, api, cron)
env: JOB=tox-bootstrapd-docker ENV=linux
services:
- docker
sudo: required
install: other/travis/phase $JOB $ENV install
script: other/travis/phase $JOB $ENV script
after_script: other/travis/phase $JOB $ENV after_script
after_failure: other/travis/phase $JOB $ENV after_failure
- stage: "Stage 2"
if: type IN (push, api, cron)
env: JOB=toxcore ENV=freebsd
dist: trusty
sudo: required
install: other/travis/phase $JOB $ENV install stage2
script: other/travis/phase $JOB $ENV script
after_script: other/travis/phase $JOB $ENV after_script
after_failure: other/travis/phase $JOB $ENV after_failure
- stage: "Stage 2"
if: type IN (push, api, cron)
env: JOB=toxcore ENV=osx RUN_TESTS=true
os: osx
install: other/travis/phase $JOB $ENV install
script: other/travis/phase $JOB $ENV script
after_script: other/travis/phase $JOB $ENV after_script
after_failure: other/travis/phase $JOB $ENV after_failure
fast_finish: true

cache:
directories:
- $HOME/cache
- /opt/freebsd/cache

install: other/travis/phase $JOB $ENV install
script: other/travis/phase $JOB $ENV script
after_script: other/travis/phase $JOB $ENV after_script
after_failure: other/travis/phase $JOB $ENV after_failure

notifications:
irc:
channels:
Expand Down
62 changes: 62 additions & 0 deletions .travis/autotools-linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/sh

ACTION="$1"

set -eu

CACHEDIR="$HOME/cache"

add_config_flag() { export CONFIG_FLAGS="$CONFIG_FLAGS $1"; }
add_c_flag() { export C_FLAGS="$C_FLAGS $1"; }
add_cxx_flag() { export CXX_FLAGS="$CXX_FLAGS $1"; }
add_flag() { add_c_flag "$@"; add_cxx_flag "$@"; }

travis_install() {
# Install vanilla NaCl only.
[ -f "$CACHEDIR/lib/amd64/libnacl.a" ] || {
curl https://hyperelliptic.org/nacl/nacl-20110221.tar.bz2 | tar jx
cd nacl-20110221 # pushd
"./do"
# "make install"
mkdir -p "$CACHEDIR/include"; mv build/*/include/* "$CACHEDIR/include"
mkdir -p "$CACHEDIR/lib" ; mv build/*/lib/* "$CACHEDIR/lib"
cd - # popd
}
}

travis_script() {
. ".travis/flags-$CC.sh"

# Optimisation flags.
add_flag -O3 -march=native

# Warn on non-ISO C.
add_c_flag -pedantic

# Make compilation error on a warning
add_flag -Werror
add_flag -g3
add_flag -ftrapv

add_config_flag --with-nacl-libs=$CACHEDIR/lib/amd64
add_config_flag --with-nacl-headers=$CACHEDIR/include/amd64
add_config_flag --disable-ipv6
add_config_flag --enable-nacl
add_config_flag --enable-daemon
add_config_flag --enable-logging
add_config_flag --with-log-level=TRACE

autoreconf -fi
mkdir -p _build
cd _build # pushd
../configure $CONFIG_FLAGS || (cat config.log && false)
make -j`nproc` -k CFLAGS="$C_FLAGS" LDFLAGS="$LD_FLAGS"
make -j`nproc` -k distcheck DISTCHECK_CONFIGURE_FLAGS="$CONFIG_FLAGS"
cd - # popd
}

if [ "-z" "$ACTION" ]; then
"travis_script"
else
"travis_$ACTION"
fi
73 changes: 73 additions & 0 deletions .travis/cmake-linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/sh

ACTION="$1"

set -eu

CACHEDIR="$HOME/cache"

ASTYLE="$CACHEDIR/astyle/build/gcc/bin/astyle"

add_config_flag() { export CONFIG_FLAGS="$CONFIG_FLAGS $1"; }
add_c_flag() { export C_FLAGS="$C_FLAGS $1"; }
add_cxx_flag() { export CXX_FLAGS="$CXX_FLAGS $1"; }
add_flag() { add_c_flag "$@"; add_cxx_flag "$@"; }

travis_install() {
which coveralls || {
# Install cpp-coveralls to upload test coverage results.
pip install --user ndg-httpsclient urllib3[secure] cpp-coveralls

# Work around https://github.com/eddyxu/cpp-coveralls/issues/108 by manually
# installing the pyOpenSSL module and injecting it into urllib3 as per
# https://urllib3.readthedocs.io/en/latest/user-guide.html#ssl-py2
sed -i -e '/^import sys$/a import urllib3.contrib.pyopenssl\nurllib3.contrib.pyopenssl.inject_into_urllib3()' `which coveralls`
}

# Install astyle (version in ubuntu-precise too old).
[ -f "$ASTYLE" ] || {
wget -O ../astyle.tar.gz https://deb.debian.org/debian/pool/main/a/astyle/astyle_2.06.orig.tar.gz
tar -xf ../astyle.tar.gz -C "$CACHEDIR"
make -C "$CACHEDIR/astyle/build/gcc" -j`nproc`
}

# Install libsodium (not in ubuntu-precise).
[ -f "$CACHEDIR/lib/libsodium.a" ] || {
git clone --depth=1 --branch=stable https://github.com/jedisct1/libsodium ../libsodium
cd ../libsodium # pushd
./autogen.sh
./configure --prefix="$CACHEDIR"
make install -j`nproc`
cd - # popd
}
}

travis_script() {
. ".travis/flags-$CC.sh"

# Coverage flags.
add_flag -fprofile-arcs -ftest-coverage

cmake -B_build -H. \
-DCMAKE_C_FLAGS="$C_FLAGS" \
-DCMAKE_CXX_FLAGS="$CXX_FLAGS" \
-DCMAKE_EXE_LINKER_FLAGS="$LD_FLAGS" \
-DCMAKE_SHARED_LINKER_FLAGS="$LD_FLAGS" \
-DCMAKE_INSTALL_PREFIX:PATH="$PWD/_install" \
-DTRACE=ON \
-DMUST_BUILD_TOXAV=ON \
-DSTRICT_ABI=ON \
-DTEST_TIMEOUT_SECONDS=120 \
-DUSE_IPV6=OFF

cd _build # pushd
make -j`nproc` -k install
make -j`nproc` test ARGS="-j50" CTEST_OUTPUT_ON_FAILURE=1
cd - # popd
}

if [ "-z" "$ACTION" ]; then
"travis_script"
else
"travis_$ACTION"
fi
60 changes: 60 additions & 0 deletions .travis/flags-clang.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
. .travis/flags.sh

# Add all warning flags we can.
add_flag -Wall
add_flag -Wextra
add_flag -Weverything

# Disable specific warning flags for both C and C++.

# TODO(iphydf): Clean these up. Probably all of these are actual bugs.
add_flag -Wno-cast-align
# Very verbose, not very useful. This warns about things like int -> uint
# conversions that change sign without a cast and narrowing conversions.
add_flag -Wno-conversion
# TODO(iphydf): Check enum values when received from the user, then assume
# correctness and remove this suppression.
add_flag -Wno-covered-switch-default
# Due to clang's tolower() macro being recursive
# https://github.com/TokTok/c-toxcore/pull/481
add_flag -Wno-disabled-macro-expansion
# We don't put __attribute__ on the public API.
add_flag -Wno-documentation-deprecated-sync
# Bootstrap daemon does this.
add_flag -Wno-format-nonliteral
# struct Foo foo = {0}; is a common idiom.
add_flag -Wno-missing-field-initializers
# Useful sometimes, but we accept padding in structs for clarity.
# Reordering fields to avoid padding will reduce readability.
add_flag -Wno-padded
# This warns on things like _XOPEN_SOURCE, which we currently need (we
# probably won't need these in the future).
add_flag -Wno-reserved-id-macro
# TODO(iphydf): Clean these up. They are likely not bugs, but still
# potential issues and probably confusing.
add_flag -Wno-sign-compare
# Our use of mutexes results in a false positive, see 1bbe446.
add_flag -Wno-thread-safety-analysis
# File transfer code has this.
add_flag -Wno-type-limits
# Callbacks often don't use all their parameters.
add_flag -Wno-unused-parameter
# libvpx uses __attribute__((unused)) for "potentially unused" static
# functions to avoid unused static function warnings.
add_flag -Wno-used-but-marked-unused
# We use variable length arrays a lot.
add_flag -Wno-vla

# Disable specific warning flags for C++.

# Comma at end of enum is supported everywhere we run.
add_cxx_flag -Wno-c++98-compat-pedantic
# TODO(iphydf): Stop using flexible array members.
add_cxx_flag -Wno-c99-extensions
# We're C-compatible, so use C style casts.
add_cxx_flag -Wno-old-style-cast

# Downgrade to warning so we still see it.
add_flag -Wno-error=documentation-unknown-command
add_flag -Wno-error=unreachable-code
add_flag -Wno-error=unused-variable
17 changes: 17 additions & 0 deletions .travis/flags-gcc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
. .travis/flags.sh

# Add all warning flags we can.
add_flag -Wall
add_flag -Wextra

# Disable specific warning flags for both C and C++.

# struct Foo foo = {0}; is a common idiom.
add_flag -Wno-missing-field-initializers
# TODO(iphydf): Clean these up. They are likely not bugs, but still
# potential issues and probably confusing.
add_flag -Wno-sign-compare
# File transfer code has this.
add_flag -Wno-type-limits
# Callbacks often don't use all their parameters.
add_flag -Wno-unused-parameter
23 changes: 23 additions & 0 deletions .travis/flags.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
export LD_LIBRARY_PATH="$CACHEDIR/lib"
export PKG_CONFIG_PATH="$CACHEDIR/lib/pkgconfig"

export CONFIG_FLAGS=""
export C_FLAGS=""
export CXX_FLAGS=""
export LD_FLAGS="-Wl,-z,defs"

unset CFLAGS
unset CXXFLAGS
unset CPPFLAGS
unset LDFLAGS

# Optimisation flags.
add_flag -O3 -march=native

# Warn on non-ISO C.
add_c_flag -pedantic

# Make compilation error on a warning
add_flag -Werror
add_flag -g3
add_flag -ftrapv
8 changes: 8 additions & 0 deletions .travis/upload-coverage
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

# We only submit coverage from the Linux build.
coveralls \
--exclude auto_tests \
--exclude other \
--exclude testing \
--gcov-options '\-lp'
Loading

0 comments on commit d703c92

Please sign in to comment.