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 30, 2018
1 parent 706fad1 commit fa46226
Show file tree
Hide file tree
Showing 35 changed files with 489 additions and 455 deletions.
35 changes: 29 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,36 @@ jobs:
x86_64:
working_directory: ~/work
docker:
- image: circleci/builder-base:latest
- image: ubuntu

steps:
- checkout
- run: add-apt-repository ppa:chris-lea/libsodium
- run: apt update
- run: apt install -y clang cmake libgtest-dev libopus-dev libsodium-dev libvpx-dev pkg-config
- run: cmake -H. -B_build -DDEBUG=ON -DTRACE=ON -DERROR_ON_WARNING=ON -DASAN=ON -DMUST_BUILD_TOXAV=ON -DSTRICT_ABI=ON -DTEST_TIMEOUT_SECONDS=90 -DUSE_IPV6=OFF
- run: make -C _build -j$(nproc)
- run: make -C _build test ARGS="-j50 --rerun-failed" CTEST_OUTPUT_ON_FAILURE=1 || make -C _build test ARGS="-j50 --rerun-failed" CTEST_OUTPUT_ON_FAILURE=1
- run: apt install -y --no-install-recommends
clang
cmake
libconfig-dev
libgtest-dev
libopus-dev
libsodium-dev
libvpx-dev
ninja-build
pkg-config
- run: . .travis/flags-clang.sh;
add_flag -fsanitize=address;
cmake -H. -B_build -GNinja
-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
- run: cd _build && ninja install -j$(nproc)
# Retry once, because sometimes tests time out.
# TODO(iphydf): Find out why tests time out on CircleCI.
- run: cd _build && ctest -j50 --output-on-failure
|| ctest -j50 --output-on-failure
73 changes: 33 additions & 40 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ language: c
matrix:
include:
- stage: "Stage 1"
env: JOB=toxcore ENV=linux
env: JOB=cmake-linux
compiler: gcc
addons:
apt: &apt-dependencies
apt:
packages:
- libconfig-dev # For tox-bootstrapd.
- libcv-dev # For av_test.
Expand All @@ -23,69 +23,62 @@ matrix:
- libgtest-dev # For unit tests.
- libvpx-dev # For toxav.
- portaudio19-dev # For av_test.
install: .travis/$JOB install
script: .travis/$JOB script
after_script: .travis/upload-coverage
- stage: "Stage 1"
if: type IN (push, api, cron)
env: JOB=autotools ENV=linux
env: JOB=autotools-linux
compiler: clang
addons:
apt: *apt-dependencies
- stage: "Stage 1"
if: type IN (push, api, cron)
env: JOB=toxcore ENV=windows ARCH=i686
group: deprecated-2017Q4
services:
- docker
- stage: "Stage 1"
if: type IN (push, api, cron)
env: JOB=toxcore ENV=windows ARCH=x86_64
group: deprecated-2017Q4
services:
- docker
apt:
packages:
- libconfig-dev # For tox-bootstrapd.
- libopus-dev # For toxav.
- libvpx-dev # For toxav.
install: .travis/$JOB install
script: .travis/$JOB script
- 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
env: JOB=cmake-win32
services: [docker]
install: .travis/$JOB install
script: .travis/$JOB script
- 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
env: JOB=cmake-win64
services: [docker]
install: .travis/$JOB install
script: .travis/$JOB script
- stage: "Stage 1"
if: type IN (push, api, cron)
env: JOB=toxcore ENV=freebsd
dist: trusty
env: JOB=cmake-freebsd
sudo: required
install: other/travis/phase $JOB $ENV install stage1
script: other/travis/phase $JOB $ENV script stage1
install: .travis/$JOB-stage1 install
script: .travis/$JOB-stage1 script
- stage: "Stage 1"
if: type IN (push, api, cron)
env: JOB=tox-bootstrapd-docker ENV=linux
services:
- docker
sudo: required
env: JOB=tox-bootstrapd-docker
services: [docker]
script: .travis/$JOB
- stage: "Stage 2"
if: type IN (push, api, cron)
env: JOB=toxcore ENV=freebsd
dist: trusty
env: JOB=cmake-freebsd
sudo: required
install: other/travis/phase $JOB $ENV install stage2
install: .travis/$JOB-stage2 install
script: .travis/$JOB-stage2 script
- stage: "Stage 2"
if: type IN (push, api, cron)
env: JOB=toxcore ENV=osx RUN_TESTS=true
env: JOB=cmake-osx
os: osx
install: .travis/$JOB install
script: .travis/$JOB script
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
52 changes: 52 additions & 0 deletions .travis/autotools-linux
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/sh

ACTION="$1"

set -eu

CACHEDIR="$HOME/cache"
NPROC=`nproc`

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"

add_ld_flag -Wl,-z,defs

# Make compilation error on a warning
add_flag -Werror

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
23 changes: 23 additions & 0 deletions .travis/cmake-freebsd-stage1
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh

ACTION="$1"

set -eu

. other/travis/env.sh
. other/travis/env-freebsd.sh

travis_install() {
. other/travis/freebsd-install
. other/travis/freebsd-install-stage1
}

travis_script() {
echo "Nothing to do here. Building happens in stage 2."
}

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

ACTION="$1"

set -eu

. other/travis/env.sh
. other/travis/env-freebsd.sh

travis_install() {
. other/travis/freebsd-install
. other/travis/freebsd-install-stage2
}

travis_script() {
. other/travis/toxcore-script
}

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

ACTION="$1"

set -eu

CACHEDIR="$HOME/cache"
NPROC=`nproc`
ASTYLE="$CACHEDIR/astyle/build/gcc/bin/astyle"

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"

add_ld_flag -Wl,-z,defs

# Make compilation error on a warning
add_flag -Werror

# 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

other/astyle/format-source . "$ASTYLE"
}

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

ACTION="$1"

set -eu

CACHEDIR="$HOME/cache"
NPROC=`sysctl -n hw.physicalcpu`

travis_install() {
# Workaround for bug in Homebrew where it only finds an old Ruby version.
brew update

brew install libsodium libvpx opus libconfig
}

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

add_ld_flag -undefined error

# Make compilation error on a warning
add_flag -Werror

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 \
-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
7 changes: 7 additions & 0 deletions .travis/cmake-win32
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

i686=true
x86_64=false
WINDOWS_ARCH=win32

. .travis/cmake-windows.sh
7 changes: 7 additions & 0 deletions .travis/cmake-win64
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

i686=false
x86_64=true
WINDOWS_ARCH=win64

. .travis/cmake-windows.sh
Loading

0 comments on commit fa46226

Please sign in to comment.