-
Notifications
You must be signed in to change notification settings - Fork 0
515 lines (464 loc) · 18.3 KB
/
ci.yml
File metadata and controls
515 lines (464 loc) · 18.3 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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
name: CI
on:
push:
branches: [ main, develop, phase-* ]
pull_request:
branches: [ main ]
jobs:
# Quick minimal build for fast feedback (Linux-only, no dependencies)
build-minimal:
name: Minimal Build (Fast Feedback)
runs-on: ubuntu-24.04
timeout-minutes: 15
if: github.ref != 'refs/heads/gh-pages'
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Checkout common_system
uses: actions/checkout@v6
with:
repository: kcenon/common_system
path: common_system
- name: Install minimal dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake ninja-build g++ libssl-dev
cd common_system
cmake -B build -DBUILD_TESTS=OFF -DBUILD_EXAMPLES=OFF
sudo cmake --install build --prefix /usr/local
cd ..
- name: Configure minimal build
run: |
cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_WITH_COMMON_SYSTEM=ON \
-DBUILD_WITH_LOGGER_SYSTEM=OFF \
-DBUILD_WITH_THREAD_SYSTEM=OFF \
-DBUILD_WITH_CONTAINER_SYSTEM=OFF \
-DBUILD_TESTS=OFF \
-DBUILD_EXAMPLES=OFF \
-DBUILD_SAMPLES=OFF
- name: Build
run: cmake --build build --parallel
build:
name: ${{ matrix.os }} / ${{ matrix.compiler }}
runs-on: ${{ matrix.os }}
timeout-minutes: 60
# Skip only if pushed to gh-pages branch
if: github.ref != 'refs/heads/gh-pages'
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-24.04
compiler: gcc
triplet: x64-linux
- os: ubuntu-24.04
compiler: clang
triplet: x64-linux
- os: macos-15
compiler: clang
triplet: arm64-osx
- os: windows-2022
compiler: msvc
triplet: x64-windows
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
submodules: recursive
- name: Set up compiler (MSVC)
if: matrix.compiler == 'msvc'
uses: ilammy/msvc-dev-cmd@v1
- name: Install build tools (Ubuntu)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y cmake ninja-build g++ clang curl zip unzip tar pkg-config
- name: Install build tools (macOS)
if: runner.os == 'macOS'
run: |
brew install ninja pkg-config
- name: Set up compiler (GCC)
if: matrix.compiler == 'gcc'
run: |
echo "CC=gcc" >> $GITHUB_ENV
echo "CXX=g++" >> $GITHUB_ENV
- name: Set up compiler (Clang - Linux)
if: matrix.compiler == 'clang' && runner.os == 'Linux'
run: |
echo "CC=clang" >> $GITHUB_ENV
echo "CXX=clang++" >> $GITHUB_ENV
- name: Set up compiler (Clang - macOS)
if: matrix.compiler == 'clang' && runner.os == 'macOS'
run: |
echo "CC=clang" >> $GITHUB_ENV
echo "CXX=clang++" >> $GITHUB_ENV
- name: Check architecture (Linux)
if: runner.os == 'Linux'
run: |
if [ "$(uname -m)" = "aarch64" ]; then
echo "VCPKG_FORCE_SYSTEM_BINARIES=arm" >> $GITHUB_ENV
fi
- name: Setup vcpkg
uses: kcenon/common_system/.github/actions/setup-vcpkg@main
with:
extra-cache-key: 'network-system'
- name: Cache vcpkg installed
uses: actions/cache@v5
id: vcpkg-installed
with:
path: ${{ github.workspace }}/vcpkg_installed
key: ${{ runner.os }}-${{ matrix.compiler }}-vcpkg-installed-${{ matrix.triplet }}-${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json') }}
restore-keys: |
${{ runner.os }}-${{ matrix.compiler }}-vcpkg-installed-${{ matrix.triplet }}-
- name: Install dependencies with vcpkg (Unix)
if: runner.os != 'Windows' && steps.vcpkg-installed.outputs.cache-hit != 'true'
run: |
${{ env.VCPKG_ROOT }}/vcpkg install --x-manifest-root=. --x-install-root=${{ github.workspace }}/vcpkg_installed --triplet ${{ matrix.triplet }}
- name: Install dependencies with vcpkg (Windows)
if: runner.os == 'Windows' && steps.vcpkg-installed.outputs.cache-hit != 'true'
shell: pwsh
run: |
${{ env.VCPKG_ROOT }}\vcpkg install --x-manifest-root=. --x-install-root=${{ github.workspace }}\vcpkg_installed --triplet ${{ matrix.triplet }}
- name: Configure and build (vcpkg - Unix)
if: runner.os != 'Windows'
id: build_vcpkg_unix
continue-on-error: true
run: |
cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_TOOLCHAIN_FILE="${{ env.CMAKE_TOOLCHAIN_FILE }}" \
-DBUILD_WITH_COMMON_SYSTEM=ON \
-DBUILD_WITH_LOGGER_SYSTEM=ON \
-DBUILD_WITH_THREAD_SYSTEM=ON \
-DBUILD_WITH_CONTAINER_SYSTEM=ON \
-DBUILD_MESSAGING_BRIDGE=OFF \
-DBUILD_TESTS=ON \
-DBUILD_SAMPLES=OFF
cmake --build build --config Debug
- name: Configure and build (vcpkg - Windows)
if: runner.os == 'Windows'
id: build_vcpkg_windows
continue-on-error: true
shell: pwsh
run: |
cmake -B build -G Ninja `
-DCMAKE_BUILD_TYPE=Debug `
-DCMAKE_TOOLCHAIN_FILE="${{ env.CMAKE_TOOLCHAIN_FILE }}" `
-DBUILD_WITH_COMMON_SYSTEM=ON `
-DBUILD_WITH_LOGGER_SYSTEM=ON `
-DBUILD_WITH_THREAD_SYSTEM=ON `
-DBUILD_WITH_CONTAINER_SYSTEM=ON `
-DBUILD_MESSAGING_BRIDGE=OFF `
-DBUILD_TESTS=ON `
-DBUILD_SAMPLES=OFF
cmake --build build --config Debug
- name: Configure and build (fallback - Unix)
if: runner.os != 'Windows' && steps.build_vcpkg_unix.outcome != 'success'
run: |
echo "vcpkg build failed. Falling back to system libraries..."
rm -rf build
sudo apt-get install -y libgtest-dev libgmock-dev libasio-dev libfmt-dev libssl-dev liblz4-dev zlib1g-dev 2>/dev/null || \
brew install googletest asio fmt openssl@3 lz4 zlib 2>/dev/null || true
cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DBUILD_WITH_COMMON_SYSTEM=ON \
-DBUILD_WITH_LOGGER_SYSTEM=ON \
-DBUILD_WITH_THREAD_SYSTEM=ON \
-DBUILD_WITH_CONTAINER_SYSTEM=ON \
-DBUILD_MESSAGING_BRIDGE=OFF \
-DBUILD_TESTS=ON \
-DBUILD_SAMPLES=OFF
cmake --build build --config Debug
- name: Configure and build (fallback - Windows)
if: runner.os == 'Windows' && steps.build_vcpkg_windows.outcome != 'success'
shell: pwsh
run: |
Write-Host "vcpkg build failed. Falling back to system vcpkg..."
if (Test-Path build) { Remove-Item -Recurse -Force build }
$toolchainFile = "$env:VCPKG_INSTALLATION_ROOT\scripts\buildsystems\vcpkg.cmake"
cmake -B build -G Ninja `
-DCMAKE_BUILD_TYPE=Debug `
-DCMAKE_TOOLCHAIN_FILE="$toolchainFile" `
-DBUILD_WITH_COMMON_SYSTEM=ON `
-DBUILD_WITH_LOGGER_SYSTEM=ON `
-DBUILD_WITH_THREAD_SYSTEM=ON `
-DBUILD_WITH_CONTAINER_SYSTEM=ON `
-DBUILD_MESSAGING_BRIDGE=OFF `
-DBUILD_TESTS=ON `
-DBUILD_SAMPLES=OFF
cmake --build build --config Debug
- name: Test (Unix)
if: runner.os != 'Windows'
run: |
cd build
ctest -C Debug --output-on-failure --verbose || true
- name: Upload build artifacts
if: failure()
uses: actions/upload-artifact@v7
continue-on-error: true
with:
name: build-${{ matrix.os }}-${{ matrix.compiler }}-logs
path: |
build/CMakeFiles/*.log
build/Testing/Temporary/
# Phase 0: Sanitizer checks (informational, non-blocking)
# Uses ASIO 1.32.0 from source (matching sanitizers.yml) because Ubuntu 24.04's
# libasio-dev (1.28.1) has a recycling allocator bug that causes SEGV under sanitizers.
sanitizers:
name: Sanitizers (${{ matrix.sanitizer.name }})
runs-on: ubuntu-24.04
timeout-minutes: 60
continue-on-error: true
strategy:
fail-fast: false
matrix:
sanitizer:
- name: ThreadSanitizer
option: ENABLE_TSAN
env_var: TSAN_OPTIONS
env_value: "second_deadlock_stack=1"
cxx_flags: "-fsanitize=thread -g"
- name: AddressSanitizer
option: ENABLE_ASAN
env_var: ASAN_OPTIONS
env_value: "detect_leaks=1:strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1"
cxx_flags: "-fsanitize=address -fno-omit-frame-pointer -g"
- name: UndefinedBehaviorSanitizer
option: ENABLE_UBSAN
env_var: UBSAN_OPTIONS
env_value: "print_stacktrace=1:halt_on_error=0"
cxx_flags: "-fsanitize=undefined -fno-omit-frame-pointer -g"
steps:
- name: Checkout code
uses: actions/checkout@v6
with:
submodules: recursive
- name: Checkout common_system
uses: actions/checkout@v6
with:
repository: kcenon/common_system
path: common_system
token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout thread_system
uses: actions/checkout@v6
with:
repository: kcenon/thread_system
path: thread_system
token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout logger_system
uses: actions/checkout@v6
with:
repository: kcenon/logger_system
path: logger_system
token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout container_system
uses: actions/checkout@v6
with:
repository: kcenon/container_system
path: container_system
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install dependencies
run: |
sudo apt-get update
# Note: Do NOT install libasio-dev here. Ubuntu 24.04 ships ASIO 1.28.1
# which has a bug where the recycling allocator returns null under sanitizers.
sudo apt-get install -y cmake ninja-build clang libgtest-dev libgmock-dev libfmt-dev libssl-dev liblz4-dev zlib1g-dev
- name: Install ASIO from source
run: |
# Ubuntu 24.04's libasio-dev (1.28.1) has a bug where the recycling allocator
# can return null when running under sanitizers, causing SEGV. ASIO 1.32.0
# has fixes for the recycling allocator.
curl -L https://github.com/chriskohlhoff/asio/archive/asio-1-32-0.tar.gz -o asio.tar.gz
tar xzf asio.tar.gz
sudo mkdir -p /usr/local/include
sudo cp -r asio-asio-1-32-0/asio/include/asio /usr/local/include/
sudo cp asio-asio-1-32-0/asio/include/asio.hpp /usr/local/include/
- name: Build ecosystem dependencies
shell: bash
run: |
# All ecosystem deps must be built with the same sanitizer flags as
# network_system. Mixing instrumented and non-instrumented code causes
# heap corruption (glibc malloc assertion failures).
SANITIZER_CXX_FLAGS="${{ matrix.sanitizer.cxx_flags }}"
# Build common_system (Tier 0 - must be first)
if [ -d "common_system" ]; then
echo "Building common_system..."
cd common_system
cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_CXX_FLAGS="$SANITIZER_CXX_FLAGS" \
-DCMAKE_C_FLAGS="$SANITIZER_CXX_FLAGS" \
-DCMAKE_EXE_LINKER_FLAGS="$SANITIZER_CXX_FLAGS" \
-DCMAKE_SHARED_LINKER_FLAGS="$SANITIZER_CXX_FLAGS" \
-DBUILD_TESTS=OFF \
-DBUILD_EXAMPLES=OFF \
-DBUILD_SAMPLES=OFF
cmake --build build
cmake --install build --prefix ${{ github.workspace }}/deps/install
cd ..
fi
# Build thread_system
if [ -d "thread_system" ]; then
echo "Building thread_system..."
cd thread_system
cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_CXX_FLAGS="$SANITIZER_CXX_FLAGS" \
-DCMAKE_C_FLAGS="$SANITIZER_CXX_FLAGS" \
-DCMAKE_EXE_LINKER_FLAGS="$SANITIZER_CXX_FLAGS" \
-DCMAKE_SHARED_LINKER_FLAGS="$SANITIZER_CXX_FLAGS" \
-DCMAKE_PREFIX_PATH=${{ github.workspace }}/deps/install \
-DCOMMON_SYSTEM_INCLUDE_DIR=${{ github.workspace }}/deps/install/include \
-DBUILD_TESTS=OFF \
-DBUILD_EXAMPLES=OFF \
-DBUILD_SAMPLES=OFF \
-DBUILD_INTEGRATION_TESTS=OFF
cmake --build build --target thread_system
cmake --install build --prefix ${{ github.workspace }}/deps/install
cd ..
fi
# Build logger_system
if [ -d "logger_system" ]; then
echo "Building logger_system..."
cd logger_system
cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_CXX_FLAGS="$SANITIZER_CXX_FLAGS" \
-DCMAKE_C_FLAGS="$SANITIZER_CXX_FLAGS" \
-DCMAKE_EXE_LINKER_FLAGS="$SANITIZER_CXX_FLAGS" \
-DCMAKE_SHARED_LINKER_FLAGS="$SANITIZER_CXX_FLAGS" \
-DCMAKE_PREFIX_PATH=${{ github.workspace }}/deps/install \
-DCOMMON_SYSTEM_INCLUDE_DIR=${{ github.workspace }}/deps/install/include \
-DBUILD_TESTS=OFF \
-DBUILD_EXAMPLES=OFF \
-DBUILD_SAMPLES=OFF \
-DLOGGER_BUILD_INTEGRATION_TESTS=OFF
cmake --build build
cmake --install build --prefix ${{ github.workspace }}/deps/install
cd ..
fi
# Build container_system
if [ -d "container_system" ]; then
echo "Building container_system..."
cd container_system
cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_CXX_FLAGS="$SANITIZER_CXX_FLAGS" \
-DCMAKE_C_FLAGS="$SANITIZER_CXX_FLAGS" \
-DCMAKE_EXE_LINKER_FLAGS="$SANITIZER_CXX_FLAGS" \
-DCMAKE_SHARED_LINKER_FLAGS="$SANITIZER_CXX_FLAGS" \
-DCMAKE_PREFIX_PATH=${{ github.workspace }}/deps/install \
-DCOMMON_SYSTEM_INCLUDE_DIR=${{ github.workspace }}/deps/install/include \
-DBUILD_TESTS=OFF \
-DBUILD_EXAMPLES=OFF \
-DBUILD_SAMPLES=OFF
cmake --build build
# Install may fail due to missing files in container_system CMake config
cmake --install build --prefix ${{ github.workspace }}/deps/install || true
cd ..
fi
- name: Configure CMake with ${{ matrix.sanitizer.name }}
run: |
cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_PREFIX_PATH=${{ github.workspace }}/deps/install \
-D${{ matrix.sanitizer.option }}=ON \
-DBUILD_WITH_COMMON_SYSTEM=ON \
-DBUILD_WITH_LOGGER_SYSTEM=ON \
-DBUILD_WITH_THREAD_SYSTEM=ON \
-DBUILD_WITH_CONTAINER_SYSTEM=ON \
-DBUILD_MESSAGING_BRIDGE=OFF \
-DBUILD_TESTS=ON \
-DBUILD_SAMPLES=OFF \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DASIO_INCLUDE_DIR=/usr/local/include \
-DSKIP_ASIO_RECYCLING_WORKAROUND=ON
- name: Build with ${{ matrix.sanitizer.name }}
run: cmake --build build --config Debug
- name: Run tests with ${{ matrix.sanitizer.name }}
run: |
cd build
# Apply suppression files for sanitizers that support them
if [ "${{ matrix.sanitizer.option }}" = "ENABLE_UBSAN" ]; then
SUPP_FILE="${{ github.workspace }}/cmake/ubsan.supp"
if [ -f "$SUPP_FILE" ]; then
export UBSAN_OPTIONS="${{ matrix.sanitizer.env_value }}:suppressions=$SUPP_FILE"
fi
elif [ "${{ matrix.sanitizer.option }}" = "ENABLE_ASAN" ]; then
SUPP_FILE="${{ github.workspace }}/sanitizers/lsan_suppressions.txt"
if [ -f "$SUPP_FILE" ]; then
export LSAN_OPTIONS="suppressions=$SUPP_FILE"
fi
elif [ "${{ matrix.sanitizer.option }}" = "ENABLE_TSAN" ]; then
SUPP_FILE="${{ github.workspace }}/tsan_suppressions.txt"
if [ -f "$SUPP_FILE" ]; then
export TSAN_OPTIONS="${{ matrix.sanitizer.env_value }}:suppressions=$SUPP_FILE"
fi
fi
ctest -C Debug --output-on-failure --verbose -LE no_sanitizer
env:
${{ matrix.sanitizer.env_var }}: ${{ matrix.sanitizer.env_value }}
- name: Upload sanitizer logs
if: always()
uses: actions/upload-artifact@v7
continue-on-error: true
with:
name: sanitizer-${{ matrix.sanitizer.name }}-logs
path: |
build/Testing/
build/**/*.log
retention-days: 7
# Downstream compatibility test (informational, non-blocking)
test-downstream:
name: Test Downstream Compatibility
needs: build
runs-on: ubuntu-24.04
timeout-minutes: 30
continue-on-error: true
steps:
- name: Checkout network_system
uses: actions/checkout@v6
with:
path: network_system
- name: Checkout database_system
uses: actions/checkout@v6
with:
repository: kcenon/database_system
path: database_system
continue-on-error: true
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y cmake ninja-build g++ libssl-dev libfmt-dev libasio-dev
- name: Build network_system
working-directory: network_system
run: |
cmake -B build -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_WITH_COMMON_SYSTEM=ON \
-DBUILD_WITH_LOGGER_SYSTEM=ON \
-DBUILD_WITH_THREAD_SYSTEM=ON \
-DBUILD_WITH_CONTAINER_SYSTEM=ON \
-DBUILD_SAMPLES=OFF
cmake --build build --config Release --parallel
cmake --install build --prefix ${{ github.workspace }}/install
- name: Test database_system can use network_system
if: success()
working-directory: database_system
continue-on-error: true
run: |
cmake -B build -G Ninja \
-DCMAKE_PREFIX_PATH=${{ github.workspace }}/install \
-DUSE_NETWORK_SYSTEM=ON
cmake --build build --parallel