Skip to content

Commit 715bcc0

Browse files
committed
[FOLD] Add Travis install scripts
1 parent 65abd05 commit 715bcc0

7 files changed

Lines changed: 395 additions & 2 deletions

File tree

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ cache:
6464
- cmake
6565

6666
before_install:
67-
- ( cd extras/rippled && bin/ci/ubuntu/install-dependencies.sh ../.. )
67+
- ( ./bin/ci/ubuntu/install-dependencies.sh . )
6868

6969
script:
70-
- extras/rippled/bin/ci/ubuntu/build-and-test.sh
70+
- bin/ci/ubuntu/build-and-test.sh
7171

7272
notifications:
7373
email:

bin/ci/ubuntu/build-and-test.sh

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/bin/bash -u
2+
# We use set -e and bash with -u to bail on first non zero exit code of any
3+
# processes launched or upon any unbound variable.
4+
# We use set -x to print commands before running them to help with
5+
# debugging.
6+
set -ex
7+
__dirname=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
8+
echo "using CC: $CC"
9+
echo "using TARGET: $TARGET"
10+
11+
# Ensure APP defaults to rippled if it's not set.
12+
: ${APP:=rippled}
13+
if [[ ${BUILD:-scons} == "cmake" ]]; then
14+
echo "cmake building ${APP}"
15+
CMAKE_TARGET=$CC.$TARGET
16+
if [[ ${CI:-} == true ]]; then
17+
CMAKE_TARGET=$CMAKE_TARGET.ci
18+
fi
19+
mkdir -p "build/${CMAKE_TARGET}"
20+
pushd "build/${CMAKE_TARGET}"
21+
cmake ../.. -Dtarget=$CMAKE_TARGET
22+
cmake --build . -- -j${NUM_PROCESSORS:-2}
23+
popd
24+
export APP_PATH="$PWD/build/${CMAKE_TARGET}/${APP}"
25+
echo "using APP_PATH: $APP_PATH"
26+
27+
else
28+
export APP_PATH="$PWD/build/$CC.$TARGET/${APP}"
29+
echo "using APP_PATH: $APP_PATH"
30+
# Make sure vcxproj is up to date
31+
scons vcxproj
32+
git diff --exit-code
33+
# $CC will be either `clang` or `gcc`
34+
# http://docs.travis-ci.com/user/migrating-from-legacy/?utm_source=legacy-notice&utm_medium=banner&utm_campaign=legacy-upgrade
35+
# indicates that 2 cores are available to containers.
36+
scons -j${NUM_PROCESSORS:-2} $CC.$TARGET
37+
fi
38+
# We can be sure we're using the build/$CC.$TARGET variant
39+
# (-f so never err)
40+
rm -f build/${APP}
41+
42+
# See what we've actually built
43+
ldd $APP_PATH
44+
45+
if [[ ${APP} == "rippled" ]]; then
46+
export APP_ARGS="--unittest --quiet --unittest-log"
47+
# Only report on src/ripple files
48+
export LCOV_FILES="*/src/ripple/*"
49+
# Nothing to explicitly exclude
50+
export LCOV_EXCLUDE_FILES="LCOV_NO_EXCLUDE"
51+
else
52+
: ${APP_ARGS:=}
53+
: ${LCOV_FILES:="*/src/*"}
54+
# Don't exclude anything
55+
: ${LCOV_EXCLUDE_FILES:="LCOV_NO_EXCLUDE"}
56+
fi
57+
58+
if [[ $TARGET == "coverage" ]]; then
59+
export PATH=$PATH:$LCOV_ROOT/usr/bin
60+
61+
# Create baseline coverage data file
62+
lcov --no-external -c -i -d . -o baseline.info
63+
fi
64+
65+
if [[ ${TARGET} == debug ]]; then
66+
# Execute unit tests under gdb, printing a call stack
67+
# if we get a crash.
68+
$GDB_ROOT/bin/gdb -return-child-result -quiet -batch \
69+
-ex "set env MALLOC_CHECK_=3" \
70+
-ex "set print thread-events off" \
71+
-ex run \
72+
-ex "thread apply all backtrace full" \
73+
-ex "quit" \
74+
--args $APP_PATH $APP_ARGS
75+
else
76+
$APP_PATH $APP_ARGS
77+
fi
78+
79+
if [[ $TARGET == "coverage" ]]; then
80+
# Create test coverage data file
81+
lcov --no-external -c -d . -o tests.info
82+
83+
# Combine baseline and test coverage data
84+
lcov -a baseline.info -a tests.info -o lcov-all.info
85+
86+
# Included files
87+
lcov -e "lcov-all.info" "${LCOV_FILES}" -o lcov.pre.info
88+
89+
# Excluded files
90+
lcov --remove lcov.pre.info "${LCOV_EXCLUDE_FILES}" -o lcov.info
91+
92+
# Push the results (lcov.info) to codecov
93+
codecov -X gcov # don't even try and look for .gcov files ;)
94+
fi
95+
96+
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/bin/bash -u
2+
# Exit if anything fails. Echo commands to aid debugging.
3+
set -ex
4+
5+
# Target working dir - defaults to current dir.
6+
# Can be set from caller, or in the first parameter
7+
TWD=$( cd ${TWD:-${1:-${PWD:-$( pwd )}}}; pwd )
8+
echo "Target path is: $TWD"
9+
# Override gcc version to $GCC_VER.
10+
# Put an appropriate symlink at the front of the path.
11+
mkdir -v $HOME/bin
12+
for g in gcc g++ gcov gcc-ar gcc-nm gcc-ranlib
13+
do
14+
test -x $( type -p ${g}-$GCC_VER )
15+
ln -sv $(type -p ${g}-$GCC_VER) $HOME/bin/${g}
16+
done
17+
18+
if [[ -n ${CLANG_VER:-} ]]; then
19+
# There are cases where the directory exists, but the exe is not available.
20+
# Use this workaround for now.
21+
if [[ ! -x ${TWD}/llvm-${LLVM_VERSION}/bin/llvm-config && -d ${TWD}/llvm-${LLVM_VERSION} ]]; then
22+
rm -fr ${TWD}/llvm-${LLVM_VERSION}
23+
fi
24+
if [[ ! -d ${TWD}/llvm-${LLVM_VERSION} ]]; then
25+
mkdir ${TWD}/llvm-${LLVM_VERSION}
26+
LLVM_URL="http://llvm.org/releases/${LLVM_VERSION}/clang+llvm-${LLVM_VERSION}-x86_64-linux-gnu-ubuntu-14.04.tar.xz"
27+
wget -O - ${LLVM_URL} | tar -Jxvf - --strip 1 -C ${TWD}/llvm-${LLVM_VERSION}
28+
fi
29+
${TWD}/llvm-${LLVM_VERSION}/bin/llvm-config --version;
30+
export LLVM_CONFIG="${TWD}/llvm-${LLVM_VERSION}/bin/llvm-config";
31+
fi
32+
33+
if [[ ${BUILD:-} == cmake ]]; then
34+
# There are cases where the directory exists, but the exe is not available.
35+
# Use this workaround for now.
36+
if [[ ! -x ${TWD}/cmake/bin/cmake && -d ${TWD}/cmake ]]; then
37+
rm -fr ${TWD}/cmake
38+
fi
39+
if [[ ! -d ${TWD}/cmake ]]; then
40+
CMAKE_URL="https://www.cmake.org/files/v3.6/cmake-3.6.1-Linux-x86_64.tar.gz"
41+
wget --version
42+
# wget version 1.13.4 thinks this certificate is invalid, even though it's fine.
43+
# "ERROR: no certificate subject alternative name matches"
44+
# See also: https://github.com/travis-ci/travis-ci/issues/5059
45+
mkdir ${TWD}/cmake &&
46+
wget -O - --no-check-certificate ${CMAKE_URL} | tar --strip-components=1 -xz -C ${TWD}/cmake
47+
cmake --version
48+
fi
49+
fi
50+
51+
# What versions are we ACTUALLY running?
52+
if [ -x $HOME/bin/g++ ]; then
53+
$HOME/bin/g++ -v
54+
fi
55+
56+
pip install --user requests==2.13.0
57+
pip install --user https://github.com/codecov/codecov-python/archive/master.zip
58+
59+
bash bin/sh/install-boost.sh
60+
61+
# Install lcov
62+
# Download the archive
63+
wget https://github.com/linux-test-project/lcov/releases/download/v1.12/lcov-1.12.tar.gz
64+
# Extract to ~/lcov-1.12
65+
tar xfvz lcov-1.12.tar.gz -C $HOME
66+
# Set install path
67+
mkdir -p $LCOV_ROOT
68+
cd $HOME/lcov-1.12 && make install PREFIX=$LCOV_ROOT
69+
70+
71+
if [[ ${TARGET} == debug && ! -x ${GDB_ROOT}/bin/gdb ]]; then
72+
pushd $HOME
73+
#install gdb
74+
wget https://ftp.gnu.org/gnu/gdb/gdb-8.0.tar.xz
75+
tar xf gdb-8.0.tar.xz
76+
pushd gdb-8.0
77+
./configure CFLAGS='-w -O2' CXXFLAGS='-std=gnu++11 -g -O2 -w' --prefix=$GDB_ROOT
78+
make -j2
79+
make install
80+
popd
81+
popd
82+
fi
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
if "%build%" == "scons" (
2+
rem Installing pip will install setuptools/easy_install.
3+
python "%PIP_PATH%"
4+
5+
rem Pip has some problems installing scons on windows so we use easy install.
6+
rem - easy_install scons
7+
rem Workaround
8+
easy_install https://pypi.python.org/packages/source/S/SCons/scons-2.5.0.tar.gz#md5=bda5530a70a41a7831d83c8b191c021e
9+
10+
rem Scons has problems with parallel builds on windows without pywin32.
11+
easy_install "%PYWIN32_PATH%"
12+
rem (easy_install can do headless installs of .exe wizards)
13+
)
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#!/bin/bash -u
2+
# We use set -e and bash with -u to bail on first non zero exit code of any
3+
# processes launched or upon any unbound variable.
4+
# We use set -x to print commands before running them to help with
5+
# debugging.
6+
set -ex
7+
__dirname=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
8+
echo "using CC: $CC"
9+
echo "using TARGET: $TARGET"
10+
11+
# Ensure APP defaults to rippled if it's not set.
12+
: ${APP:=rippled}
13+
if [[ ${BUILD:-scons} == "cmake" ]]; then
14+
echo "cmake building ${APP}"
15+
CMAKE_TARGET=$CC.$TARGET
16+
if [[ ${CI:-} == true ]]; then
17+
CMAKE_TARGET=$CMAKE_TARGET.ci
18+
fi
19+
mkdir -p "build/${CMAKE_TARGET}"
20+
pushd "build/${CMAKE_TARGET}"
21+
cmake ../.. -Dtarget=$CMAKE_TARGET
22+
cmake --build . -- -j${NUM_PROCESSORS:-2}
23+
popd
24+
export APP_PATH="$PWD/build/${CMAKE_TARGET}/${APP}"
25+
echo "using APP_PATH: $APP_PATH"
26+
27+
else
28+
export APP_PATH="$PWD/build/$CC.$TARGET/${APP}"
29+
echo "using APP_PATH: $APP_PATH"
30+
# Make sure vcxproj is up to date
31+
scons vcxproj
32+
git diff --exit-code
33+
# $CC will be either `clang` or `gcc`
34+
# http://docs.travis-ci.com/user/migrating-from-legacy/?utm_source=legacy-notice&utm_medium=banner&utm_campaign=legacy-upgrade
35+
# indicates that 2 cores are available to containers.
36+
scons -j${NUM_PROCESSORS:-2} $CC.$TARGET
37+
fi
38+
# We can be sure we're using the build/$CC.$TARGET variant
39+
# (-f so never err)
40+
rm -f build/${APP}
41+
42+
# See what we've actually built
43+
ldd $APP_PATH
44+
45+
if [[ ${APP} == "rippled" ]]; then
46+
export APP_ARGS="--unittest --quiet --unittest-log"
47+
# Only report on src/ripple files
48+
export LCOV_FILES="*/src/ripple/*"
49+
# Nothing to explicitly exclude
50+
export LCOV_EXCLUDE_FILES="LCOV_NO_EXCLUDE"
51+
else
52+
: ${APP_ARGS:=}
53+
: ${LCOV_FILES:="*/src/*"}
54+
# Don't exclude anything
55+
: ${LCOV_EXCLUDE_FILES:="LCOV_NO_EXCLUDE"}
56+
fi
57+
58+
if [[ $TARGET == "coverage" ]]; then
59+
export PATH=$PATH:$LCOV_ROOT/usr/bin
60+
61+
# Create baseline coverage data file
62+
lcov --no-external -c -i -d . -o baseline.info
63+
fi
64+
65+
if [[ ${TARGET} == debug ]]; then
66+
# Execute unit tests under gdb, printing a call stack
67+
# if we get a crash.
68+
$GDB_ROOT/bin/gdb -return-child-result -quiet -batch \
69+
-ex "set env MALLOC_CHECK_=3" \
70+
-ex "set print thread-events off" \
71+
-ex run \
72+
-ex "thread apply all backtrace full" \
73+
-ex "quit" \
74+
--args $APP_PATH $APP_ARGS
75+
else
76+
$APP_PATH $APP_ARGS
77+
fi
78+
79+
if [[ $TARGET == "coverage" ]]; then
80+
# Create test coverage data file
81+
lcov --no-external -c -d . -o tests.info
82+
83+
# Combine baseline and test coverage data
84+
lcov -a baseline.info -a tests.info -o lcov-all.info
85+
86+
# Included files
87+
lcov -e "lcov-all.info" "${LCOV_FILES}" -o lcov.pre.info
88+
89+
# Excluded files
90+
lcov --remove lcov.pre.info "${LCOV_EXCLUDE_FILES}" -o lcov.info
91+
92+
# Push the results (lcov.info) to codecov
93+
codecov -X gcov # don't even try and look for .gcov files ;)
94+
fi
95+
96+
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/bin/bash -u
2+
# Exit if anything fails. Echo commands to aid debugging.
3+
set -ex
4+
5+
# Target working dir - defaults to current dir.
6+
# Can be set from caller, or in the first parameter
7+
TWD=$( cd ${TWD:-${1:-${PWD:-$( pwd )}}}; pwd )
8+
echo "Target path is: $TWD"
9+
# Override gcc version to $GCC_VER.
10+
# Put an appropriate symlink at the front of the path.
11+
mkdir -v $HOME/bin
12+
for g in gcc g++ gcov gcc-ar gcc-nm gcc-ranlib
13+
do
14+
test -x $( type -p ${g}-$GCC_VER )
15+
ln -sv $(type -p ${g}-$GCC_VER) $HOME/bin/${g}
16+
done
17+
18+
if [[ -n ${CLANG_VER:-} ]]; then
19+
# There are cases where the directory exists, but the exe is not available.
20+
# Use this workaround for now.
21+
if [[ ! -x ${TWD}/llvm-${LLVM_VERSION}/bin/llvm-config && -d ${TWD}/llvm-${LLVM_VERSION} ]]; then
22+
rm -fr ${TWD}/llvm-${LLVM_VERSION}
23+
fi
24+
if [[ ! -d ${TWD}/llvm-${LLVM_VERSION} ]]; then
25+
mkdir ${TWD}/llvm-${LLVM_VERSION}
26+
LLVM_URL="http://llvm.org/releases/${LLVM_VERSION}/clang+llvm-${LLVM_VERSION}-x86_64-linux-gnu-ubuntu-14.04.tar.xz"
27+
wget -O - ${LLVM_URL} | tar -Jxvf - --strip 1 -C ${TWD}/llvm-${LLVM_VERSION}
28+
fi
29+
${TWD}/llvm-${LLVM_VERSION}/bin/llvm-config --version;
30+
export LLVM_CONFIG="${TWD}/llvm-${LLVM_VERSION}/bin/llvm-config";
31+
fi
32+
33+
if [[ ${BUILD:-} == cmake ]]; then
34+
# There are cases where the directory exists, but the exe is not available.
35+
# Use this workaround for now.
36+
if [[ ! -x ${TWD}/cmake/bin/cmake && -d ${TWD}/cmake ]]; then
37+
rm -fr ${TWD}/cmake
38+
fi
39+
if [[ ! -d ${TWD}/cmake ]]; then
40+
CMAKE_URL="https://www.cmake.org/files/v3.6/cmake-3.6.1-Linux-x86_64.tar.gz"
41+
wget --version
42+
# wget version 1.13.4 thinks this certificate is invalid, even though it's fine.
43+
# "ERROR: no certificate subject alternative name matches"
44+
# See also: https://github.com/travis-ci/travis-ci/issues/5059
45+
mkdir ${TWD}/cmake &&
46+
wget -O - --no-check-certificate ${CMAKE_URL} | tar --strip-components=1 -xz -C ${TWD}/cmake
47+
cmake --version
48+
fi
49+
fi
50+
51+
# What versions are we ACTUALLY running?
52+
if [ -x $HOME/bin/g++ ]; then
53+
$HOME/bin/g++ -v
54+
fi
55+
56+
pip install --user requests==2.13.0
57+
pip install --user https://github.com/codecov/codecov-python/archive/master.zip
58+
59+
bash bin/sh/install-boost.sh
60+
61+
# Install lcov
62+
# Download the archive
63+
wget https://github.com/linux-test-project/lcov/releases/download/v1.12/lcov-1.12.tar.gz
64+
# Extract to ~/lcov-1.12
65+
tar xfvz lcov-1.12.tar.gz -C $HOME
66+
# Set install path
67+
mkdir -p $LCOV_ROOT
68+
cd $HOME/lcov-1.12 && make install PREFIX=$LCOV_ROOT
69+
70+
71+
if [[ ${TARGET} == debug && ! -x ${GDB_ROOT}/bin/gdb ]]; then
72+
pushd $HOME
73+
#install gdb
74+
wget https://ftp.gnu.org/gnu/gdb/gdb-8.0.tar.xz
75+
tar xf gdb-8.0.tar.xz
76+
pushd gdb-8.0
77+
./configure CFLAGS='-w -O2' CXXFLAGS='-std=gnu++11 -g -O2 -w' --prefix=$GDB_ROOT
78+
make -j2
79+
make install
80+
popd
81+
popd
82+
fi

0 commit comments

Comments
 (0)