[ci]Fix coverage #995
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Ubuntu 22.04 (llvm cov) | |
on: | |
pull_request_target: | |
branches: | |
- main | |
- fix_coverage_show | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Dependencies | |
run: | | |
sudo apt-get install openssl | |
sudo apt-get install libssl-dev | |
sudo apt-get install llvm | |
- name: Install newer Clang | |
run: | | |
sudo rm /etc/apt/sources.list.d/microsoft-prod.list | |
sudo apt-get update | |
wget https://apt.llvm.org/llvm.sh | |
chmod +x ./llvm.sh | |
sudo ./llvm.sh 17 | |
- name: Run Coverage | |
run: | | |
ls | |
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 -DBUILD_EXAMPLES=OFF -DBUILD_BENCHMARK=OFF | |
make -j | |
export LLVM_PROFILE_FILE="test_ylt-%m.profraw" | |
cd output | |
cd tests | |
./coro_io_test | |
./coro_rpc_test | |
./easylog_test | |
./struct_pack_test | |
./struct_pack_test_with_optimize | |
./metric_test | |
./struct_pb_test | |
./reflection_test | |
./coro_http_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 -object coro_http_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: List files in the repository | |
run: | | |
echo "workspace" | |
ls ${{ github.workspace }} | |
echo "workspace/build" | |
ls ${{ github.workspace }}/build | |
- name: Upload Coverage Results | |
uses: actions/[email protected] | |
with: | |
name: llvm-cov | |
path: ${{github.workspace}}/build/.coverage_llvm_cov | |
- name: Create Code Coverage Report | |
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 -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 -object coro_http_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 | |
uses: peter-evans/create-or-update-comment@v4 | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
body-file: '${{github.workspace}}/build/output/tests/tmp.log' |