Unverified Commit b552d16f authored by yiwu-arbug's avatar yiwu-arbug Committed by GitHub

Add code coverage CI (#7)

use `lcov` to generate code coverage report together with GCC build, and send result to codecov. Also some minor refactor to travis config.
Signed-off-by: 's avatarYi Wu <yiwu@pingcap.com>
parent 37298baa
...@@ -10,13 +10,13 @@ addons: ...@@ -10,13 +10,13 @@ addons:
sources: sources:
- ubuntu-toolchain-r-test - ubuntu-toolchain-r-test
packages: packages:
- g++-8 - g++-7
- libgflags-dev - libgflags-dev
- lcov
# For GCC build, we also report code coverage to codecov.
matrix: matrix:
include: include:
- compiler: clang
env: BUILD_TYPE="Debug"
- compiler: clang - compiler: clang
env: BUILD_TYPE="Release" env: BUILD_TYPE="Release"
- compiler: clang - compiler: clang
...@@ -25,23 +25,34 @@ matrix: ...@@ -25,23 +25,34 @@ matrix:
env: SANITIZER="TSAN" env: SANITIZER="TSAN"
- compiler: clang - compiler: clang
env: SANITIZER="UBSAN" env: SANITIZER="UBSAN"
- env: COMPILER=gcc8 - env: COMPILER=gcc7
install: install:
- git clone --depth=1 --branch=tikv-3.0 https://github.com/pingcap/rocksdb.git - git clone --depth=1 --branch=tikv-3.0 https://github.com/pingcap/rocksdb.git
- if [ "${COMPILER}" == gcc8 ]; then - if [ "${COMPILER}" == gcc7 ]; then
CC=gcc-8 && CXX=g++-8; CC=gcc-7;
CXX=g++-7;
COVERAGE_OPT="-DCODE_COVERAGE=ON";
fi fi
- if [ ! -z "${BUILD_TYPE}" ]; then - if [ ! -z "${BUILD_TYPE}" ]; then
BUILD_OPT="-DCMAKE_BUILD_TYPE=${BUILD_TYPE}"; BUILD_OPT="-DCMAKE_BUILD_TYPE=${BUILD_TYPE}";
else
BUILD_OPT="-DCMAKE_BUILD_TYPE=Debug";
fi fi
- if [ ! -z "${SANITIZER}" ]; then - if [ ! -z "${SANITIZER}" ]; then
SANITIZER_OPT="-DWITH_${SANITIZER}=ON" && TOOLS_OPT="-DWITH_TITAN_TOOLS=OFF"; SANITIZER_OPT="-DWITH_${SANITIZER}=ON";
TOOLS_OPT="-DWITH_TITAN_TOOLS=OFF";
fi fi
script: script:
- ${CXX} --version - cmake . -L -DROCKSDB_DIR=./rocksdb -DTRAVIS=ON ${BUILD_OPT} ${SANITIZER_OPT} ${TOOLS_OPT} ${COVERAGE_OPT}
- echo $BUILD_OPT - make -j4
- echo $SANITIZER_OPT - ctest -R titan
- echo $TOOLS_OPT
- cmake . -DROCKSDB_DIR=./rocksdb -DTRAVIS=ON ${BUILD_OPT} ${SANITIZER_OPT} ${TOOLS_OPT} && make -j4 && ctest -R titan after_success:
- if [ "${COMPILER}" == gcc7 ]; then
lcov --gcov-tool gcov-7 --directory . --capture --output-file coverage.info;
lcov --remove coverage.info '/usr/*' --output-file coverage.info;
lcov --list coverage.info;
bash <(curl -s https://codecov.io/bash) -f coverage.info || echo "Codecov did not collect coverage reports";
fi
...@@ -43,11 +43,17 @@ add_library(titan STATIC ${SOURCES}) ...@@ -43,11 +43,17 @@ add_library(titan STATIC ${SOURCES})
option(WITH_TITAN_TESTS "Build with tests." ON) option(WITH_TITAN_TESTS "Build with tests." ON)
option(WITH_TITAN_TOOLS "Build with tools." ON) option(WITH_TITAN_TOOLS "Build with tools." ON)
option(TRAVIS "Building in Travis." OFF) option(TRAVIS "Building in Travis." OFF)
option(CODE_COVERAGE "Generate code coverage report." OFF)
if (CMAKE_BUILD_TYPE STREQUAL "Release") if (CMAKE_BUILD_TYPE STREQUAL "Release")
set(WITH_TITAN_TESTS OFF) set(WITH_TITAN_TESTS OFF)
endif() endif()
if (CODE_COVERAGE)
target_compile_options(titan PRIVATE "--coverage")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
endif()
if (WITH_TITAN_TESTS OR WITH_TITAN_TOOLS) if (WITH_TITAN_TESTS OR WITH_TITAN_TOOLS)
add_subdirectory(${ROCKSDB_DIR} rocksdb EXCLUDE_FROM_ALL) add_subdirectory(${ROCKSDB_DIR} rocksdb EXCLUDE_FROM_ALL)
# -latomic is needed when building titandb_stress using clang. # -latomic is needed when building titandb_stress using clang.
......
[![Build Status](https://travis-ci.org/pingcap/titan.svg?branch=master)](https://travis-ci.org/pingcap/titan)
# Titan: A RocksDB Plugin to Reduce Write Amplification # Titan: A RocksDB Plugin to Reduce Write Amplification
[![Build Status](https://travis-ci.org/pingcap/titan.svg?branch=master)](https://travis-ci.org/pingcap/titan)
[![codecov](https://codecov.io/gh/pingcap/titan/branch/master/graph/badge.svg)](https://codecov.io/gh/pingcap/titan)
Titan is a RocksDB Plugin for key-value separation, inspired by Titan is a RocksDB Plugin for key-value separation, inspired by
[WiscKey](https://www.usenix.org/system/files/conference/fast16/fast16-papers-lu.pdf). [WiscKey](https://www.usenix.org/system/files/conference/fast16/fast16-papers-lu.pdf).
For introduction and design details, see our For introduction and design details, see our
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment