fix coverage (#582)

This commit is contained in:
qicosmos 2024-01-30 11:12:44 +08:00 committed by GitHub
parent 383ba03de0
commit 638c4b2ec9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 50 additions and 6 deletions

38
.github/workflows/code-coverage.yml vendored Normal file
View File

@ -0,0 +1,38 @@
name: Upload CodeCov Report
on: [ push, pull_request ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Install newer Clang
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x ./llvm.sh
sudo ./llvm.sh 17
- name: Configure
run: |
cmake -B ${{github.workspace}}/build \
-DCMAKE_BUILD_TYPE=${{matrix.mode}} -DBUILD_WITH_LIBCXX=OFF -DENABLE_SSL=ON \
-DUSE_CCACHE=${{env.ccache}} -DCMAKE_C_COMPILER=clang-17 -DCMAKE_CXX_COMPILER=clang++-17
- name: Build with ${{ matrix.compiler }}
run: cmake --build ${{github.workspace}}/build --config Debug
- name: Test
working-directory: ${{github.workspace}}/build
env:
CTEST_OUTPUT_ON_FAILURE: 1
run: ctest -C ${{ matrix.configuration }} -j 1 -V
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1

View File

@ -2,8 +2,9 @@ name: Ubuntu 22.04 (llvm cov)
on:
pull_request_target:
branches: [ doc ]
workflow_dispatch:
branches:
- main
- fix_coverage
jobs:
build:
@ -17,7 +18,12 @@ jobs:
run: |
sudo apt-get install openssl
sudo apt-get install libssl-dev
sudo apt-get install llvm
- name: Install newer Clang
run: |
wget https://apt.llvm.org/llvm.sh
chmod +x ./llvm.sh
sudo ./llvm.sh 17
- name: Run Coverage
run: |
@ -25,12 +31,12 @@ jobs:
cp -r src/coro_rpc/tests/openssl_files .
ls
mkdir build && cd build
CC=clang CXX=clang++ cmake .. -DCOVERAGE_TEST=ON -DENABLE_SSL=ON
CC=clang-17 CXX=clang++-17 cmake .. -DCOVERAGE_TEST=ON -DENABLE_SSL=ON
make -j test_rpc
export LLVM_PROFILE_FILE="test_rpc-%m.profraw"
./tests/test_rpc
llvm-profdata merge -sparse test_rpc-*.profraw -o test_rpc.profdata
llvm-cov show ./tests/test_rpc -instr-profile=test_rpc.profdata -format=html -output-dir=../.coverage_llvm_cov -ignore-filename-regex="async_simple|thirdparty|tests|asio|util|logging|struct_pack" -show-instantiations=false
llvm-cov show ./tests/test_rpc -instr-profile=test_rpc.profdata -format=html -output-dir=../.coverage_llvm_cov -ignore-filename-regex="thirdparty|asio" -show-instantiations=false
echo "Done!"
- name: Upload Coverage Results
@ -45,7 +51,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 ./tests/test_rpc -instr-profile=test_rpc.profdata -ignore-filename-regex="thirdparty|tests" -show-region-summary=false >> tmp.log
llvm-cov report ./tests/test_rpc -instr-profile=test_rpc.profdata -ignore-filename-regex="thirdparty|asio" -show-region-summary=false >> tmp.log
echo "\`\`\`" >> tmp.log
- name: Create Comment