Skip to content

Commit

Permalink
[ci] fix code coverage (#797)
Browse files Browse the repository at this point in the history
* [ci] fix code coverage

* fix

* fix

* fix action
  • Loading branch information
poor-circle authored Oct 22, 2024
1 parent 5bb176e commit ba0a0d0
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: install clang-format
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/clean_cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
contents: read
steps:
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Cleanup
run: |
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/linux_llvm_cov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Dependencies
run: |
Expand All @@ -34,7 +34,7 @@ jobs:
cp -r src/coro_rpc/tests/openssl_files .
ls
mkdir build && cd build
CC=clang-17 CXX=clang++-17 cmake .. -DCOVERAGE_TEST=ON -DYLT_ENABLE_SSL=ON
CC=clang-17 CXX=clang++-17 cmake .. -DCOVERAGE_TEST=ON -DYLT_ENABLE_SSL=ON -DBUILD_EXAMPLES=OFF -DBUILD_BENCHMARK=OFF
make -j
export LLVM_PROFILE_FILE="test_ylt-%m.profraw"
cd output
Expand All @@ -48,11 +48,11 @@ jobs:
./struct_pb_test
./reflection_test
llvm-profdata merge -sparse test_ylt-*.profraw -o test_ylt.profdata
llvm-cov show coro_io_test -object coro_rpc_test -object easylog_test -object struct_pack_test -object struct_pack_test_with_optimize -object metric_test -object struct_pb_test -object reflection_test -instr-profile=test_ylt.profdata -format=html -output-dir=../../.coverage_llvm_cov -ignore-filename-regex="thirdparty|asio|src" -show-instantiations=false
llvm-cov show -object coro_io_test -object coro_rpc_test -object easylog_test -object struct_pack_test -object struct_pack_test_with_optimize -object metric_test -object struct_pb_test -object reflection_test -instr-profile=test_ylt.profdata -format=html -output-dir=../../.coverage_llvm_cov -ignore-filename-regex="thirdparty|src|template_switch" -show-instantiations=false
echo "Done!"
- name: Upload Coverage Results
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: llvm-cov
path: ${{ github.workspace }}/build/.coverage_llvm_cov
Expand All @@ -63,7 +63,7 @@ jobs:
echo "Code Coverage Report" > tmp.log
echo "for detail, [goto summary](https://github.com/${{ github.repository_owner }}/${{ github.event.repository.name }}/actions/runs/${{github.run_id}}) download Artifacts `llvm-cov`" >> tmp.log
echo "\`\`\`" >> tmp.log
llvm-cov report coro_io_test -object coro_rpc_test -object easylog_test -object struct_pack_test -object struct_pack_test_with_optimize -object metric_test -object struct_pb_test -object reflection_test -instr-profile=test_ylt.profdata -ignore-filename-regex="thirdparty|asio|src" -show-region-summary=false >> tmp.log
llvm-cov report -object coro_io_test -object coro_rpc_test -object easylog_test -object struct_pack_test -object struct_pack_test_with_optimize -object metric_test -object struct_pb_test -object reflection_test -instr-profile=test_ylt.profdata -ignore-filename-regex="thirdparty|src|template_switch" -show-region-summary=false >> tmp.log
echo "\`\`\`" >> tmp.log
- name: Create Comment
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

# - name: SetUp HomeBrew
# id: set-up-homebrew
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/s390x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
name: Build Linux on s390x arch and run unit tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: uraimo/run-on-arch-action@v2
name: Test
id: runcmd
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ubuntu_clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Dependencies
run: sudo apt-get install openssl libssl-dev
Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Dependencies
run: |
Expand Down Expand Up @@ -117,7 +117,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install liburing
run: sudo apt-get install liburing-dev
Expand Down Expand Up @@ -164,7 +164,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install ninja-build tool
uses: seanmiddleditch/gha-setup-ninja@master
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ubuntu_gcc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Dependencies
run: sudo apt-get install openssl libssl-dev
Expand Down Expand Up @@ -57,7 +57,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install Dependencies
run: |
Expand Down Expand Up @@ -98,7 +98,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install liburing
run: sudo apt-get install liburing-dev
Expand Down Expand Up @@ -135,7 +135,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install ninja-build tool
uses: seanmiddleditch/gha-setup-ninja@master
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Install package
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Enable Developer Command Prompt
uses: ilammy/[email protected]
with:
Expand Down Expand Up @@ -56,7 +56,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Enable Developer Command Prompt
uses: ilammy/[email protected]
with:
Expand Down
57 changes: 32 additions & 25 deletions coverage_gen.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
if [ $# == 0 ]
then
# use llvm-cov
# you need install llvm-profdata & llvm-cov
echo "use llvm-cov"
rm -rf .coverage_llvm_cov
rm -rf build
mkdir build && cd build
export CC=clang
export CXX=clang++
cmake .. -DCOVERAGE_TEST=ON -DYLT_ENABLE_SSL=ON
make -j

# warning: test_ylt.profraw: malformed instrumentation profile data
# error: no profile can be merged
# add %m to fix the bug on ARM
# https://groups.google.com/g/llvm-dev/c/oaA58fbNMGg
# https://github.com/llvm/llvm-project/issues/50966
export LLVM_PROFILE_FILE="test_ylt-%m.profraw"
cd output/tests
./coro_io_test
./coro_rpc_test
./easylog_test
./struct_pack_test
./struct_pack_test_with_optimize
./metric_test
./struct_pb_test
./reflection_test
llvm-profdata merge -sparse test_ylt-*.profraw -o test_ylt.profdata
llvm-cov show -object ./coro_io_test -object ./coro_rpc_test -object ./easylog_test -object ./struct_pack_test -object ./struct_pack_test_with_optimize -object ./metric_test -object ./struct_pb_test -object ./reflection_test -instr-profile=test_ylt.profdata -format=html -output-dir=../../.coverage_llvm_cov -ignore-filename-regex="thirdparty|standalone|src|template_switch" -show-instantiations=false
llvm-cov report -object ./coro_io_test -object ./coro_rpc_test -object ./easylog_test -object ./struct_pack_test -object ./struct_pack_test_with_optimize -object ./metric_test -object ./struct_pb_test -object ./reflection_test -instr-profile=test_ylt.profdata -ignore-filename-regex="thirdparty|standalone|src|template_switch" -show-region-summary=false
echo 'For more Detail, see:/build/.coverage_llvm_cov/index.html'

# OR, we can use gcc && lcov
# for coverage, we should install
# 1. gcc
# 2. lcov 1.16
Expand All @@ -17,26 +47,3 @@ echo "ignore"
#mkdir ./.coverage_lcov
#lcov --rc lcov_branch_coverage=1 --capture --directory . --output-file ./.coverage_lcov/lcov.info
#genhtml --rc lcov_branch_coverage=1 ./.coverage_lcov/lcov.info --output-directory ./.coverage_lcov/report
else
echo "use llvm-cov"
rm -rf .coverage_llvm_cov
rm -rf build
mkdir build && cd build || exit 1
export CC=clang
export CXX=clang++
cmake .. -DCOVERAGE_TEST=ON -DENABLE_SSL=ON
make -j

# warning: test_ylt.profraw: malformed instrumentation profile data
# error: no profile can be merged
# add %m to fix the bug on ARM
# https://groups.google.com/g/llvm-dev/c/oaA58fbNMGg
# https://github.com/llvm/llvm-project/issues/50966
export LLVM_PROFILE_FILE="ylt_test-%m.profraw"
ls
cd output
./tests/coro_io_test ./tests/coro_rpc_test ./tests/easylog_test ./tests/struct_pack_test ./tests/struct_pack_test_with_optimize ./tests/metric_test ./tests/struct_pb_test ./tests/reflection_test
llvm-profdata merge -sparse ylt_test-*.profraw -o ylt_test.profdata
llvm-cov show ./tests/coro_io_test ./tests/coro_rpc_test ./tests/easylog_test ./tests/struct_pack_test ./tests/struct_pack_test_with_optimize ./tests/metric_test ./tests/struct_pb_test ./tests/reflection_test -instr-profile=test_ylt.profdata -format=html -output-dir=../../.coverage_llvm_cov -ignore-filename-regex="thirdparty|asio" -show-instantiations=false
echo 'Done!!!'
fi

0 comments on commit ba0a0d0

Please sign in to comment.