-
Notifications
You must be signed in to change notification settings - Fork 3
137 lines (128 loc) · 5.1 KB
/
ci.yml
File metadata and controls
137 lines (128 loc) · 5.1 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
push:
pull_request:
branches: [ main ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
strategy:
matrix:
os: [ubuntu-24.04, ubuntu-22.04]
runs-on: ${{ matrix.os }}
steps:
# Checks-out your repository under $GITHUB_WORKSPACE
- uses: actions/checkout@v4
- name: Update submodules
run: git submodule update --init --recursive
- name: Configure and build
run: mkdir build && cd build && cmake .. && cmake --build .
# This workflow contains a single job called "build"
test:
# The type of runner that the job will run on
strategy:
matrix:
os: [ubuntu-24.04, ubuntu-22.04]
runs-on: ${{ matrix.os }}
steps:
# Checks-out your repository under $GITHUB_WORKSPACE
- uses: actions/checkout@v4
- name: Update submodules
run: git submodule update --init --recursive
- name: Install tools
run: sudo apt-get update && sudo apt-get install -y lcov
- name: Configure and build
run: mkdir build && cd build && cmake -DBUILD_TESTING=ON -DCOVERAGE_CHECK=on .. && cmake --build .
- name: Run tests
run: cd ./build && make test
- name: Collect coverage data (version-aware)
run: |
# Check lcov version and use appropriate flags
LCOV_VERSION=$(lcov --version 2>&1 | head -n1 | grep -oP 'version \K[0-9]+\.[0-9]+' || echo "1.0")
echo "Detected lcov version: $LCOV_VERSION"
# Parse major and minor version
MAJOR_VERSION=$(echo $LCOV_VERSION | cut -d. -f1)
MINOR_VERSION=$(echo $LCOV_VERSION | cut -d. -f2)
echo "Major version: $MAJOR_VERSION, Minor version: $MINOR_VERSION"
# Determine which flags to use based on version
if [ "$MAJOR_VERSION" -ge 2 ]; then
echo "Using lcov 2.0+ configuration"
# lcov 2.0+ supports geninfo_unexecuted_blocks and enhanced ignore-errors
/usr/bin/lcov --directory ./build --capture --output-file ./build/coverage.info \
--rc geninfo_unexecuted_blocks=1 --ignore-errors mismatch,negative,unused
else
echo "Using lcov 1.x configuration (no ignore-errors support for geninfo)"
# lcov 1.x doesn't support --ignore-errors at geninfo level
/usr/bin/lcov --directory ./build --capture --output-file ./build/coverage.info
fi
# Filter coverage data
echo "Filtering coverage data..."
if [ "$MAJOR_VERSION" -ge 2 ]; then
echo "Using lcov 2.0+ filtering"
/usr/bin/lcov --ignore-errors unused -remove ./build/coverage.info \
"/usr/*" \
"*/tests/*" \
"*/src/demo/*" \
"*/sample/*" \
"*/googletest/*" \
--output-file ./build/coverage.info
else
echo "Using lcov 1.x filtering"
/usr/bin/lcov -remove ./build/coverage.info \
"/usr/*" \
"*/tests/*" \
"*/src/demo/*" \
"*/sample/*" \
"*/googletest/*" \
--output-file ./build/coverage.info
fi
- name: Show coverage summary
run: |
# Use summary instead of list for more reliable output across versions
echo "Coverage Summary:"
/usr/bin/lcov --summary ./build/coverage.info
- uses: codecov/codecov-action@v5
if: github.ref == 'refs/heads/main'
with:
fail_ci_if_error: true
files: ./build/coverage.info
exclude: tests, src/demo
flags: unittests # optional
token: ${{ secrets.CODECOV_TOKEN }} # required
verbose: true # optional (default = false)
# AddressSanitizer + UndefinedBehaviorSanitizer
sanitize-asan:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Update submodules
run: git submodule update --init --recursive
- name: Configure with ASAN + UBSAN
run: mkdir build && cd build && cmake -DBUILD_TESTING=ON -DENABLE_ASAN=ON -DENABLE_UBSAN=ON -DCMAKE_BUILD_TYPE=Debug ..
- name: Build
run: cmake --build build
- name: Run tests with ASAN + UBSAN
env:
ASAN_OPTIONS: detect_leaks=1:abort_on_error=1
UBSAN_OPTIONS: print_stacktrace=1:halt_on_error=1
run: cd build && ./bin/utests
# ThreadSanitizer (separate job - incompatible with ASAN)
sanitize-tsan:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Update submodules
run: git submodule update --init --recursive
- name: Configure with TSAN
run: mkdir build && cd build && cmake -DBUILD_TESTING=ON -DENABLE_TSAN=ON -DCMAKE_BUILD_TYPE=Debug ..
- name: Build
run: cmake --build build
- name: Run tests with TSAN
env:
TSAN_OPTIONS: halt_on_error=1:second_deadlock_stack=1
run: cd build && ./bin/utests