Test workflow refactor #5
Workflow file for this run
This file contains hidden or 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: 'Code Coverage C++' | |
| description: | | |
| This workflow checks and displays code coverage. | |
| on: | |
| push: | |
| branches: [ 'main' ] | |
| tags: [ '*' ] | |
| pull_request: | |
| branches: [ '*' ] | |
| jobs: | |
| code-coverage-cpp: | |
| name: 'Code Coverage C++' | |
| runs-on: ubuntu-latest | |
| env: | |
| SERIAL_TEST_PORT_IN: /tmp/ttyCI_IN | |
| SERIAL_TEST_PORT_OUT: /tmp/ttyCI_OUT | |
| TEST_REPORT_NAME: 'lcov.info' | |
| permissions: | |
| contents: read | |
| checks: write | |
| steps: | |
| - name: 'Checkout repository' | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: 'Install Clang and compiler-rt (profile)' | |
| run: | | |
| wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo gpg --dearmor -o /usr/share/keyrings/llvm-apt.gpg | |
| echo "deb [signed-by=/usr/share/keyrings/llvm-apt.gpg] https://apt.llvm.org/$(lsb_release -cs)/ llvm-toolchain-$(lsb_release -cs)-21 main" | sudo tee /etc/apt/sources.list.d/llvm-21.list | |
| sudo apt-get update | |
| sudo apt-get install -y clang-21 libclang-rt-21-dev llvm-21 | |
| - name: 'Setup CMake' | |
| uses: jwlawson/actions-setup-cmake@v2 | |
| with: | |
| cmake-version: '3.31.x' | |
| - name: 'Configure CMake (coverage preset)' | |
| run: | | |
| cmake --preset coverage \ | |
| -DCMAKE_C_COMPILER=clang-21 \ | |
| -DCMAKE_CXX_COMPILER=clang++-21 | |
| - name: 'Build' | |
| run: cmake --build --preset coverage | |
| - name: 'Install test dependencies' | |
| run: sudo apt-get install -y socat | |
| - name: 'Start virtual serial echo (socat)' | |
| run: | | |
| socat -d -d pty,raw,echo=0,link=$SERIAL_TEST_PORT_IN,mode=666 pty,raw,echo=0,link=$SERIAL_TEST_PORT_OUT,mode=666 & | |
| sleep 2 | |
| stdbuf -i0 -o0 cat < $SERIAL_TEST_PORT_OUT > $SERIAL_TEST_PORT_OUT & | |
| sleep 1 | |
| - name: 'Run tests with coverage' | |
| working-directory: build | |
| env: | |
| LD_LIBRARY_PATH: '${{ github.workspace }}/build' | |
| SERIAL_TEST_PORT: '${{ env.SERIAL_TEST_PORT_IN }}' | |
| LLVM_PROFILE_FILE: 'default.profraw' | |
| run: ./cpp_bindings_linux_tests --gtest_color=yes | |
| - name: 'Merge profile and export lcov' | |
| working-directory: build | |
| run: | | |
| llvm-profdata-21 merge -o default.profdata default.profraw | |
| llvm-cov-21 export -instr-profile=default.profdata \ | |
| ./cpp_bindings_linux_tests \ | |
| -object=./libcpp_bindings_linux.so \ | |
| -format=lcov \ | |
| -ignore-filename-regex='.*/GTest.*' \ | |
| -ignore-filename-regex='.*/googletest.*' \ | |
| -ignore-filename-regex='.*/cpp_core.*' \ | |
| > $TEST_REPORT_NAME | |
| - name: 'Code Coverage Annotation' | |
| uses: ggilder/codecoverage@v1 | |
| with: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| COVERAGE_FILE_PATH: './build/${{ github.env.TEST_REPORT_NAME }}' | |
| COVERAGE_FORMAT: 'lcov' |