Apache DataFusion SQL Query Engine
ARROW-2562: [CI] C++ and Rust code coverage using codecov.io
Antoine Pitrou18a29a91cbab
diff --git a/.travis.yml b/.travis.ymlindex b4ec6ff1aa..e91d7b166a 100644--- a/.travis.yml+++ b/.travis.yml@@ -52,6 +52,7 @@ matrix:- ARROW_TRAVIS_PLASMA=1- ARROW_TRAVIS_ORC=1- ARROW_TRAVIS_CLANG_FORMAT=1+ - ARROW_TRAVIS_COVERAGE=1- ARROW_TRAVIS_PYTHON_BENCHMARKS=1- ARROW_TRAVIS_PYTHON_DOCS=1- ARROW_BUILD_WARNING_LEVEL=CHECKIN@@ -68,10 +69,12 @@ matrix:# If either C++ or Python changed, we must install the C++ libraries- $TRAVIS_BUILD_DIR/ci/travis_before_script_cpp.shscript:- - if [ $ARROW_CI_CPP_AFFECTED == "1" ]; then $TRAVIS_BUILD_DIR/ci/travis_script_cpp.sh; fi+ # All test steps are required for accurate C++ coverage info+ - $TRAVIS_BUILD_DIR/ci/travis_script_cpp.sh- $TRAVIS_BUILD_DIR/ci/travis_build_parquet_cpp.sh- $TRAVIS_BUILD_DIR/ci/travis_script_python.sh 2.7- $TRAVIS_BUILD_DIR/ci/travis_script_python.sh 3.6+ - $TRAVIS_BUILD_DIR/ci/travis_upload_cpp_coverage.sh# [OS X] C++ & Python w/ XCode 6.4- compiler: clanglanguage: cpp@@ -178,6 +181,7 @@ matrix:- $TRAVIS_BUILD_DIR/ci/travis_before_script_c_glib.shscript:- $TRAVIS_BUILD_DIR/ci/travis_script_c_glib.sh+ # Rust- language: rustcache: cargorust: stable@@ -197,7 +201,11 @@ matrix:- $TRAVIS_BUILD_DIR/ci/travis_script_rust.shafter_success:- pushd ${TRAVIS_BUILD_DIR}/rust- - cargo coveralls --verbose+ # Run coverage for codecov.io+ - RUST_BACKTRACE=1 cargo coverage --verbose+ - bash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports"+ # Run coverage for coveralls.io+ #- cargo coveralls --verboseafter_failure:- COREFILE=$(find . -maxdepth 2 -name "core*" | head -n 1)diff --git a/ci/travis_before_script_cpp.sh b/ci/travis_before_script_cpp.shindex b9afbee786..379007d5bf 100755--- a/ci/travis_before_script_cpp.sh+++ b/ci/travis_before_script_cpp.sh@@ -17,7 +17,6 @@# specific language governing permissions and limitations# under the License.-set -exsource $TRAVIS_BUILD_DIR/ci/travis_env_common.sh@@ -83,6 +82,10 @@ if [ $ARROW_TRAVIS_VALGRIND == "1" ]; thenCMAKE_COMMON_FLAGS="$CMAKE_COMMON_FLAGS -DARROW_TEST_MEMCHECK=ON"fi+if [ $ARROW_TRAVIS_COVERAGE == "1" ]; then+ CMAKE_COMMON_FLAGS="$CMAKE_COMMON_FLAGS -DARROW_GENERATE_COVERAGE=ON"+fi+if [ $TRAVIS_OS_NAME == "linux" ]; thencmake $CMAKE_COMMON_FLAGS \$CMAKE_LINUX_FLAGS \diff --git a/ci/travis_env_common.sh b/ci/travis_env_common.shindex c8c19ed5b6..a4ae5bd271 100755--- a/ci/travis_env_common.sh+++ b/ci/travis_env_common.sh@@ -29,6 +29,10 @@ export ARROW_JS_DIR=${TRAVIS_BUILD_DIR}/jsexport ARROW_INTEGRATION_DIR=$TRAVIS_BUILD_DIR/integrationexport ARROW_RUST_DIR=${TRAVIS_BUILD_DIR}/rust+if [ $ARROW_TRAVIS_COVERAGE == "1" ]; then+ export ARROW_CPP_COVERAGE_FILE=${TRAVIS_BUILD_DIR}/coverage.info+fi+export CPP_BUILD_DIR=$TRAVIS_BUILD_DIR/cpp-buildexport ARROW_CPP_INSTALL=$TRAVIS_BUILD_DIR/cpp-installdiff --git a/ci/travis_install_linux.sh b/ci/travis_install_linux.shindex 74fde27741..b1e21ea8d6 100755--- a/ci/travis_install_linux.sh+++ b/ci/travis_install_linux.sh@@ -24,3 +24,7 @@ sudo apt-get install -y -q \if [ "$ARROW_TRAVIS_VALGRIND" == "1" ]; thensudo apt-get install -y -q valgrindfi++if [ $ARROW_TRAVIS_COVERAGE == "1" ]; then+ sudo apt-get install -y -q lcov+fidiff --git a/ci/travis_install_toolchain.sh b/ci/travis_install_toolchain.shindex 31076b2e73..a153d893dd 100755--- a/ci/travis_install_toolchain.sh+++ b/ci/travis_install_toolchain.sh@@ -23,7 +23,7 @@ source $TRAVIS_BUILD_DIR/ci/travis_install_conda.shif [ ! -e $CPP_TOOLCHAIN ]; then# Set up C++ toolchain from conda-forge packages for faster builds- conda create -y -q -p $CPP_TOOLCHAIN python=2.7 \+ conda create -y -q -p $CPP_TOOLCHAIN python=3.6 \nomkl \boost-cpp \libprotobuf \diff --git a/ci/travis_script_cpp.sh b/ci/travis_script_cpp.shindex 455a6766f9..02e58cd72c 100755--- a/ci/travis_script_cpp.sh+++ b/ci/travis_script_cpp.sh@@ -26,3 +26,10 @@ pushd $CPP_BUILD_DIRctest -j2 --output-on-failure -L unittestpopd++# Capture C++ coverage info (we wipe the build dir in travis_script_python.sh)+if [ $ARROW_TRAVIS_COVERAGE == "1" ]; then+ pushd $TRAVIS_BUILD_DIR+ lcov --quiet --directory . --capture --no-external --output-file $ARROW_CPP_COVERAGE_FILE+ popd+fidiff --git a/ci/travis_script_python.sh b/ci/travis_script_python.shindex 5177a6c622..aaca3fdba6 100755--- a/ci/travis_script_python.sh+++ b/ci/travis_script_python.sh@@ -52,15 +52,23 @@ conda install -y -q pip \# conda install -y -q pytorch torchvision -c soumith# fi-# Build C++ libraries+# Re-build C++ libraries with the right Python setupmkdir -p $ARROW_CPP_BUILD_DIRpushd $ARROW_CPP_BUILD_DIR# Clear out prior build filesrm -rf *+# XXX Can we simply reuse CMAKE_COMMON_FLAGS from travis_before_script_cpp.sh?+CMAKE_COMMON_FLAGS="-DARROW_EXTRA_ERROR_CONTEXT=ON"++if [ $ARROW_TRAVIS_COVERAGE == "1" ]; then+ CMAKE_COMMON_FLAGS="$CMAKE_COMMON_FLAGS -DARROW_GENERATE_COVERAGE=ON"+fi+cmake -GNinja \- -DARROW_BUILD_TESTS=off \+ $CMAKE_COMMON_FLAGS \+ -DARROW_BUILD_TESTS=on \-DARROW_BUILD_UTILITIES=off \-DARROW_PLASMA=on \-DARROW_PYTHON=on \@@ -74,6 +82,9 @@ ninja installpopd+# python-test isn't run by travis_script_cpp.sh, exercise it here+$ARROW_CPP_BUILD_DIR/$ARROW_BUILD_TYPE/python-test+# Other stuff pip installpushd $ARROW_PYTHON_DIR@@ -107,6 +118,17 @@ fiPYARROW_PATH=$CONDA_PREFIX/lib/python$PYTHON_VERSION/site-packages/pyarrowpython -m pytest -r sxX --durations=15 $PYARROW_PATH --parquet+# Capture C++ coverage info and combine with previous coverage file+if [ $ARROW_TRAVIS_COVERAGE == "1" ]; then+ pushd $TRAVIS_BUILD_DIR+ lcov --quiet --directory . --capture --no-external --output-file coverage-python-tests.info+ lcov --add-tracefile coverage-python-tests.info \+ --add-tracefile $ARROW_CPP_COVERAGE_FILE \+ --output-file $ARROW_CPP_COVERAGE_FILE+ rm coverage-python-tests.info+ popd+fi+if [ "$ARROW_TRAVIS_PYTHON_DOCS" == "1" ] && [ "$PYTHON_VERSION" == "3.6" ]; then# Build documentation onceconda install -y -q \diff --git a/ci/travis_upload_cpp_coverage.sh b/ci/travis_upload_cpp_coverage.shnew file mode 100755index 0000000000..20b7e1bdd0--- /dev/null+++ b/ci/travis_upload_cpp_coverage.sh@@ -0,0 +1,31 @@+#!/usr/bin/env bash++# Licensed to the Apache Software Foundation (ASF) under one+# or more contributor license agreements. See the NOTICE file+# distributed with this work for additional information+# regarding copyright ownership. The ASF licenses this file+# to you under the Apache License, Version 2.0 (the+# "License"); you may not use this file except in compliance+# with the License. You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing,+# software distributed under the License is distributed on an+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY+# KIND, either express or implied. See the License for the+# specific language governing permissions and limitations+# under the License.++set -e++source $TRAVIS_BUILD_DIR/ci/travis_env_common.sh++pushd $TRAVIS_BUILD_DIR++# Display summary+lcov --list $ARROW_CPP_COVERAGE_FILE+# Upload report to CodeCov+bash <(curl -s https://codecov.io/bash) || echo "Codecov did not collect coverage reports"++popd