-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (74 loc) · 2.81 KB
/
code_coverage_cpp.yml
File metadata and controls
88 lines (74 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
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
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.*' \
> lcov.info
- name: 'Code Coverage Annotation'
uses: ggilder/codecoverage@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERAGE_FILE_PATH: './build/lcov.info'
COVERAGE_FORMAT: 'lcov'