-
Notifications
You must be signed in to change notification settings - Fork 100
387 lines (336 loc) · 15.6 KB
/
build_cpp.yml
File metadata and controls
387 lines (336 loc) · 15.6 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
# Copyright(C) 2025-2026 Advanced Micro Devices, Inc. All rights reserved.
# SPDX-License-Identifier: MIT
# This workflow builds and tests the C++ library in cpp/
# Tests include: CMake build, GoogleTest mock tests (cloud), integration tests (STX)
# Integration tests: LLM chat/tool-calling, MCP connection, WiFi diagnostics, Health monitoring
# Platform: Cross-platform (Linux and Windows cloud), Windows STX (self-hosted AMD hardware)
name: C++ Build & Test
on:
workflow_call:
push:
branches: [ main ]
paths:
- 'cpp/**'
- '.github/workflows/build_cpp.yml'
- '.github/workflows/benchmark_cpp.yml'
pull_request:
branches: [ main ]
types: [opened, synchronize, reopened, ready_for_review]
paths:
- 'cpp/**'
- '.github/workflows/build_cpp.yml'
- '.github/workflows/benchmark_cpp.yml'
merge_group:
workflow_dispatch:
# Cancel in-progress runs when a new run is triggered
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
build-and-test:
name: C++ (${{ matrix.os }})
runs-on: ${{ matrix.os }}
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false || contains(github.event.pull_request.labels.*.name, 'ready_for_ci')
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v6
- name: Install OpenSSL (Linux)
if: runner.os == 'Linux'
run: sudo apt-get install -y libssl-dev
- name: Install OpenSSL (Windows)
if: runner.os == 'Windows'
run: choco install openssl --no-progress -y
- name: Restore FetchContent cache
id: cache-deps
uses: actions/cache@v4
with:
path: cpp/build/_deps
key: fetchcontent-${{ matrix.os }}-${{ hashFiles('cpp/CMakeLists.txt') }}
- name: Configure CMake
run: cmake -B cpp/build -S cpp -DCMAKE_BUILD_TYPE=Release -DGAIA_BUILD_INTEGRATION_TESTS=OFF
- name: Build
run: cmake --build cpp/build --config Release --parallel
- name: Test
run: ctest --test-dir cpp/build -C Release --output-on-failure
# Verify cmake --install + find_package round-trip works
install-test:
name: C++ Install Test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false || contains(github.event.pull_request.labels.*.name, 'ready_for_ci')
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v6
- name: Install OpenSSL (Linux)
if: runner.os == 'Linux'
run: sudo apt-get install -y libssl-dev
- name: Restore FetchContent cache
uses: actions/cache@v4
with:
path: cpp/build/_deps
key: fetchcontent-install-${{ matrix.os }}-${{ hashFiles('cpp/CMakeLists.txt') }}
- name: Install OpenSSL (Windows)
if: runner.os == 'Windows'
shell: bash
run: choco install openssl --no-progress -y
- name: Build and install gaia_core
shell: bash
run: |
cmake -B cpp/build -S cpp -DCMAKE_BUILD_TYPE=Release \
-DGAIA_BUILD_TESTS=OFF -DGAIA_BUILD_EXAMPLES=OFF \
-DGAIA_BUILD_INTEGRATION_TESTS=OFF \
-DCMAKE_INSTALL_PREFIX="${{ runner.temp }}/gaia_install"
cmake --build cpp/build --config Release --parallel
cmake --install cpp/build --config Release
- name: Build consumer via find_package
shell: bash
run: |
cmake -B consumer/build -S cpp/examples/fetch_content_consumer \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_PREFIX_PATH="${{ runner.temp }}/gaia_install" \
-DUSE_FIND_PACKAGE=ON
cmake --build consumer/build --config Release --parallel
# Verify BUILD_SHARED_LIBS=ON (shared library / DLL) compiles cleanly
shared-lib-test:
name: C++ Shared Library (${{ matrix.os }})
runs-on: ${{ matrix.os }}
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false || contains(github.event.pull_request.labels.*.name, 'ready_for_ci')
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
steps:
- uses: actions/checkout@v6
- name: Install OpenSSL (Linux)
if: runner.os == 'Linux'
run: sudo apt-get install -y libssl-dev
- name: Install OpenSSL (Windows)
if: runner.os == 'Windows'
run: choco install openssl --no-progress -y
- name: Restore FetchContent cache
uses: actions/cache@v4
with:
path: cpp/build-shared/_deps
key: fetchcontent-shared-${{ matrix.os }}-${{ hashFiles('cpp/CMakeLists.txt') }}
- name: Build shared library
shell: bash
run: |
cmake -B cpp/build-shared -S cpp -DCMAKE_BUILD_TYPE=Release \
-DBUILD_SHARED_LIBS=ON \
-DGAIA_BUILD_TESTS=OFF -DGAIA_BUILD_EXAMPLES=OFF \
-DGAIA_BUILD_INTEGRATION_TESTS=OFF
cmake --build cpp/build-shared --config Release --parallel
# Integration tests on STX hardware: LLM + MCP + WiFi + Health
integration-test:
name: C++ Integration Tests (STX)
runs-on: ${{ (contains(github.event.pull_request.labels.*.name, 'stx-test') && 'stx-test') || 'stx' }}
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false || contains(github.event.pull_request.labels.*.name, 'ready_for_ci')
steps:
- uses: actions/checkout@v6
- name: Setup Python environment
uses: ./.github/actions/setup-venv
with:
python-version: '3.12'
install-package: '.[lemonade]'
- name: Install Lemonade Server
uses: ./.github/actions/install-lemonade
- name: Ensure C++ build tools are available
shell: powershell
run: |
$ErrorActionPreference = "Stop"
$ProgressPreference = 'SilentlyContinue'
$cmakeVer = "3.31.4"
$mgwVer = "2.5.0"
# --- CMake ---
# Check PATH, then previously downloaded location, then VS, then download
$cmakeCached = "$env:TEMP\cmake\cmake-${cmakeVer}-windows-x86_64\bin"
if (Get-Command cmake -ErrorAction SilentlyContinue) {
Write-Host "CMake found in PATH"
} elseif (Test-Path "$cmakeCached\cmake.exe") {
Write-Host "CMake found at cached location"
echo "$cmakeCached" >> $env:GITHUB_PATH
} else {
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
if (Test-Path $vswhere) {
$vsCmake = & $vswhere -latest `
-requires Microsoft.VisualStudio.Component.VC.CMake.Project `
-find "Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin" 2>$null
if ($vsCmake -and (Test-Path "$vsCmake\cmake.exe")) {
Write-Host "Using VS-bundled CMake"
echo "$vsCmake" >> $env:GITHUB_PATH
}
}
}
if (-not (Get-Command cmake -ErrorAction SilentlyContinue) -and
-not (Test-Path "$cmakeCached\cmake.exe")) {
$url = "https://github.com/Kitware/CMake/releases/download/v${cmakeVer}/cmake-${cmakeVer}-windows-x86_64.zip"
Write-Host "Downloading CMake v${cmakeVer}..."
Invoke-WebRequest -Uri $url -OutFile "$env:TEMP\cmake.zip" -UseBasicParsing
Expand-Archive "$env:TEMP\cmake.zip" "$env:TEMP\cmake" -Force
Remove-Item "$env:TEMP\cmake.zip"
echo "$cmakeCached" >> $env:GITHUB_PATH
}
# --- C++ compiler ---
# Check for MSVC, then g++ in PATH, then cached w64devkit, then download
$hasMSVC = $false
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
if (Test-Path $vswhere) {
$vsPath = & $vswhere -latest -property installationPath 2>$null
if ($vsPath) { $hasMSVC = $true; Write-Host "MSVC found" }
}
$mgwCached = "$env:TEMP\w64devkit\bin"
if (-not $hasMSVC) {
if (Get-Command g++ -ErrorAction SilentlyContinue) {
Write-Host "g++ found in PATH"
} elseif (Test-Path "$mgwCached\g++.exe") {
Write-Host "w64devkit found at cached location"
echo "$mgwCached" >> $env:GITHUB_PATH
} else {
$url = "https://github.com/skeeto/w64devkit/releases/download/v${mgwVer}/w64devkit-x64-${mgwVer}.7z.exe"
Write-Host "Downloading w64devkit (MinGW-w64) v${mgwVer}..."
Invoke-WebRequest -Uri $url -OutFile "$env:TEMP\w64devkit.exe" -UseBasicParsing
Write-Host "Extracting w64devkit..."
& "$env:TEMP\w64devkit.exe" -o"$env:TEMP" -y | Out-Null
Remove-Item "$env:TEMP\w64devkit.exe"
echo "$mgwCached" >> $env:GITHUB_PATH
}
}
Write-Host "Build tools ready"
- name: Restore FetchContent cache
uses: actions/cache@v4
with:
path: cpp/build-integration/_deps
key: fetchcontent-integration-windows-${{ hashFiles('cpp/CMakeLists.txt') }}
- name: Configure and build integration tests
shell: powershell
run: |
# Auto-detect generator: MinGW Makefiles when using w64devkit
$gen = @()
if (Get-Command g++ -ErrorAction SilentlyContinue) {
if (-not (Get-Command cl -ErrorAction SilentlyContinue)) {
$gen = @("-G", "MinGW Makefiles")
}
}
cmake -B cpp/build-integration -S cpp @gen `
-DCMAKE_BUILD_TYPE=Release `
-DGAIA_BUILD_INTEGRATION_TESTS=ON `
-DGAIA_BUILD_TESTS=OFF `
-DGAIA_BUILD_EXAMPLES=OFF `
-DGAIA_ENABLE_SSL=OFF
if ($LASTEXITCODE -ne 0) { throw "CMake configure failed" }
cmake --build cpp/build-integration --config Release --parallel
if ($LASTEXITCODE -ne 0) { throw "CMake build failed" }
- name: Verify uvx is available
shell: powershell
run: |
# uvx is provided by uv (installed by setup-venv)
$uvx = Get-Command uvx -ErrorAction SilentlyContinue
if ($uvx) {
Write-Host "[OK] uvx found at: $($uvx.Source)"
} else {
Write-Host "[WARN] uvx not found -- MCP and Health integration tests will fail"
Write-Host " uvx should be available via uv (installed by setup-venv)"
exit 0
}
# Remove any broken persistent installation that may interfere with uvx.
# Swallow all output/errors — the tool may not be installed and that's fine.
# Run via cmd /c so native stderr never reaches PowerShell's error stream
# (PS 5.1 -Command mode generates NativeCommandError from any native stderr).
cmd /c "uv tool uninstall windows-mcp 2>NUL" 2>$null
$global:LASTEXITCODE = 0
Write-Host "[OK] uvx ready (windows-mcp will run via temporary uvx environments)"
- name: Start Lemonade Server and run integration tests
shell: powershell
timeout-minutes: 30
env:
GAIA_CPP_TEST_MODEL: Qwen3-4B-Instruct-2507-GGUF
GAIA_CPP_BASE_URL: http://localhost:8000/api/v1
run: |
try {
# Start Lemonade with Qwen3-4B-GGUF
.\installer\scripts\start-lemonade.ps1 -ModelName "Qwen3-4B-Instruct-2507-GGUF" -Port 8000 -CtxSize 16384 -InitWaitTime 15
# Verify health
$health = Invoke-RestMethod -Uri "http://localhost:8000/api/v1/health" -Method GET -TimeoutSec 10
if ($health.status -ne "ok") { throw "Lemonade health check failed" }
Write-Host "[OK] Lemonade Server ready with Qwen3-4B-Instruct-2507-GGUF"
# Run all C++ integration tests (LLM + MCP + WiFi + Health)
Write-Host "=== Running C++ Integration Tests (LLM + MCP + WiFi + Health) ==="
$env:GAIA_CPP_TEST_MODEL = "Qwen3-4B-Instruct-2507-GGUF"
$env:GAIA_CPP_BASE_URL = "http://localhost:8000/api/v1"
# -j 1: run tests sequentially so they don't compete for the single LLM server
ctest --test-dir cpp/build-integration -C Release --output-on-failure -j 1
if ($LASTEXITCODE -ne 0) { throw "C++ integration tests failed" }
Write-Host "[SUCCESS] All C++ integration tests passed!"
} catch {
Write-Host "[ERROR] $($_.Exception.Message)"
throw
} finally {
if ($env:LEMONADE_PROCESS_ID) {
Write-Host "Stopping Lemonade Server (PID $env:LEMONADE_PROCESS_ID)..."
Stop-Process -Id $env:LEMONADE_PROCESS_ID -Force -ErrorAction SilentlyContinue
}
}
- name: Upload server logs
if: always()
uses: actions/upload-artifact@v6
with:
name: cpp-integration-lemonade-logs
path: |
lemonade-server-stdout.log
lemonade-server-stderr.log
lemonade-server.log
# Performance benchmarks (runs after build passes)
benchmark:
name: C++ Benchmarks
needs: [build-and-test]
if: needs.build-and-test.result == 'success'
uses: ./.github/workflows/benchmark_cpp.yml
# Summary job
cpp-build-summary:
name: C++ Build Summary
runs-on: ubuntu-latest
needs: [build-and-test, install-test, shared-lib-test, integration-test, benchmark]
if: >-
${{ always() && !cancelled() &&
needs.build-and-test.result != 'cancelled' }}
steps:
- name: Check build results
run: |
echo "=== C++ Build & Test Summary ==="
echo "Build & Test: ${{ needs.build-and-test.result }}"
echo "Install Test: ${{ needs.install-test.result }}"
echo "Shared Lib Test: ${{ needs.shared-lib-test.result }}"
echo "Integration Tests: ${{ needs.integration-test.result }}"
echo "Benchmarks: ${{ needs.benchmark.result }}"
echo ""
if [[ "${{ needs.build-and-test.result }}" == "skipped" ]]; then
echo "All C++ jobs skipped (draft PR - add 'ready_for_ci' label to run)"
exit 0
fi
FAILED=0
[[ "${{ needs.build-and-test.result }}" != "success" ]] && FAILED=1
[[ "${{ needs.install-test.result }}" != "success" ]] && FAILED=1
[[ "${{ needs.shared-lib-test.result }}" != "success" ]] && FAILED=1
# Integration test runs on self-hosted STX hardware; treat
# 'skipped' and 'failure' as non-blocking (warn only) since the
# runner may lack tools like cmake in PATH.
if [[ "${{ needs.integration-test.result }}" == "failure" ]]; then
echo "::warning::Integration tests failed (STX runner infrastructure issue)"
fi
# Benchmarks are non-blocking (regression alerts are warnings only)
if [[ "${{ needs.benchmark.result }}" == "failure" ]]; then
echo "::warning::Benchmark regression detected — review cpp-benchmark-* artifacts"
fi
if [[ "$FAILED" == "0" ]]; then
echo "All required C++ jobs passed (unit tests, install round-trip, shared library)!"
else
echo "One or more required C++ jobs failed"
exit 1
fi