|
1 | 1 | name: CI |
2 | | - |
3 | | -on: |
4 | | - push: |
5 | | - branches: [ main, master ] |
6 | | - pull_request: |
7 | | - branches: [ main, master ] |
8 | | - |
| 2 | +on: [push, pull_request] |
9 | 3 | jobs: |
10 | | - # --------------------------------------------------------------------------- |
11 | | - # Linux build and test (GCC + Clang, Release + Debug) |
12 | | - # --------------------------------------------------------------------------- |
13 | | - build-linux: |
14 | | - name: "Linux (${{ matrix.compiler }}, ${{ matrix.build_type }})" |
| 4 | + check: |
15 | 5 | runs-on: ubuntu-latest |
16 | | - strategy: |
17 | | - fail-fast: false |
18 | | - matrix: |
19 | | - compiler: [gcc, clang] |
20 | | - build_type: [Release, Debug] |
21 | | - |
22 | 6 | steps: |
23 | 7 | - uses: actions/checkout@v4 |
24 | | - |
25 | | - - name: Install system dependencies |
26 | | - run: | |
27 | | - sudo apt-get update -qq |
28 | | - # Install LLVM 18 repo for clang-18 on Ubuntu 24.04 |
29 | | - wget -qO- https://apt.llvm.org/llvm.sh | sudo bash -s 18 |
30 | | - sudo apt-get install -y \ |
31 | | - build-essential \ |
32 | | - cmake \ |
33 | | - ninja-build \ |
34 | | - libspdlog-dev \ |
35 | | - libyaml-cpp-dev \ |
36 | | - libhiredis-dev \ |
37 | | - libgtest-dev \ |
38 | | - libgmock-dev \ |
39 | | - nlohmann-json3-dev \ |
40 | | - libssl-dev \ |
41 | | - clang-18 \ |
42 | | - clang-format-18 \ |
43 | | - clang-tidy-18 \ |
44 | | - cppcheck \ |
45 | | - valgrind |
46 | | -
|
47 | | - - name: Select compiler |
48 | | - run: | |
49 | | - if [ "${{ matrix.compiler }}" = "clang" ]; then |
50 | | - echo "CC=clang-18" >> "$GITHUB_ENV" |
51 | | - echo "CXX=clang++-18" >> "$GITHUB_ENV" |
52 | | - else |
53 | | - echo "CC=gcc" >> "$GITHUB_ENV" |
54 | | - echo "CXX=g++" >> "$GITHUB_ENV" |
55 | | - fi |
56 | | -
|
57 | | - - name: Cache CMake build artifacts |
58 | | - uses: actions/cache@v4 |
59 | | - with: |
60 | | - path: build |
61 | | - key: ${{ runner.os }}-${{ matrix.compiler }}-${{ matrix.build_type }}-${{ hashFiles('CMakeLists.txt', 'src/**', 'include/**', 'tests/**') }} |
62 | | - restore-keys: | |
63 | | - ${{ runner.os }}-${{ matrix.compiler }}-${{ matrix.build_type }}- |
64 | | -
|
65 | | - - name: Set ASAN flag |
66 | | - run: | |
67 | | - if [ "${{ matrix.build_type }}" = "Debug" ]; then |
68 | | - echo "ASAN_FLAG=ON" >> "$GITHUB_ENV" |
69 | | - else |
70 | | - echo "ASAN_FLAG=OFF" >> "$GITHUB_ENV" |
71 | | - fi |
72 | | -
|
73 | | - - name: CMake configure |
74 | | - run: | |
75 | | - cmake -S . -B build \ |
76 | | - -G Ninja \ |
77 | | - -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ |
78 | | - -DCMAKE_C_COMPILER="$CC" \ |
79 | | - -DCMAKE_CXX_COMPILER="$CXX" \ |
80 | | - -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ |
81 | | - -DLLMQUANT_WARNINGS_AS_ERRORS=ON \ |
82 | | - -DLLMQUANT_ENABLE_ASAN="$ASAN_FLAG" |
83 | | -
|
84 | | - - name: Build |
85 | | - run: cmake --build build --parallel |
86 | | - |
87 | | - - name: Run tests (ctest) |
88 | | - run: | |
89 | | - cd build && ctest \ |
90 | | - --output-on-failure \ |
91 | | - --parallel 4 |
92 | | -
|
93 | | - - name: clang-tidy static analysis |
94 | | - if: matrix.compiler == 'clang' && matrix.build_type == 'Release' |
95 | | - run: | |
96 | | - find src -name '*.cpp' | xargs clang-tidy-18 \ |
97 | | - -p build \ |
98 | | - --warnings-as-errors='' \ |
99 | | - --extra-arg=-std=c++20 \ |
100 | | - --extra-arg=-Iinclude \ |
101 | | - --extra-arg=-I${{ github.workspace }}/include \ |
102 | | - 2>&1 | tee clang-tidy-report.txt |
103 | | - echo "clang-tidy completed" |
104 | | -
|
105 | | - - name: cppcheck static analysis |
106 | | - if: matrix.compiler == 'gcc' && matrix.build_type == 'Release' |
107 | | - run: | |
108 | | - cppcheck \ |
109 | | - --enable=warning,performance,portability \ |
110 | | - --std=c++20 \ |
111 | | - --error-exitcode=1 \ |
112 | | - --suppress=missingIncludeSystem \ |
113 | | - -I include \ |
114 | | - src/ \ |
115 | | - 2>&1 | tee cppcheck-report.txt |
116 | | -
|
117 | | - # ----------------------------------------------------------------------- |
118 | | - # AddressSanitizer run (Debug builds only) |
119 | | - # ----------------------------------------------------------------------- |
120 | | - - name: AddressSanitizer / UBSan test run |
121 | | - if: matrix.build_type == 'Debug' |
122 | | - run: | |
123 | | - # ASAN is baked into the Debug binary via -fsanitize=address,undefined |
124 | | - # (set by LLMQUANT_ENABLE_ASAN=ON above for non-MSVC Debug builds). |
125 | | - # ctest already ran the tests; this step re-runs with full ASAN options |
126 | | - # and explicit leak-detection to catch any latent issues. |
127 | | - export ASAN_OPTIONS="detect_leaks=1:halt_on_error=1:check_initialization_order=1" |
128 | | - export UBSAN_OPTIONS="halt_on_error=1:print_stacktrace=1" |
129 | | - cd build && ctest \ |
130 | | - --output-on-failure \ |
131 | | - --parallel 1 \ |
132 | | - 2>&1 | tee ../asan-report.txt |
133 | | -
|
134 | | - # ----------------------------------------------------------------------- |
135 | | - # Valgrind memcheck (GCC Release only — Linux only, no ASAN instrumentation) |
136 | | - # ----------------------------------------------------------------------- |
137 | | - - name: Valgrind memcheck |
138 | | - if: matrix.compiler == 'gcc' && matrix.build_type == 'Release' |
139 | | - run: | |
140 | | - # Run the unit-test binary under valgrind. |
141 | | - # --error-exitcode=1 turns any error into a non-zero exit so CI fails. |
142 | | - valgrind \ |
143 | | - --tool=memcheck \ |
144 | | - --error-exitcode=1 \ |
145 | | - --leak-check=full \ |
146 | | - --show-leak-kinds=definite,indirect \ |
147 | | - --track-origins=yes \ |
148 | | - --suppressions=/usr/lib/valgrind/default.supp \ |
149 | | - build/tests/tests \ |
150 | | - --gtest_filter="-*Performance*:*Bench*:*bench*" \ |
151 | | - 2>&1 | tee valgrind-report.txt |
152 | | -
|
153 | | - - name: Upload test results on failure |
154 | | - if: failure() |
155 | | - uses: actions/upload-artifact@v4 |
156 | | - with: |
157 | | - name: test-results-${{ matrix.compiler }}-${{ matrix.build_type }} |
158 | | - path: | |
159 | | - build/Testing/ |
160 | | - clang-tidy-report.txt |
161 | | - cppcheck-report.txt |
162 | | - asan-report.txt |
163 | | - valgrind-report.txt |
164 | | -
|
165 | | - # --------------------------------------------------------------------------- |
166 | | - # clang-format formatting gate |
167 | | - # --------------------------------------------------------------------------- |
168 | | - format-check: |
169 | | - name: "clang-format check" |
170 | | - runs-on: ubuntu-latest |
171 | | - steps: |
172 | | - - uses: actions/checkout@v4 |
173 | | - |
174 | | - - name: Install clang-format |
175 | | - run: | |
176 | | - sudo apt-get update -qq |
177 | | - wget -qO- https://apt.llvm.org/llvm.sh | sudo bash -s 18 |
178 | | - sudo apt-get install -y clang-format-18 |
179 | | -
|
180 | | - - name: Check formatting |
181 | | - run: | |
182 | | - find src include tests \ |
183 | | - \( -name '*.cpp' -o -name '*.h' \) \ |
184 | | - | xargs clang-format-18 --dry-run --Werror |
185 | | - echo "All source files are correctly formatted." |
186 | | -
|
187 | | - # --------------------------------------------------------------------------- |
188 | | - # Doxygen documentation build |
189 | | - # --------------------------------------------------------------------------- |
190 | | - docs: |
191 | | - name: "Doxygen API docs" |
192 | | - runs-on: ubuntu-latest |
193 | | - steps: |
194 | | - - uses: actions/checkout@v4 |
195 | | - |
196 | | - - name: Install system dependencies |
197 | | - run: | |
198 | | - sudo apt-get update -qq |
199 | | - sudo apt-get install -y \ |
200 | | - cmake \ |
201 | | - ninja-build \ |
202 | | - libspdlog-dev \ |
203 | | - libyaml-cpp-dev \ |
204 | | - libhiredis-dev \ |
205 | | - libgtest-dev \ |
206 | | - libgmock-dev \ |
207 | | - nlohmann-json3-dev \ |
208 | | - libssl-dev \ |
209 | | - doxygen \ |
210 | | - graphviz |
211 | | -
|
212 | | - - name: Configure (needed to generate llmquant_version.h) |
213 | | - run: | |
214 | | - cmake -S . -B build_docs \ |
215 | | - -DCMAKE_BUILD_TYPE=Release \ |
216 | | - -DLLMQUANT_WARNINGS_AS_ERRORS=OFF |
217 | | -
|
218 | | - - name: Build docs |
219 | | - run: doxygen docs/Doxyfile |
220 | | - |
221 | | - - name: Verify HTML output exists |
222 | | - run: test -f docs/api/html/index.html |
223 | | - |
224 | | - - name: Upload docs artifact |
225 | | - uses: actions/upload-artifact@v4 |
226 | | - with: |
227 | | - name: api-docs |
228 | | - path: docs/api/html/ |
229 | | - |
230 | | - # --------------------------------------------------------------------------- |
231 | | - # Windows build (MSVC, Release + Debug) |
232 | | - # --------------------------------------------------------------------------- |
233 | | - build-windows: |
234 | | - name: "Windows (MSVC, ${{ matrix.build_type }})" |
235 | | - runs-on: windows-latest |
236 | | - strategy: |
237 | | - fail-fast: false |
238 | | - matrix: |
239 | | - build_type: [Release, Debug] |
240 | | - |
241 | | - steps: |
242 | | - - uses: actions/checkout@v4 |
243 | | - |
244 | | - - name: Set up vcpkg |
245 | | - uses: lukka/run-vcpkg@v11 |
246 | | - with: |
247 | | - vcpkgGitCommitId: 'a42af01b72c28a8e1d7b48107b33e4f286a55ef6' |
248 | | - |
249 | | - - name: Install vcpkg dependencies |
250 | | - run: | |
251 | | - & "$env:VCPKG_ROOT\vcpkg" install spdlog yaml-cpp gtest nlohmann-json openssl --triplet x64-windows |
252 | | - # hiredis is optional (find_package QUIET) — omitted to avoid Windows build timeouts |
253 | | -
|
254 | | - - name: CMake configure |
255 | | - run: | |
256 | | - cmake -S . -B build ` |
257 | | - -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ` |
258 | | - -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake" ` |
259 | | - -DLLMQUANT_WARNINGS_AS_ERRORS=OFF |
260 | | -
|
261 | | - - name: Build |
262 | | - run: cmake --build build --config ${{ matrix.build_type }} --parallel |
263 | | - |
264 | | - - name: Run tests |
265 | | - run: | |
266 | | - cd build && ctest ` |
267 | | - -C ${{ matrix.build_type }} ` |
268 | | - --output-on-failure ` |
269 | | - --parallel 4 |
| 8 | + - run: cmake -B build -DCMAKE_BUILD_TYPE=Release |
0 commit comments