-
Notifications
You must be signed in to change notification settings - Fork 21
384 lines (341 loc) · 12.1 KB
/
builds.yml
File metadata and controls
384 lines (341 loc) · 12.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
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
name: Builds
on:
push:
branches: ["main"]
paths:
- src/**
- include/**
- examples/**
- bridge/**
- client-sdk-rust/**
- CMakeLists.txt
- build.sh
- build.cmd
- vcpkg.json
- CMakePresets.json
- docker/Dockerfile
- .github/workflows/**
pull_request:
branches: ["main"]
paths:
- src/**
- include/**
- examples/**
- bridge/**
- client-sdk-rust/**
- CMakeLists.txt
- build.sh
- build.cmd
- vcpkg.json
- CMakePresets.json
- docker/Dockerfile
- .github/workflows/**
workflow_dispatch:
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
# vcpkg binary caching for Windows
VCPKG_DEFAULT_TRIPLET: x64-windows-static-md
VCPKG_DEFAULT_HOST_TRIPLET: x64-windows-static-md
VCPKG_TARGET_TRIPLET: x64-windows-static-md
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
name: linux-x64
build_cmd: ./build.sh release-examples
build_dir: build-release
- os: ubuntu-24.04-arm
name: linux-arm64
build_cmd: ./build.sh release-examples
build_dir: build-release
- os: macos-latest
name: macos-arm64
build_cmd: ./build.sh release-examples
build_dir: build-release
- os: macos-latest
name: macos-x64
build_cmd: ./build.sh release-examples --macos-arch x86_64
build_dir: build-release
- os: windows-latest
name: windows-x64
build_cmd: .\build.cmd release-examples
build_dir: build-release
name: Build (${{ matrix.name }})
runs-on: ${{ matrix.os }}
steps:
- name: Checkout (with submodules)
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
# ---------- vcpkg caching for Windows ----------
- name: Export GitHub Actions cache environment variables
if: runner.os == 'Windows'
uses: actions/github-script@v7
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Setup vcpkg (Windows only)
if: runner.os == 'Windows'
uses: lukka/run-vcpkg@v11
with:
vcpkgGitCommitId: 'fb87e2bb3fe69e16c224989acb5a61349166c782'
# ---------- OS-specific deps ----------
- name: Install deps (Ubuntu)
if: runner.os == 'Linux'
run: |
set -eux
sudo apt-get update
sudo apt-get install -y \
build-essential cmake ninja-build pkg-config \
llvm-dev libclang-dev clang \
libva-dev libdrm-dev libgbm-dev libx11-dev libgl1-mesa-dev \
libxext-dev libxcomposite-dev libxdamage-dev libxfixes-dev \
libxrandr-dev libxi-dev libxkbcommon-dev \
libasound2-dev libpulse-dev \
libssl-dev \
libprotobuf-dev protobuf-compiler \
libabsl-dev \
libwayland-dev libdecor-0-dev \
libspdlog-dev
- name: Install deps (macOS)
if: runner.os == 'macOS'
run: |
set -eux
brew update
brew install cmake ninja protobuf abseil spdlog
# ---------- Rust toolchain ----------
- name: Install Rust (stable)
uses: dtolnay/rust-toolchain@stable
- name: Install Rust cross-compilation target
if: matrix.name == 'macos-x64'
run: rustup target add x86_64-apple-darwin
# ---------- Cache Cargo ----------
- name: Cache Cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-${{ matrix.name }}-cargo-reg-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ runner.os }}-${{ matrix.name }}-cargo-reg-
- name: Cache Cargo target
uses: actions/cache@v4
with:
path: client-sdk-rust/target
key: ${{ runner.os }}-${{ matrix.name }}-cargo-target-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.name }}-cargo-target-
# ---------- Build environment setup ----------
- name: Set Linux build environment
if: runner.os == 'Linux'
run: |
echo "CXXFLAGS=-Wno-deprecated-declarations" >> $GITHUB_ENV
echo "CFLAGS=-Wno-deprecated-declarations" >> $GITHUB_ENV
LLVM_VERSION=$(llvm-config --version | cut -d. -f1)
echo "LIBCLANG_PATH=/usr/lib/llvm-${LLVM_VERSION}/lib" >> $GITHUB_ENV
# ---------- Build ----------
- name: Build (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
chmod +x build.sh
${{ matrix.build_cmd }}
- name: Build (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: ${{ matrix.build_cmd }}
# ---------- Smoke test examples ----------
- name: Smoke test examples (Unix)
if: runner.os != 'Windows'
shell: bash
run: |
set -x
failed=false
for exe in SimpleRoom SimpleRpc SimpleDataStream; do
exe_path="${{ matrix.build_dir }}/bin/${exe}"
if [[ -x "${exe_path}" ]]; then
echo "Testing ${exe}..."
output=$("${exe_path}" --help 2>&1) || true
if [[ -z "${output}" ]]; then
echo "ERROR: ${exe} produced no output"
failed=true
else
echo "${output}"
echo "${exe} ran successfully"
fi
else
echo "ERROR: ${exe_path} not found or not executable"
failed=true
fi
done
if [[ "$failed" == "true" ]]; then exit 1; fi
- name: Smoke test examples (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
$ErrorActionPreference = 'Continue'
$examples = @('SimpleRoom', 'SimpleRpc', 'SimpleDataStream')
$failed = $false
foreach ($exe in $examples) {
$exePath = "${{ matrix.build_dir }}/bin/${exe}.exe"
if (Test-Path $exePath) {
Write-Host "Testing ${exe}..."
$pinfo = New-Object System.Diagnostics.ProcessStartInfo
$pinfo.FileName = $exePath
$pinfo.Arguments = "--help"
$pinfo.RedirectStandardOutput = $true
$pinfo.RedirectStandardError = $true
$pinfo.UseShellExecute = $false
$p = New-Object System.Diagnostics.Process
$p.StartInfo = $pinfo
$p.Start() | Out-Null
$stdout = $p.StandardOutput.ReadToEnd()
$stderr = $p.StandardError.ReadToEnd()
$p.WaitForExit()
$output = $stdout + $stderr
if ([string]::IsNullOrWhiteSpace($output)) {
Write-Host "ERROR: ${exe} produced no output"
$failed = $true
} else {
Write-Host $output
Write-Host "${exe} ran successfully"
}
} else {
Write-Host "ERROR: ${exePath} not found"
$failed = $true
}
}
if ($failed) { exit 1 } else { exit 0 }
# ---------- Upload artifacts ----------
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: livekit-sdk-${{ matrix.name }}
path: |
${{ matrix.build_dir }}/lib/
${{ matrix.build_dir }}/include/
${{ matrix.build_dir }}/bin/
retention-days: 7
# ---------- Cleanup ----------
- name: Clean after build (best-effort)
if: always()
shell: bash
run: |
if [[ "$RUNNER_OS" == "Windows" ]]; then
rm -rf build-release build-debug || true
else
./build.sh clean-all || true
fi
docker-build-x64:
name: Build (docker-linux-x64)
runs-on: ubuntu-latest
steps:
- name: Checkout (with submodules)
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
run: |
docker buildx build \
--platform linux/amd64 \
--load \
-t livekit-cpp-sdk-x64:${{ github.sha }} \
. \
-f docker/Dockerfile
- name: Verify installed SDK inside image
run: |
docker run --rm livekit-cpp-sdk-x64:${{ github.sha }} bash -c \
'test -f /opt/livekit-sdk/lib/cmake/LiveKit/LiveKitConfig.cmake'
- name: Save Docker image artifact
run: |
docker save livekit-cpp-sdk-x64:${{ github.sha }} | gzip > livekit-cpp-sdk-x64-docker.tar.gz
- name: Upload Docker image artifact
uses: actions/upload-artifact@v4
with:
name: livekit-cpp-sdk-docker-x64
path: livekit-cpp-sdk-x64-docker.tar.gz
retention-days: 7
docker-build-linux-arm64:
name: Build (docker-linux-arm64)
runs-on: ubuntu-24.04-arm
steps:
- name: Checkout (with submodules)
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
run: |
docker buildx build \
--platform linux/arm64 \
--load \
-t livekit-cpp-sdk:${{ github.sha }} \
. \
-f docker/Dockerfile
- name: Verify installed SDK inside image
run: |
docker run --rm livekit-cpp-sdk:${{ github.sha }} bash -c \
'test -f /opt/livekit-sdk/lib/cmake/LiveKit/LiveKitConfig.cmake'
- name: Save Docker image artifact
run: |
docker save livekit-cpp-sdk:${{ github.sha }} | gzip > livekit-cpp-sdk-arm64-docker.tar.gz
- name: Upload Docker image artifact
uses: actions/upload-artifact@v4
with:
name: livekit-cpp-sdk-docker-arm64
path: livekit-cpp-sdk-arm64-docker.tar.gz
retention-days: 7
build-collections-linux-arm64:
name: Build (cpp-example-collection-linux-arm64)
runs-on: ubuntu-24.04-arm
needs: docker-build-linux-arm64
steps:
- name: Download Docker image artifact
uses: actions/download-artifact@v4
with:
name: livekit-cpp-sdk-docker-arm64
- name: Load Docker image
run: gzip -dc livekit-cpp-sdk-arm64-docker.tar.gz | docker load
- name: Build cpp-example-collection against installed SDK
run: |
docker run --rm livekit-cpp-sdk:${{ github.sha }} bash -lc '
set -euxo pipefail
git clone https://github.com/livekit-examples/cpp-example-collection.git /tmp/cpp-example-collection
cd /tmp/cpp-example-collection
git checkout sderosa/examples-migration
cmake -S . -B build -DLIVEKIT_LOCAL_SDK_DIR=/opt/livekit-sdk
cmake --build build --parallel
'
build-collections-x64:
name: Build (cpp-example-collection-x64)
runs-on: ubuntu-latest
needs: docker-build-x64
steps:
- name: Download Docker image artifact
uses: actions/download-artifact@v4
with:
name: livekit-cpp-sdk-docker-x64
- name: Load Docker image
run: gzip -dc livekit-cpp-sdk-x64-docker.tar.gz | docker load
- name: Build cpp-example-collection against installed SDK
run: |
docker run --rm livekit-cpp-sdk-x64:${{ github.sha }} bash -lc '
set -euxo pipefail
git clone https://github.com/livekit-examples/cpp-example-collection.git /tmp/cpp-example-collection
cd /tmp/cpp-example-collection
git checkout sderosa/examples-migration
cmake -S . -B build -DLIVEKIT_LOCAL_SDK_DIR=/opt/livekit-sdk
cmake --build build --parallel
'