From 638c4b2ec9c40e7490f0d0d00c87287837737c5d Mon Sep 17 00:00:00 2001 From: qicosmos Date: Tue, 30 Jan 2024 11:12:44 +0800 Subject: [PATCH] fix coverage (#582) --- .github/workflows/code-coverage.yml | 38 ++++++++++++++++++++++++++++ .github/workflows/linux_llvm_cov.yml | 18 ++++++++----- 2 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/code-coverage.yml diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml new file mode 100644 index 000000000..db303f11d --- /dev/null +++ b/.github/workflows/code-coverage.yml @@ -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 diff --git a/.github/workflows/linux_llvm_cov.yml b/.github/workflows/linux_llvm_cov.yml index 2c70a3257..a9906dba8 100644 --- a/.github/workflows/linux_llvm_cov.yml +++ b/.github/workflows/linux_llvm_cov.yml @@ -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