Skip to content

coverage

coverage #27

Workflow file for this run

# The coverage jobs for cpp code
#
# This sperate job exists because C/CPP coverage require build type to be Debug.
# Other coverage jobs e.g java/scala's coverage lives alongside with their test jobs.
name: coverage
on:
push:
branches:
- main
paths-ignore:
- 'docs/**'
- 'demo/**'
- 'docker/**'
- 'image/**'
- 'release/**'
- 'tools/**'
- '*.md'
- 'benchmark/**'
pull_request:
paths-ignore:
- 'docs/**'
- 'demo/**'
- 'docker/**'
- 'image/**'
- 'release/**'
- 'tools/**'
- '*.md'
- 'benchmark/**'
workflow_dispatch:
jobs:
coverage:
runs-on: ubuntu-20.04
env:
CTEST_PARALLEL_LEVEL: 1 # parallel test level for ctest (make test)
CMAKE_BUILD_TYPE: Debug
TESTING_ENABLE: ON
SQL_PYSDK_ENABLE: OFF
SQL_JAVASDK_ENABLE: OFF
NPROC: 2
BUILD_SHARED_LIBS: ON
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: download lcov
uses: actions/checkout@v3
with:
repository: linux-test-project/lcov
ref: v1.16
path: lcov
- name: install lcov
working-directory: lcov
run: |
sudo make install
- name: coverage configure
run: |
make coverage-configure COVERAGE_NO_DEPS=ON
- name: start service
run: |
./steps/ut_zookeeper.sh start
# make coverage-cpp will gen 16G build/ (no run), run test will take 2G more, so split make and test
- name: Coverage CPP
run: |
# rm some irrelevant files
rm -rf .deps/build
# only build tests: no build output by ctest, so we use cmake
# ctest --build-and-test . build --build-nocmake --build-generator "Unix Makefiles" -j $NPROC
# split make too, delete irrelavant files in the middle
cmake --build build --target help | grep -Eo "\S+_test$" | awk '{if(NR <60) printf(" %s ",$0)}' | xargs cmake --build build -j $NPROC --target
# rm some in the middle
rm -f build/bin/*
find build -name "*.a" -type f -delete
du -d 1 -h build
df -h
cmake --build build --target help | grep -Eo "\S+_test$" | awk '{if(NR >=60) printf(" %s ",$0)}' | xargs cmake --build build -j $NPROC --target
# rm some irrelevant files, *.dir/Makefile can't be deleted, test in bin won't test by coverage
rm build/bin/*
find build -name "*.a" -type f -delete
find build -name "*.o" -type f -delete
# find . -type d -name "*.dir" -not -name "" -exec rm -r {} +
du -d 1 -h build
df -h
# Makefile target coverage, not the cmake target(won't build tests again), total 119(120-api_server_test)
cd build
SQL_CASE_BASE_DIR=$(pwd)/.. YAML_CASE_BASE_DIR=$(pwd)/.. make coverage
- name: debug
if: always()
run: |
du -d 1 -h build
df -h
- name: Upload Coverage Report
uses: codecov/codecov-action@v3
with:
files: build/coverage.info
name: coverage-cpp
fail_ci_if_error: true
verbose: true
- name: stop service
run: |
./steps/ut_zookeeper.sh stop