From a4bd2a540d549e9d199be969105ec4e7e2faf961 Mon Sep 17 00:00:00 2001 From: Wes McKinney Date: Mon, 23 Oct 2017 12:44:45 -0400 Subject: [PATCH 1/9] Port coveralls setup from parquet-cpp to Arrow C++, wire up with Travis CI Change-Id: I87fa01d80a15aa5a0876d0eda5db6733e94463db --- .travis.yml | 2 + README.md | 5 +++ ci/travis_before_script_cpp.sh | 4 ++ ci/upload_cpp_coverage.sh | 62 +++++++++++++++++++++++++++ cpp/CMakeLists.txt | 4 +- cpp/build-support/collect_coverage.py | 44 +++++++++++++++++++ 6 files changed, 119 insertions(+), 2 deletions(-) create mode 100755 ci/upload_cpp_coverage.sh create mode 100755 cpp/build-support/collect_coverage.py diff --git a/.travis.yml b/.travis.yml index c682a9d9db89..af9be19ea511 100644 --- a/.travis.yml +++ b/.travis.yml @@ -53,6 +53,7 @@ matrix: before_script: - export CC="gcc-4.9" - export CXX="g++-4.9" + - export ARROW_TRAVIS_COVERAGE=1 - export ARROW_TRAVIS_USE_TOOLCHAIN=1 - export ARROW_TRAVIS_VALGRIND=1 - export ARROW_TRAVIS_PLASMA=1 @@ -63,6 +64,7 @@ matrix: - $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/upload_cpp_coverage.sh - compiler: clang language: cpp osx_image: xcode6.4 diff --git a/README.md b/README.md index 9dda25de9117..3ef01498d107 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,11 @@ travis build status + + Code Coverage + + Coverage Status + diff --git a/ci/travis_before_script_cpp.sh b/ci/travis_before_script_cpp.sh index dbdcd33ed0d5..8dc0298047e8 100755 --- a/ci/travis_before_script_cpp.sh +++ b/ci/travis_before_script_cpp.sh @@ -89,6 +89,10 @@ if [ $ARROW_TRAVIS_VALGRIND == "1" ]; then CMAKE_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=1" +fi + if [ $TRAVIS_OS_NAME == "linux" ]; then cmake $CMAKE_COMMON_FLAGS \ $CMAKE_LINUX_FLAGS \ diff --git a/ci/upload_cpp_coverage.sh b/ci/upload_cpp_coverage.sh new file mode 100755 index 000000000000..89c722b2f416 --- /dev/null +++ b/ci/upload_cpp_coverage.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash + +# Licensed 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. See accompanying LICENSE file. + +set -e +set -x + +ROOT_DIR=$(cd "$(dirname "$BASH_SOURCE")"; pwd) + +source $TRAVIS_BUILD_DIR/ci/travis_env_common.sh + +# Current cpp-coveralls version 0.4 throws an error (PARQUET-1075) on Travis +# CI. Pin to last working version +pip install cpp_coveralls==0.3.12 + +mkdir coverage_artifacts +python $TRAVIS_BUILD_DIR/cpp/build-support/collect_coverage.py src/ coverage_artifacts + +cd coverage_artifacts + +ls -l + +coveralls --gcov $(which gcov-4.9) \ + --gcov-options '\-l' --root '' \ + --include $ARROW_CPP_BUILD_DIR \ + --exclude $ARROW_CPP_BUILD_DIR/boost_ep \ + --exclude $ARROW_CPP_BUILD_DIR/boost_ep-prefix \ + --exclude $ARROW_CPP_BUILD_DIR/brotli_ep \ + --exclude $ARROW_CPP_BUILD_DIR/brotli_ep-prefix \ + --exclude $ARROW_CPP_BUILD_DIR/flatbuffers_ep \ + --exclude $ARROW_CPP_BUILD_DIR/flatbuffers_ep-prefix \ + --exclude $ARROW_CPP_BUILD_DIR/gbenchmark_ep \ + --exclude $ARROW_CPP_BUILD_DIR/gbenchmark_ep-prefix \ + --exclude $ARROW_CPP_BUILD_DIR/gflags_ep \ + --exclude $ARROW_CPP_BUILD_DIR/gflags_ep-prefix \ + --exclude $ARROW_CPP_BUILD_DIR/googletest_ep \ + --exclude $ARROW_CPP_BUILD_DIR/googletest_ep-prefix \ + --exclude $ARROW_CPP_BUILD_DIR/grpc_ep \ + --exclude $ARROW_CPP_BUILD_DIR/grpc_ep-prefix \ + --exclude $ARROW_CPP_BUILD_DIR/jemalloc_ep \ + --exclude $ARROW_CPP_BUILD_DIR/jemalloc_ep-prefix \ + --exclude $ARROW_CPP_BUILD_DIR/lz4_ep \ + --exclude $ARROW_CPP_BUILD_DIR/lz4_ep-prefix \ + --exclude $ARROW_CPP_BUILD_DIR/rapidjson_ep \ + --exclude $ARROW_CPP_BUILD_DIR/rapidjson_ep-prefix \ + --exclude $ARROW_CPP_BUILD_DIR/snappy_ep \ + --exclude $ARROW_CPP_BUILD_DIR/snappy_ep-prefix \ + --exclude $ARROW_CPP_BUILD_DIR/zlib_ep \ + --exclude $ARROW_CPP_BUILD_DIR/zlib_ep-prefix \ + --exclude $ARROW_CPP_BUILD_DIR/zstd_ep \ + --exclude $ARROW_CPP_BUILD_DIR/zstd_ep-prefix \ + --exclude /usr diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index a159b1e5674b..abbafd855b31 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -267,8 +267,6 @@ include(ThirdpartyToolchain) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_COMMON_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARROW_CXXFLAGS}") -message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}") - if ("${COMPILER_FAMILY}" STREQUAL "clang") # Using Clang with ccache causes a bunch of spurious warnings that are # purportedly fixed in the next version of ccache. See the following for details: @@ -306,6 +304,8 @@ if ("${ARROW_GENERATE_COVERAGE}") endif() endif() +message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}") + # set compile output directory string (TOLOWER ${CMAKE_BUILD_TYPE} BUILD_SUBDIR_NAME) diff --git a/cpp/build-support/collect_coverage.py b/cpp/build-support/collect_coverage.py new file mode 100755 index 000000000000..1dab16022af0 --- /dev/null +++ b/cpp/build-support/collect_coverage.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python +# 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. + +import os +import os.path as osp +import shutil +import sys + + +def is_coverage_file(path): + return path.endswith('gcno') or path.endswith('gcda') + + +def copy_files(path, outpath='.'): + for root, dirs, files in os.walk(path): + for fname in files: + if not is_coverage_file(fname): + continue + relpath = osp.join(root, fname) + dstpath = '_'.join((root.replace(path, '').replace('/', '_'), + fname)) + + shutil.copy(relpath, osp.join(outpath, dstpath)) + + +if __name__ == '__main__': + path = sys.argv[1] + outpath = sys.argv[2] + copy_files(path, outpath) From abb5b42e6bf8f7251b80376a1a0d13291ffe725c Mon Sep 17 00:00:00 2001 From: Wes McKinney Date: Mon, 23 Oct 2017 12:46:15 -0400 Subject: [PATCH 2/9] Use absolute paths Change-Id: I56762ecc870a3813d9e78ad9d8df8f086f13371a --- ci/upload_cpp_coverage.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ci/upload_cpp_coverage.sh b/ci/upload_cpp_coverage.sh index 89c722b2f416..31ff36768387 100755 --- a/ci/upload_cpp_coverage.sh +++ b/ci/upload_cpp_coverage.sh @@ -24,7 +24,9 @@ source $TRAVIS_BUILD_DIR/ci/travis_env_common.sh pip install cpp_coveralls==0.3.12 mkdir coverage_artifacts -python $TRAVIS_BUILD_DIR/cpp/build-support/collect_coverage.py src/ coverage_artifacts +python $TRAVIS_BUILD_DIR/cpp/build-support/collect_coverage.py \ + $ARROW_CPP_BUILD_DIR/src/ \ + coverage_artifacts cd coverage_artifacts From 3695c5eab736d5046eeaad678687535937e0c904 Mon Sep 17 00:00:00 2001 From: Wes McKinney Date: Mon, 23 Oct 2017 12:47:26 -0400 Subject: [PATCH 3/9] Fix license header Change-Id: Ie64bc309a8f3feb92abd3d625b03b924f73b945c --- ci/upload_cpp_coverage.sh | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/ci/upload_cpp_coverage.sh b/ci/upload_cpp_coverage.sh index 31ff36768387..561c4c02edee 100755 --- a/ci/upload_cpp_coverage.sh +++ b/ci/upload_cpp_coverage.sh @@ -1,16 +1,19 @@ #!/usr/bin/env bash - -# Licensed 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 +# 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 # -# 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. # -# 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. See accompanying LICENSE file. set -e set -x From 1f4abc41b1f0a7151d6a61f8a02e07665b02240d Mon Sep 17 00:00:00 2001 From: Wes McKinney Date: Mon, 23 Oct 2017 15:09:33 -0400 Subject: [PATCH 4/9] Less restrictive search for coverage files, print output for debugging Change-Id: I83a7d836672b4ba36da25fd58437f1e7322f4211 --- ci/upload_cpp_coverage.sh | 2 +- cpp/build-support/collect_coverage.py | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ci/upload_cpp_coverage.sh b/ci/upload_cpp_coverage.sh index 561c4c02edee..8f8671352639 100755 --- a/ci/upload_cpp_coverage.sh +++ b/ci/upload_cpp_coverage.sh @@ -28,7 +28,7 @@ pip install cpp_coveralls==0.3.12 mkdir coverage_artifacts python $TRAVIS_BUILD_DIR/cpp/build-support/collect_coverage.py \ - $ARROW_CPP_BUILD_DIR/src/ \ + $ARROW_CPP_BUILD_DIR \ coverage_artifacts cd coverage_artifacts diff --git a/cpp/build-support/collect_coverage.py b/cpp/build-support/collect_coverage.py index 1dab16022af0..eb010c0ba441 100755 --- a/cpp/build-support/collect_coverage.py +++ b/cpp/build-support/collect_coverage.py @@ -28,6 +28,10 @@ def is_coverage_file(path): def copy_files(path, outpath='.'): for root, dirs, files in os.walk(path): + if len(files) > 0: + print(root) + print(dirs) + print(files) for fname in files: if not is_coverage_file(fname): continue From 08787bf4e88e1071356d6b369d8532339c3b9ec4 Mon Sep 17 00:00:00 2001 From: Wes McKinney Date: Mon, 23 Oct 2017 20:53:07 -0400 Subject: [PATCH 5/9] Upload coverage before Python builds Change-Id: If672a446b5fa67fd17831dfd19e5b1299e1479c0 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index af9be19ea511..01c368f17fe7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -61,10 +61,10 @@ matrix: - $TRAVIS_BUILD_DIR/ci/travis_before_script_cpp.sh script: - $TRAVIS_BUILD_DIR/ci/travis_script_cpp.sh + - $TRAVIS_BUILD_DIR/ci/upload_cpp_coverage.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/upload_cpp_coverage.sh - compiler: clang language: cpp osx_image: xcode6.4 From ab6ea7afa2d4079cd5fcc27f821a8c15bfde75f1 Mon Sep 17 00:00:00 2001 From: Wes McKinney Date: Mon, 23 Oct 2017 21:55:24 -0400 Subject: [PATCH 6/9] Include base cpp dir Change-Id: I5b6c40cc3d58bebb03b15d0f2aee91ab75458da1 --- ci/upload_cpp_coverage.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/upload_cpp_coverage.sh b/ci/upload_cpp_coverage.sh index 8f8671352639..09cd957b49e4 100755 --- a/ci/upload_cpp_coverage.sh +++ b/ci/upload_cpp_coverage.sh @@ -37,7 +37,7 @@ ls -l coveralls --gcov $(which gcov-4.9) \ --gcov-options '\-l' --root '' \ - --include $ARROW_CPP_BUILD_DIR \ + --include $ARROW_CPP_DIR \ --exclude $ARROW_CPP_BUILD_DIR/boost_ep \ --exclude $ARROW_CPP_BUILD_DIR/boost_ep-prefix \ --exclude $ARROW_CPP_BUILD_DIR/brotli_ep \ From fd554a919d5d927235e64450bbc3d7d9dd8f042f Mon Sep 17 00:00:00 2001 From: Wes McKinney Date: Mon, 23 Oct 2017 21:58:22 -0400 Subject: [PATCH 7/9] exclude CPP_TOOLCHAIN Change-Id: Ie96db8222bf62b596cd12ab94a8bea54d65446a7 --- ci/upload_cpp_coverage.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/upload_cpp_coverage.sh b/ci/upload_cpp_coverage.sh index 09cd957b49e4..121f77235503 100755 --- a/ci/upload_cpp_coverage.sh +++ b/ci/upload_cpp_coverage.sh @@ -38,6 +38,7 @@ ls -l coveralls --gcov $(which gcov-4.9) \ --gcov-options '\-l' --root '' \ --include $ARROW_CPP_DIR \ + --exclude $CPP_TOOLCHAIN \ --exclude $ARROW_CPP_BUILD_DIR/boost_ep \ --exclude $ARROW_CPP_BUILD_DIR/boost_ep-prefix \ --exclude $ARROW_CPP_BUILD_DIR/brotli_ep \ From b2b4a65b3b29789587c44649df0f3de9ba6fd02c Mon Sep 17 00:00:00 2001 From: Wes McKinney Date: Tue, 24 Oct 2017 09:13:16 -0400 Subject: [PATCH 8/9] Tweak coveralls call Change-Id: I060aac4f7518320caac48a712e790e8cb1968f1b --- ci/upload_cpp_coverage.sh | 61 ++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/ci/upload_cpp_coverage.sh b/ci/upload_cpp_coverage.sh index 121f77235503..65e83009bcc5 100755 --- a/ci/upload_cpp_coverage.sh +++ b/ci/upload_cpp_coverage.sh @@ -36,33 +36,34 @@ cd coverage_artifacts ls -l coveralls --gcov $(which gcov-4.9) \ - --gcov-options '\-l' --root '' \ - --include $ARROW_CPP_DIR \ - --exclude $CPP_TOOLCHAIN \ - --exclude $ARROW_CPP_BUILD_DIR/boost_ep \ - --exclude $ARROW_CPP_BUILD_DIR/boost_ep-prefix \ - --exclude $ARROW_CPP_BUILD_DIR/brotli_ep \ - --exclude $ARROW_CPP_BUILD_DIR/brotli_ep-prefix \ - --exclude $ARROW_CPP_BUILD_DIR/flatbuffers_ep \ - --exclude $ARROW_CPP_BUILD_DIR/flatbuffers_ep-prefix \ - --exclude $ARROW_CPP_BUILD_DIR/gbenchmark_ep \ - --exclude $ARROW_CPP_BUILD_DIR/gbenchmark_ep-prefix \ - --exclude $ARROW_CPP_BUILD_DIR/gflags_ep \ - --exclude $ARROW_CPP_BUILD_DIR/gflags_ep-prefix \ - --exclude $ARROW_CPP_BUILD_DIR/googletest_ep \ - --exclude $ARROW_CPP_BUILD_DIR/googletest_ep-prefix \ - --exclude $ARROW_CPP_BUILD_DIR/grpc_ep \ - --exclude $ARROW_CPP_BUILD_DIR/grpc_ep-prefix \ - --exclude $ARROW_CPP_BUILD_DIR/jemalloc_ep \ - --exclude $ARROW_CPP_BUILD_DIR/jemalloc_ep-prefix \ - --exclude $ARROW_CPP_BUILD_DIR/lz4_ep \ - --exclude $ARROW_CPP_BUILD_DIR/lz4_ep-prefix \ - --exclude $ARROW_CPP_BUILD_DIR/rapidjson_ep \ - --exclude $ARROW_CPP_BUILD_DIR/rapidjson_ep-prefix \ - --exclude $ARROW_CPP_BUILD_DIR/snappy_ep \ - --exclude $ARROW_CPP_BUILD_DIR/snappy_ep-prefix \ - --exclude $ARROW_CPP_BUILD_DIR/zlib_ep \ - --exclude $ARROW_CPP_BUILD_DIR/zlib_ep-prefix \ - --exclude $ARROW_CPP_BUILD_DIR/zstd_ep \ - --exclude $ARROW_CPP_BUILD_DIR/zstd_ep-prefix \ - --exclude /usr + --gcov-options '\-lp' \ + --root '' \ + --include $ARROW_CPP_DIR/src \ + --exclude $CPP_TOOLCHAIN \ + --exclude $ARROW_CPP_BUILD_DIR/boost_ep \ + --exclude $ARROW_CPP_BUILD_DIR/boost_ep-prefix \ + --exclude $ARROW_CPP_BUILD_DIR/brotli_ep \ + --exclude $ARROW_CPP_BUILD_DIR/brotli_ep-prefix \ + --exclude $ARROW_CPP_BUILD_DIR/flatbuffers_ep \ + --exclude $ARROW_CPP_BUILD_DIR/flatbuffers_ep-prefix \ + --exclude $ARROW_CPP_BUILD_DIR/gbenchmark_ep \ + --exclude $ARROW_CPP_BUILD_DIR/gbenchmark_ep-prefix \ + --exclude $ARROW_CPP_BUILD_DIR/gflags_ep \ + --exclude $ARROW_CPP_BUILD_DIR/gflags_ep-prefix \ + --exclude $ARROW_CPP_BUILD_DIR/googletest_ep \ + --exclude $ARROW_CPP_BUILD_DIR/googletest_ep-prefix \ + --exclude $ARROW_CPP_BUILD_DIR/grpc_ep \ + --exclude $ARROW_CPP_BUILD_DIR/grpc_ep-prefix \ + --exclude $ARROW_CPP_BUILD_DIR/jemalloc_ep \ + --exclude $ARROW_CPP_BUILD_DIR/jemalloc_ep-prefix \ + --exclude $ARROW_CPP_BUILD_DIR/lz4_ep \ + --exclude $ARROW_CPP_BUILD_DIR/lz4_ep-prefix \ + --exclude $ARROW_CPP_BUILD_DIR/rapidjson_ep \ + --exclude $ARROW_CPP_BUILD_DIR/rapidjson_ep-prefix \ + --exclude $ARROW_CPP_BUILD_DIR/snappy_ep \ + --exclude $ARROW_CPP_BUILD_DIR/snappy_ep-prefix \ + --exclude $ARROW_CPP_BUILD_DIR/zlib_ep \ + --exclude $ARROW_CPP_BUILD_DIR/zlib_ep-prefix \ + --exclude $ARROW_CPP_BUILD_DIR/zstd_ep \ + --exclude $ARROW_CPP_BUILD_DIR/zstd_ep-prefix \ + --exclude /usr From 3abcef50d34d7a62d810f71ccd4502493d202796 Mon Sep 17 00:00:00 2001 From: Wes McKinney Date: Wed, 25 Oct 2017 12:27:32 -0400 Subject: [PATCH 9/9] Revert changes from PARQUET-1038 Change-Id: I7e12dd0042b45eabbd0723e021c672573a6c99eb --- ci/upload_cpp_coverage.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ci/upload_cpp_coverage.sh b/ci/upload_cpp_coverage.sh index 65e83009bcc5..13d75f8e8b8f 100755 --- a/ci/upload_cpp_coverage.sh +++ b/ci/upload_cpp_coverage.sh @@ -35,10 +35,9 @@ cd coverage_artifacts ls -l -coveralls --gcov $(which gcov-4.9) \ - --gcov-options '\-lp' \ - --root '' \ - --include $ARROW_CPP_DIR/src \ +coveralls --gcov-options '\-l' \ + -r $ARROW_CPP_DIR \ + --include $ARROW_CPP_DIR \ --exclude $CPP_TOOLCHAIN \ --exclude $ARROW_CPP_BUILD_DIR/boost_ep \ --exclude $ARROW_CPP_BUILD_DIR/boost_ep-prefix \