Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable coveralls . #1596

Closed
wants to merge 14 commits into from
Closed
11 changes: 10 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
run: mkdir -p build
- name: CMake with gcc
if: matrix.compiler == 'gcc'
run: cd build && cmake ..
run: cd build && cmake -DENABLE_COVERAGE=ON ..
- name: CMake with clang
if: matrix.compiler == 'clang'
run: cd build && cmake -DCMAKE_CXX_COMPILER=clang++-8 -DCMAKE_C_COMPILER=clang-8 -DENABLE_ASAN=on -DNEBULA_CLANG_USE_GCC_TOOLCHAIN=/opt/vesoft/toolset/gcc/7.5.0 ..
Expand All @@ -48,3 +48,12 @@ jobs:
- name: CTest with single thread
timeout-minutes: 40
run: cd build && ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer ASAN_OPTIONS=fast_unwind_on_malloc=0 ctest --timeout 300 --output-on-failure
- name: Coverage Report
if: success() && matrix.compiler == 'gcc' && matrix.tag == 'centos7'
run: cd build && lcov --gcov-tool $GCOV --capture --directory . --output-file coverage.info
- name: Coveralls
if: success() && matrix.compiler == 'gcc' && matrix.tag == 'centos7'
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: build/coverage.info
15 changes: 14 additions & 1 deletion .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
[ -d build/ ] && rm -rf build/* || mkdir -p build
- name: CMake with gcc
if: matrix.compiler == 'gcc' && steps.ignore_docs.outputs.num_source_files != 0
run: cd build && cmake ..
run: cd build && cmake -DENABLE_COVERAGE=ON ..
- name: CMake with clang
if: matrix.compiler == 'clang' && steps.ignore_docs.outputs.num_source_files != 0
run: cd build && cmake -DCMAKE_CXX_COMPILER=clang++-8 -DCMAKE_C_COMPILER=clang-8 -DENABLE_ASAN=on -DNEBULA_CLANG_USE_GCC_TOOLCHAIN=/opt/vesoft/toolset/gcc/7.5.0 ..
Expand All @@ -70,6 +70,19 @@ jobs:
if: failure() && steps.ignore_docs.outputs.num_source_files != 0
timeout-minutes: 30
run: cd build && ASAN_SYMBOLIZER_PATH=/usr/bin/llvm-symbolizer ASAN_OPTIONS=fast_unwind_on_malloc=0 ctest --timeout 300 --output-on-failure --rerun-failed
- name: Coverage Report
if: success() && matrix.compiler == 'gcc' && matrix.tag == 'centos7'
run: |
cd build && lcov --gcov-tool $GCOV --capture --directory . --output-file coverage.info
stat coverage.info
- name: Coveralls
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we see the difference result of coverage between PR and master?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we see the difference result of coverage between PR and master?

Yes, like this https://github.com/Tencent/rapidjson

if: success() && matrix.compiler == 'gcc' && matrix.tag == 'centos7'
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: build/coverage.info
env:
NODE_OPTIONS: --max-old-space-size=20480
- name: Cleanup
if: always()
run: rm -rf build
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ option(ENABLE_NATIVE "Whether to build native client" OFF)
option(ENABLE_CCACHE "Whether to use ccache to speed up compiling" ON)
option(ENABLE_ASAN "Whether to turn AddressSanitizer ON or OFF" OFF)
option(ENABLE_TESTING "Whether to turn unit test ON or OFF" ON)
option(ENABLE_COVERAGE "Enable testing coverage reporting" OFF)
option(ENABLE_UBSAN "Whether to turn Undefined Behavior Sanitizer ON or OFF" OFF)
option(ENABLE_FUZZ_TEST "Whether to turn Fuzz Test ON or OFF" OFF)
option(ENABLE_WERROR "Whether to error on warnings" ON)
Expand All @@ -66,6 +67,13 @@ if (!CMAKE_CXX_COMPILER)
message(FATAL_ERROR "No C++ compiler found")
endif()

if(ENABLE_TESTING AND ENABLE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
# Add required flags (GCC & LLVM/Clang)
add_compile_options(
--coverage # sets all required flags
)
endif()

set(CMAKE_CXX_STANDARD 14) # specify the C++ standard
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
Expand Down Expand Up @@ -453,6 +461,12 @@ else()
set(GETTIME_LIB)
endif()

if (ENABLE_TESTING AND ENABLE_COVERAGE)
set(COVERAGE --coverage)
else()
set(COVERAGE)
endif()

# A wrapper for target_link_libraries()
macro(nebula_link_libraries target)
target_link_libraries(
Expand All @@ -477,6 +491,7 @@ macro(nebula_link_libraries target)
dl
${GETTIME_LIB}
-pthread
${COVERAGE}
)
endmacro(nebula_link_libraries)

Expand Down
2 changes: 1 addition & 1 deletion src/common/stats/StatsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ StatusOr<StatsManager::VT> StatsManager::readValue(folly::StringPiece metricName
}

TimeRange range;
if ( parts[2] == "5") {
if (parts[2] == "5") {
range = TimeRange::FIVE_SECONDS;
} else if (parts[2] == "60") {
range = TimeRange::ONE_MINUTE;
Expand Down
4 changes: 2 additions & 2 deletions src/storage/BaseProcessor.inl
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ BaseProcessor<RESP>::collectIndexValues(RowReader* reader,
}
return values;
}


template <typename RESP>
void BaseProcessor<RESP>::collectProps(RowReader* reader,
Expand Down Expand Up @@ -161,7 +161,7 @@ void BaseProcessor<RESP>::collectProps(RowReader* reader,
}
}
}


} // namespace storage
} // namespace nebula