-
Notifications
You must be signed in to change notification settings - Fork 1
161 lines (142 loc) · 5.2 KB
/
ci.yml
File metadata and controls
161 lines (142 loc) · 5.2 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
name: CI
on:
push:
branches: ["**"]
paths-ignore:
- "**/*.md"
- ".gitkeep"
pull_request:
branches: ["**"]
paths-ignore:
- "**/*.md"
- ".gitkeep"
jobs:
# ─── Code formatting check ───────────────────────────────────────────────────
format:
name: clang-format check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install clang-format
run: sudo apt-get install -y clang-format
- name: Check formatting
run: |
find . \( -name '*.cpp' -o -name '*.h' \) \
! -path './third_party/*' \
! -path './deps/*' -print0 \
| xargs -0 clang-format --dry-run --Werror
# ─── Static analysis ─────────────────────────────────────────────────────────
static-analysis:
name: cppcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install cppcheck
run: sudo apt-get install -y cppcheck
- name: Run cppcheck
run: |
cppcheck \
--enable=warning,performance \
--std=c++20 \
--error-exitcode=1 \
--suppress=missingIncludeSystem \
--suppress=unmatchedSuppression \
--suppress=throwInNoexceptFunction \
--suppress=uninitMemberVarPrivate \
--suppress='*:deps/*' \
-I . -I utils -I deps/pmm \
$(find . -name '*.cpp' ! -path './third_party/*' ! -path './deps/*')
# ─── File size limits ─────────────────────────────────────────────────────────
file-size:
name: File size check (<= 1500 lines)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check file size limits
run: |
MAX_LINES=1500
FAILED=0
while IFS= read -r -d '' file; do
lines=$(wc -l < "$file")
if [ "$lines" -gt "$MAX_LINES" ]; then
echo "FAIL: $file has $lines lines (max $MAX_LINES)"
FAILED=1
fi
done < <(find . \( -name '*.cpp' -o -name '*.h' \) \
! -path './third_party/*' \
! -path './deps/*' -print0)
exit $FAILED
# ─── Build and test ──────────────────────────────────────────────────────────
build-and-test:
name: ${{ matrix.os }} / ${{ matrix.compiler }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
compiler: gcc
cc: gcc
cxx: g++
build_type: Debug
coverage: true
- os: ubuntu-latest
compiler: clang
cc: clang
cxx: clang++
build_type: Release
coverage: false
- os: macos-latest
compiler: clang
cc: clang
cxx: clang++
build_type: Release
coverage: false
- os: windows-latest
compiler: msvc
cc: cl
cxx: cl
build_type: Release
coverage: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Configure CMake (Linux / macOS, without coverage)
if: runner.os != 'Windows' && !matrix.coverage
run: |
cmake -B build \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_C_COMPILER=${{ matrix.cc }} \
-DCMAKE_CXX_COMPILER=${{ matrix.cxx }}
- name: Configure CMake (Linux, with coverage)
if: runner.os != 'Windows' && matrix.coverage
run: |
cmake -B build \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_C_COMPILER=${{ matrix.cc }} \
-DCMAKE_CXX_COMPILER=${{ matrix.cxx }} \
-DCMAKE_CXX_FLAGS="--coverage" \
-DCMAKE_C_FLAGS="--coverage"
- name: Configure CMake (Windows)
if: runner.os == 'Windows'
run: cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
- name: Build
run: cmake --build build --config ${{ matrix.build_type }}
- name: Test
run: ctest --test-dir build --build-config ${{ matrix.build_type }} --output-on-failure
- name: Generate coverage report
if: matrix.coverage
run: |
sudo apt-get install -y lcov
lcov --capture --directory build --output-file coverage.info \
--ignore-errors mismatch,source
lcov --remove coverage.info \
'/usr/*' '*/third_party/*' '*/catch2-build/*' \
--output-file coverage.info \
--ignore-errors unused
lcov --list coverage.info
- name: Upload coverage to Codecov
if: matrix.coverage
uses: codecov/codecov-action@v4
with:
files: coverage.info
fail_ci_if_error: false