From 9b2b35aa2f5ed4807d291bed5409fd3134571af6 Mon Sep 17 00:00:00 2001 From: Chang Liu Date: Tue, 14 Mar 2023 12:46:56 -0400 Subject: [PATCH] Add test coverage report to CI --- .github/workflows/ci-workflow.yml | 27 ++++++++++++------- .github/workflows/lcov_exclude | 4 +++ CMakeLists.txt | 5 ++++ Makefile | 8 ++++++ scripts/dockerized-ci-tests-runner/Dockerfile | 2 +- 5 files changed, 35 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/lcov_exclude diff --git a/.github/workflows/ci-workflow.yml b/.github/workflows/ci-workflow.yml index e204afd171..a1a11372ac 100644 --- a/.github/workflows/ci-workflow.yml +++ b/.github/workflows/ci-workflow.yml @@ -19,16 +19,23 @@ jobs: - name: Ensure Python dependencies run: | pip install torch~=1.13 --extra-index-url https://download.pytorch.org/whl/cpu &&\ - pip install --user -r tools/python_api/requirements_dev.txt + pip install --user -r tools/python_api/requirements_dev.txt -f https://data.pyg.org/whl/torch-1.13.0+cpu.html - - name: Build - run: CC=gcc CXX=g++ make release NUM_THREADS=32 - - - name: Test - run: CC=gcc CXX=g++ make test NUM_THREADS=32 + - name: Test with coverage + run: CC=gcc CXX=g++ make lcov NUM_THREADS=32 - name: Python test - run: CC=gcc CXX=g++ make pytest NUM_THREADS=32 + run: CC=clang-14 CXX=clang++-14 make pytest NUM_THREADS=32 + + - name: Generate coverage report + run: | + lcov -c -d ./ --no-external -o cover.info &&\ + lcov --remove cover.info $(< .github/workflows/lcov_exclude) -o cover.info + + - name: Upload coverage report + uses: codecov/codecov-action@v3 + with: + file: cover.info gcc-build-test-with-asan: name: gcc build & test with asan @@ -40,7 +47,7 @@ jobs: - name: Ensure Python dependencies run: | pip install torch~=1.13 --extra-index-url https://download.pytorch.org/whl/cpu &&\ - pip install --user -r tools/python_api/requirements_dev.txt + pip install --user -r tools/python_api/requirements_dev.txt -f https://data.pyg.org/whl/torch-1.13.0+cpu.html - name: Build debug run: CC=gcc CXX=g++ make alldebug NUM_THREADS=32 @@ -70,7 +77,7 @@ jobs: - name: Ensure python dependencies run: | pip install torch~=1.13 --extra-index-url https://download.pytorch.org/whl/cpu &&\ - pip install --user -r tools/python_api/requirements_dev.txt + pip install --user -r tools/python_api/requirements_dev.txt -f https://data.pyg.org/whl/torch-1.13.0+cpu.html - name: Build run: CC=clang-14 CXX=clang++-14 make release NUM_THREADS=32 @@ -103,7 +110,7 @@ jobs: - name: Ensure Python dependencies run: | pip install torch~=1.13 --extra-index-url https://download.pytorch.org/whl/cpu &&\ - pip install --user -r tools/python_api/requirements_dev.txt + pip install --user -r tools/python_api/requirements_dev.txt -f https://data.pyg.org/whl/torch-1.13.0+cpu.html - name: Build run: make benchmark NUM_THREADS=30 diff --git a/.github/workflows/lcov_exclude b/.github/workflows/lcov_exclude new file mode 100644 index 0000000000..b9e0689697 --- /dev/null +++ b/.github/workflows/lcov_exclude @@ -0,0 +1,4 @@ +*/third_party/* +*/_deps/* +*/test/* +*/external/* diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ab81d817d..4ae71c3f76 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,11 @@ endif() option(BUILD_TESTS "Build C++ and Python tests." FALSE) option(BUILD_BENCHMARK "Build benchmarks." FALSE) +option(BUILD_LCOV "Build coverage report." FALSE) +if(${BUILD_LCOV}) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") +endif() + function(link_threads LIBRARY) if (CMAKE_VERSION VERSION_LESS "3.1") target_link_libraries(${LIBRARY} pthread) diff --git a/Makefile b/Makefile index f33c7ddd72..ead401346f 100644 --- a/Makefile +++ b/Makefile @@ -70,6 +70,14 @@ test: arrow cd $(ROOT_DIR)/build/release/test && \ ctest +lcov: arrow + mkdir -p build/release && \ + cd build/release && \ + cmake $(GENERATOR) $(FORCE_COLOR) $(SANITIZER_FLAG) -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=TRUE -DBUILD_LCOV=TRUE ../.. && \ + cmake --build . --config Release -- -j $(NUM_THREADS) + cd $(ROOT_DIR)/build/release/test && \ + ctest + pytest: arrow $(MAKE) release cd $(ROOT_DIR)/tools/python_api/test && \ diff --git a/scripts/dockerized-ci-tests-runner/Dockerfile b/scripts/dockerized-ci-tests-runner/Dockerfile index baf3bf0139..96f0bb115b 100644 --- a/scripts/dockerized-ci-tests-runner/Dockerfile +++ b/scripts/dockerized-ci-tests-runner/Dockerfile @@ -3,7 +3,7 @@ FROM ubuntu:22.04 ENV DEBIAN_FRONTEND=noninteractive # Install dependencies RUN apt-get update && apt-get install -y --no-install-recommends apt-utils -RUN apt-get update && apt-get install -y g++ gcc clang-14 python3-dev python3-pip python-is-python3 cmake nodejs jq curl apt-transport-https gnupg sudo git clang-format-11 ca-certificates lsb-release wget +RUN apt-get update && apt-get install -y g++ gcc clang-14 python3-dev python3-pip python-is-python3 cmake nodejs jq curl apt-transport-https gnupg sudo git clang-format-11 ca-certificates lsb-release wget lcov RUN useradd --create-home runner USER runner