Skip to content

Commit

Permalink
Merge pull request #1378 from kuzudb/code-cov
Browse files Browse the repository at this point in the history
Add test coverage report to CI
  • Loading branch information
mewim committed Mar 14, 2023
2 parents 3ec4124 + 9b2b35a commit 5c26f28
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 11 deletions.
27 changes: 17 additions & 10 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/lcov_exclude
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*/third_party/*
*/_deps/*
*/test/*
*/external/*
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 && \
Expand Down
2 changes: 1 addition & 1 deletion scripts/dockerized-ci-tests-runner/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5c26f28

Please sign in to comment.