From f27793b95e864618abc8ac135c0305734696e9db Mon Sep 17 00:00:00 2001 From: qicosmos Date: Tue, 30 Jan 2024 16:29:30 +0800 Subject: [PATCH] [ci]test coverage (#585) --- .github/workflows/code-coverage.yml | 2 +- .github/workflows/linux_llvm_cov.yml | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index db303f11d..a4076bd50 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -26,7 +26,7 @@ jobs: -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 + run: cmake --build ${{github.workspace}}/build --config Debug -- -j - name: Test working-directory: ${{github.workspace}}/build diff --git a/.github/workflows/linux_llvm_cov.yml b/.github/workflows/linux_llvm_cov.yml index 7a48f3040..356958f26 100644 --- a/.github/workflows/linux_llvm_cov.yml +++ b/.github/workflows/linux_llvm_cov.yml @@ -18,6 +18,7 @@ jobs: run: | sudo apt-get install openssl sudo apt-get install libssl-dev + sudo apt-get install llvm - name: Install newer Clang run: | @@ -35,28 +36,33 @@ jobs: make -j export LLVM_PROFILE_FILE="test_ylt-%m.profraw" cd output - ./tests/coro_io_test ./tests/coro_rpc_test ./tests/easylog_test ./tests/struct_pack_test ./tests/struct_pack_test_with_optimize + cd tests + ./coro_io_test + ./coro_rpc_test + ./easylog_test + ./struct_pack_test + ./struct_pack_test_with_optimize llvm-profdata merge -sparse test_ylt-*.profraw -o test_ylt.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 -instr-profile=test_ylt.profdata -format=html -output-dir=../.coverage_llvm_cov -ignore-filename-regex="thirdparty|asio" -show-instantiations=false + llvm-cov show coro_io_test coro_rpc_test easylog_test struct_pack_test struct_pack_test_with_optimize -instr-profile=test_ylt.profdata -format=html -output-dir=../../.coverage_llvm_cov -ignore-filename-regex="thirdparty|asio" -show-instantiations=false echo "Done!" - name: Upload Coverage Results uses: actions/upload-artifact@v3 with: name: llvm-cov - path: ${{ github.workspace }}/.coverage_llvm_cov + path: ${{ github.workspace }}/build/.coverage_llvm_cov - name: Create Code Coverage Report - working-directory: ${{github.workspace}}/build + working-directory: ${{github.workspace}}/build/output/tests run: | 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/coro_io_test ./tests/coro_rpc_test ./tests/easylog_test ./tests/struct_pack_test ./tests/struct_pack_test_with_optimize -instr-profile=test_ylt.profdata -ignore-filename-regex="thirdparty|asio" -show-region-summary=false >> tmp.log + llvm-cov report coro_io_test coro_rpc_test easylog_test struct_pack_test struct_pack_test_with_optimize -instr-profile=test_ylt.profdata -ignore-filename-regex="thirdparty|asio" -show-region-summary=false >> tmp.log echo "\`\`\`" >> tmp.log - name: Create Comment uses: peter-evans/create-or-update-comment@v2 with: issue-number: ${{ github.event.pull_request.number }} - body-file: '${{github.workspace}}/build/tmp.log' + body-file: '${{github.workspace}}/build/output/tests/tmp.log'