Skip to content

Commit

Permalink
Feature/coverage action (vesoft-inc#1856)
Browse files Browse the repository at this point in the history
* Collect coverage in azure pipelines which not require token for codecov.io.

* Add azure-pipelines.yml

* Remove the library coverage information.

* Add coverage badge.

* Let action run coverage report.

* Try less avoid OOM.

* Revert "Try less avoid OOM."

This reverts commit 94fb05c.

* Limit the coverage building concurrency.

* Fix the logic.

Co-authored-by: dangleptr <37216992+dangleptr@users.noreply.github.com>
  • Loading branch information
Shylock-Hg and dangleptr authored Mar 9, 2020
1 parent c555d3e commit 11472d2
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 4 deletions.
18 changes: 17 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,13 @@ jobs:
cp ci/ccache.conf /tmp/ccache/ccache.conf
mkdir -p build
- name: CMake with gcc-9.2
if: matrix.compiler == 'gcc-9.2'
if: matrix.compiler == 'gcc-9.2' && matrix.os != 'centos7'
run: |
cmake -DCMAKE_BUILD_TYPE=Release -B build/
- name: CMake with Coverage
if: matrix.compiler == 'gcc-9.2' && matrix.os == 'centos7'
run: |
cmake -DENABLE_COVERAGE=ON -B build/
- name: CMake with clang-9
if: matrix.compiler == 'clang-9'
run: |
Expand Down Expand Up @@ -81,3 +85,15 @@ jobs:
--timeout 400 \
--rerun-failed \
--output-on-failure
- name: Testing Coverage Report
working-directory: build
if: success() && matrix.compiler == 'gcc-9.2' && matrix.os == 'centos7'
run: |
set -e
/usr/local/bin/lcov --version
/usr/local/bin/lcov --capture --gcov-tool $GCOV --directory . --output-file coverage.info
/usr/local/bin/lcov --remove coverage.info '*/opt/vesoft/*' -o clean.info
bash <(curl -s https://codecov.io/bash) -Z -f clean.info
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
shell: bash
24 changes: 21 additions & 3 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
image: vesoft/nebula-dev:${{ matrix.os }}
env:
CCACHE_DIR: /tmp/ccache/${{ matrix.os }}-${{ matrix.compiler }}
options: --mount type=tmpfs,destination=/tmp/ccache,tmpfs-size=1073741824 -v /tmp/ccache/${{ matrix.os }}-${{ matrix.compiler }}:/tmp/ccache/${{ matrix.os }}-${{ matrix.compiler }}
options: --mount type=tmpfs,destination=/tmp/ccache,tmpfs-size=1073741824 -v /tmp/ccache/${{ matrix.os }}-${{ matrix.compiler }}:/tmp/ccache/${{ matrix.os }}-${{ matrix.compiler }} -v /etc/action/secrets/codecov:/etc/action/secrets/codecov
steps:
- uses: actions/checkout@v1
with:
Expand All @@ -56,9 +56,13 @@ jobs:
[ -d build/ ] && rm -rf build/* || mkdir -p build
shell: bash
- name: CMake with gcc-9.2
if: matrix.compiler == 'gcc-9.2' && steps.ignore_docs.outputs.num_source_files != 0
if: matrix.compiler == 'gcc-9.2' && matrix.os != 'centos7' && steps.ignore_docs.outputs.num_source_files != 0
run: |
cmake -DCMAKE_BUILD_TYPE=Release -B build/
- name: CMake with Coverage
if: matrix.compiler == 'gcc-9.2' && matrix.os == 'centos7' && steps.ignore_docs.outputs.num_source_files != 0
run: |
cmake -DENABLE_COVERAGE=ON -B build/
- name: CMake with clang-9
if: matrix.compiler == 'clang-9' && steps.ignore_docs.outputs.num_source_files != 0
run: |
Expand All @@ -68,9 +72,13 @@ jobs:
-DENABLE_ASAN=on \
-B build/
- name: Make
if: steps.ignore_docs.outputs.num_source_files != 0
if: (matrix.compiler != 'gcc-9.2' || matrix.os != 'centos7') && steps.ignore_docs.outputs.num_source_files != 0
run: |
cmake --build build/ -j $(nproc)
- name: Make with less concurrency
if: matrix.compiler == 'gcc-9.2' && matrix.os == 'centos7' && steps.ignore_docs.outputs.num_source_files != 0
run: |
cmake --build build/ -j $(($(nproc)/2))
- name: CTest with multiple threads
if: steps.ignore_docs.outputs.num_source_files != 0
timeout-minutes: 15
Expand All @@ -97,6 +105,16 @@ jobs:
--timeout 400 \
--output-on-failure \
--rerun-failed
- name: Testing Coverage Report
working-directory: build
if: success() && matrix.compiler == 'gcc-9.2' && matrix.os == 'centos7' && steps.ignore_docs.outputs.num_source_files != 0
run: |
set -e
/usr/local/bin/lcov --version
/usr/local/bin/lcov --capture --gcov-tool $GCOV --directory . --output-file coverage.info
/usr/local/bin/lcov --remove coverage.info '*/opt/vesoft/*' -o clean.info
bash <(curl -s https://codecov.io/bash) -Z -t $(cat /etc/action/secrets/codecov) -f clean.info
shell: bash
- name: Cleanup
if: always()
run: rm -rf build
11 changes: 11 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 "Whether to turn unit test coverage ON or OFF" 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 Down Expand Up @@ -74,6 +75,15 @@ set(CMAKE_CXX_STANDARD 14) # specify the C++ standard
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# coverage
if (ENABLE_TESTING AND ENABLE_COVERAGE)
add_compile_options(--coverage)
add_compile_options(-g)
add_compile_options(-O0)

set(COVERAGES --coverage)
endif()

# To detect if ccache is available
find_program(ccache_program_found "ccache")
if (ENABLE_CCACHE AND ccache_program_found)
Expand Down Expand Up @@ -517,6 +527,7 @@ macro(nebula_link_libraries target)
${GETTIME_LIB}
${libatomic_link_flags}
-pthread
${COVERAGES}
)
endmacro(nebula_link_libraries)

Expand Down
3 changes: 3 additions & 0 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<a href="http://githubbadges.com/fork.svg?user=vesoft-inc&repo=nebula&style=default">
<img src="http://githubbadges.com/fork.svg?user=vesoft-inc&repo=nebula&style=default" alt="nebula fork"/>
</a>
<a href="https://codecov.io/gh/vesoft-inc/nebula">
<img src="https://codecov.io/gh/vesoft-inc/nebula/branch/master/graph/badge.svg" alt="codecov"/>
</a>
</p>

# Nebula Graph是什么?
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
<a href="http://githubbadges.com/fork.svg?user=vesoft-inc&repo=nebula&style=default">
<img src="http://githubbadges.com/fork.svg?user=vesoft-inc&repo=nebula&style=default" alt="nebula fork"/>
</a>
<a href="https://codecov.io/gh/vesoft-inc/nebula">
<img src="https://codecov.io/gh/vesoft-inc/nebula/branch/master/graph/badge.svg" alt="codecov"/>
</a>
<br>
</p>

Expand Down

0 comments on commit 11472d2

Please sign in to comment.