Add coverage tracking via codecov.io

Conflicts:
	.travis.yml
This commit is contained in:
Nicholas Dudfield
2015-08-17 11:26:15 +07:00
committed by Edward Hennis
parent 8df88238cd
commit f4fe55caff
6 changed files with 98 additions and 52 deletions

5
.gitignore vendored
View File

@@ -24,6 +24,11 @@ bin/rippled
Debug/*.*
Release/*.*
# Ignore coverage files.
*.gcno
*.gcda
*.gcov
# Ignore locally installed node_modules
/node_modules

View File

@@ -19,12 +19,21 @@ env:
# Env vars are not translated there.
- GCC_VER=4.8
matrix:
- TARGET=coverage
- TARGET=debug
- TARGET=debug.nounity
# We can specify any combination of builds here, for example, to
# include release builds, too, uncomment the following lines.
#- TARGET=release
#- TARGET=release.nounity
matrix:
exclude:
# Because gcov won't work (easily) with clang
- env: TARGET=coverage
compiler: clang
# Because coverage target is basically debug + --coverage flags
- env: TARGET=debug
compiler: gcc
addons:
apt:
@@ -34,6 +43,7 @@ addons:
- python-software-properties
# See also GCC_VER.
- g++-4.8
- gcc-4.8
- protobuf-compiler
- libprotobuf-dev
- libssl-dev
@@ -48,55 +58,10 @@ cache:
- $BOOST_ROOT
before_install:
# Override gcc version to $GCC_VER.
# Put an appropriate symlink at the front of the path.
- mkdir -v $HOME/bin
- test -x $( type -p gcc-$GCC_VER )
- ln -sv $(type -p gcc-$GCC_VER) $HOME/bin/gcc
- test -x $( type -p g++-$GCC_VER )
- ln -sv $(type -p g++-$GCC_VER) $HOME/bin/g++
- export PATH=$PWD/bin:$PATH
# What versions are we ACTUALLY running?
- g++ -v
- clang -v
# Avoid `spurious errors` caused by ~/.npm permission issues
# Does it already exist? Who owns? What permissions?
- ls -lah ~/.npm || mkdir ~/.npm
# Make sure we own it
- chown -Rc $USER ~/.npm
- bash bin/sh/install-boost.sh
- bin/ci/ubuntu/install-dependencies.sh
script:
# Set so any failing command will abort the build
- set -e
# Make sure vcxproj is up to date
- scons vcxproj
- git diff --exit-code
# $CC will be either `clang` or `gcc`
# http://docs.travis-ci.com/user/migrating-from-legacy/?utm_source=legacy-notice&utm_medium=banner&utm_campaign=legacy-upgrade
# indicates that 2 cores are available to containers.
- scons -j2 $CC.$TARGET
# We can be sure we're using the build/$CC.$TARGET variant (-f so never err)
- rm -f build/rippled
- export RIPPLED_PATH="$PWD/build/$CC.$TARGET/rippled"
# See what we've actually built
- ldd $RIPPLED_PATH
# Run unittests (under gdb)
- | # create gdb script
echo "set env MALLOC_CHECK_=3" > script.gdb
echo "run" >> script.gdb
echo "backtrace full" >> script.gdb
# gdb --help
- cat script.gdb | gdb --ex 'set print thread-events off' --return-child-result --args $RIPPLED_PATH --unittest
- npm install
# Use build/(gcc|clang).$TARGET/rippled
- |
echo "exports.default_server_config = {\"rippled_path\" : \"$RIPPLED_PATH\"};" > test/config.js
# Run integration tests
- npm test
- bin/ci/ubuntu/build-and-test.sh
notifications:
email:

View File

@@ -15,11 +15,13 @@
clang All clang variants
clang.debug clang debug variant
clang.coverage clang coverage variant
clang.release clang release variant
clang.profile clang profile variant
gcc All gcc variants
gcc.debug gcc debug variant
gcc.coverage gcc coverage variant
gcc.release gcc release variant
gcc.profile gcc profile variant
@@ -250,6 +252,9 @@ def print_coms(target, source, env):
# TODO Add 'PROTOCCOM' to this list and make it work
Beast.print_coms(['CXXCOM', 'CCCOM', 'LINKCOM'], env)
def is_debug_variant(variant):
return variant in ('debug', 'coverage')
#-------------------------------------------------------------------------------
# Set construction variables for the base environment
@@ -311,7 +316,7 @@ def config_base(env):
# Set toolchain and variant specific construction variables
def config_env(toolchain, variant, env):
if variant == 'debug':
if is_debug_variant(variant):
env.Append(CPPDEFINES=['DEBUG', '_DEBUG'])
elif variant == 'release' or variant == 'profile':
@@ -416,6 +421,12 @@ def config_env(toolchain, variant, env):
'-fno-strict-aliasing'
])
if variant == 'coverage':
env.Append(CXXFLAGS=[
'-fprofile-arcs', '-ftest-coverage'])
env.Append(LINKFLAGS=[
'-fprofile-arcs', '-ftest-coverage'])
if toolchain == 'clang':
if Beast.system.osx:
env.Replace(CC='clang', CXX='clang++', LINK='clang++')
@@ -443,7 +454,7 @@ def config_env(toolchain, variant, env):
# If we are in debug mode, use GCC-specific functionality to add
# extra error checking into the code (e.g. std::vector will throw
# for out-of-bounds conditions)
if variant == 'debug':
if is_debug_variant(variant):
env.Append(CPPDEFINES={
'_FORTIFY_SOURCE': 2
})
@@ -562,7 +573,7 @@ base.Decider('MD5-timestamp')
set_implicit_cache()
# Configure the toolchains, variants, default toolchain, and default target
variants = ['debug', 'release', 'profile']
variants = ['debug', 'coverage', 'release', 'profile']
all_toolchains = ['clang', 'gcc', 'msvc']
if Beast.system.osx:
toolchains = ['clang']
@@ -684,7 +695,7 @@ def get_classic_sources(toolchain):
append_sources(result, *list_sources('src/ripple/shamap', '.cpp'))
append_sources(result, *list_sources('src/ripple/test', '.cpp'))
append_sources(result, *list_sources('src/ripple/unl', '.cpp'))
append_sources(
result,
*list_sources('src/ripple/nodestore', '.cpp'),
@@ -802,7 +813,7 @@ for tu_style in ['classic', 'unity']:
for variant in variants:
if not should_prepare_targets(tu_style, toolchain, variant):
continue
if variant == 'profile' and toolchain == 'msvc':
if variant in ['profile', 'coverage'] and toolchain == 'msvc':
continue
# Configure this variant's construction environment
env = base.Clone()

36
bin/ci/ubuntu/build-and-test.sh Executable file
View File

@@ -0,0 +1,36 @@
#!/bin/bash -u
# We use set -e and bash with -u to bail on first non zero exit code of any
# processes launched or upon any unbound variable
set -e
__dirname=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
echo "using CC: $CC"
echo "using TARGET: $TARGET"
export RIPPLED_PATH="$PWD/build/$CC.$TARGET/rippled"
echo "using RIPPLED_PATH: $RIPPLED_PATH"
# Make sure vcxproj is up to date
scons vcxproj
git diff --exit-code
# $CC will be either `clang` or `gcc`
# http://docs.travis-ci.com/user/migrating-from-legacy/?utm_source=legacy-notice&utm_medium=banner&utm_campaign=legacy-upgrade
# indicates that 2 cores are available to containers.
scons -j${NUM_PROCESSORS:-2} $CC.$TARGET
# We can be sure we're using the build/$CC.$TARGET variant
# (-f so never err)
rm -f build/rippled
# See what we've actually built
ldd $RIPPLED_PATH
if [[ $TARGET == "coverage" ]]; then
$RIPPLED_PATH --unittest
# We pass along -p to keep path segments so as to avoid collisions
codecov --gcov-args=-p --gcov-source-match='^src/(ripple|beast)'
else
# Run unittests (under gdb)
cat $__dirname/unittests.gdb | gdb \
--return-child-result \
--args $RIPPLED_PATH --unittest
fi
# Run NPM tests
npm install
npm test --rippled=$RIPPLED_PATH

View File

@@ -0,0 +1,25 @@
#!/bin/bash -u
# Exit if anything fails.
set -e
# Override gcc version to $GCC_VER.
# Put an appropriate symlink at the front of the path.
mkdir -v $HOME/bin
for g in gcc g++ gcov gcc-ar gcc-nm gcc-ranlib
do
test -x $( type -p ${g}-$GCC_VER )
ln -sv $(type -p ${g}-$GCC_VER) $HOME/bin/${g}
done
export PATH=$PWD/bin:$PATH
# What versions are we ACTUALLY running?
g++ -v
clang -v
# Avoid `spurious errors` caused by ~/.npm permission issues
# Does it already exist? Who owns? What permissions?
ls -lah ~/.npm || mkdir ~/.npm
# Make sure we own it
chown -Rc $USER ~/.npm
# We use this so we can filter the subtrees from our coverage report
pip install --user https://github.com/sublimator/codecov-python/zipball/source-match
bash bin/sh/install-boost.sh

View File

@@ -0,0 +1,4 @@
set env MALLOC_CHECK_=3
set print thread-events off
run
backtrace full