Skip to content

Commit 0aa60a3

Browse files
Integration tests in CI (#113)
1 parent 66254b4 commit 0aa60a3

19 files changed

Lines changed: 606 additions & 274 deletions

.github/workflows/builds.yml

Lines changed: 12 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,24 @@ jobs:
6565
include:
6666
- os: ubuntu-latest
6767
name: linux-x64
68-
build_cmd: ./build.sh release-all
68+
build_cmd: ./build.sh release-examples
6969
build_dir: build-release
7070
- os: ubuntu-24.04-arm
7171
name: linux-arm64
72-
build_cmd: ./build.sh release-all
72+
build_cmd: ./build.sh release-examples
7373
build_dir: build-release
74-
- os: macos-latest
74+
- os: macos-26-xlarge
7575
name: macos-arm64
76-
build_cmd: ./build.sh release-all
76+
build_cmd: ./build.sh release-examples
7777
build_dir: build-release
78-
- os: macos-latest
78+
- os: macos-26-large
7979
name: macos-x64
80-
build_cmd: ./build.sh release-all --macos-arch x86_64
80+
build_cmd: ./build.sh release-examples --macos-arch x86_64
8181
build_dir: build-release
82-
- os: windows-latest
82+
# Pinned to Windows 2022 for current VS 17 implementation
83+
- os: windows-2022
8384
name: windows-x64
84-
build_cmd: .\build.cmd release-all
85+
build_cmd: .\build.cmd release-examples
8586
build_dir: build-release
8687

8788
name: Build (${{ matrix.name }})
@@ -149,22 +150,10 @@ jobs:
149150
run: rustup target add x86_64-apple-darwin
150151

151152
# ---------- Cache Cargo ----------
152-
- name: Cache Cargo registry
153-
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
153+
- name: Cache Cargo
154+
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
154155
with:
155-
path: |
156-
~/.cargo/registry
157-
~/.cargo/git
158-
key: ${{ runner.os }}-${{ matrix.name }}-cargo-reg-${{ hashFiles('**/Cargo.lock') }}
159-
restore-keys: ${{ runner.os }}-${{ matrix.name }}-cargo-reg-
160-
161-
- name: Cache Cargo target
162-
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
163-
with:
164-
path: client-sdk-rust/target
165-
key: ${{ runner.os }}-${{ matrix.name }}-cargo-target-${{ hashFiles('**/Cargo.lock') }}
166-
restore-keys: |
167-
${{ runner.os }}-${{ matrix.name }}-cargo-target-
156+
workspaces: client-sdk-rust -> target
168157

169158
# ---------- Build environment setup ----------
170159
- name: Set Linux build environment
@@ -288,29 +277,6 @@ jobs:
288277
}
289278
if ($failed) { exit 1 } else { exit 0 }
290279
291-
# ---------- Run unit tests ----------
292-
- name: Run unit tests (Unix)
293-
if: runner.os != 'Windows'
294-
shell: bash
295-
run: |
296-
${{ matrix.build_dir }}/bin/livekit_unit_tests \
297-
--gtest_output=xml:${{ matrix.build_dir }}/unit-test-results.xml
298-
299-
- name: Run unit tests (Windows)
300-
if: runner.os == 'Windows'
301-
shell: pwsh
302-
run: |
303-
& "${{ matrix.build_dir }}/bin/livekit_unit_tests.exe" `
304-
--gtest_output=xml:${{ matrix.build_dir }}/unit-test-results.xml
305-
306-
- name: Upload test results
307-
if: always()
308-
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
309-
with:
310-
name: test-results-${{ matrix.name }}
311-
path: ${{ matrix.build_dir }}/unit-test-results.xml
312-
retention-days: 7
313-
314280
# ---------- Upload artifacts ----------
315281
- name: Upload build artifacts
316282
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1

.github/workflows/make-release.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ jobs:
3030
- os: ubuntu-24.04-arm
3131
name: linux-arm64
3232
generator: Ninja
33-
- os: macos-latest
33+
- os: macos-26-xlarge
3434
name: macos-arm64
3535
generator: Ninja
36-
- os: macos-latest
36+
- os: macos-26-large
3737
name: macos-x64
3838
generator: Ninja
39-
- os: windows-latest
39+
# Pinned to Windows 2022 for current VS 17 implementation
40+
- os: windows-2022
4041
name: windows-x64
4142
generator: "Visual Studio 17 2022"
4243

.github/workflows/tests.yml

Lines changed: 262 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,262 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
paths:
7+
- src/**
8+
- include/**
9+
- client-sdk-rust/**
10+
- CMakeLists.txt
11+
- CMakePresets.json
12+
- build.sh
13+
- build.cmd
14+
- vcpkg.json
15+
- .token_helpers/**
16+
- .github/workflows/tests.yml
17+
pull_request:
18+
branches: ["main"]
19+
paths:
20+
- src/**
21+
- include/**
22+
- client-sdk-rust/**
23+
- CMakeLists.txt
24+
- CMakePresets.json
25+
- build.sh
26+
- build.cmd
27+
- vcpkg.json
28+
- .token_helpers/**
29+
- .github/workflows/tests.yml
30+
workflow_dispatch:
31+
32+
permissions:
33+
contents: read
34+
actions: read
35+
packages: read
36+
37+
env:
38+
CARGO_TERM_COLOR: always
39+
# vcpkg binary caching for Windows (mirrors builds.yml)
40+
VCPKG_DEFAULT_TRIPLET: x64-windows-static-md
41+
VCPKG_DEFAULT_HOST_TRIPLET: x64-windows-static-md
42+
VCPKG_TARGET_TRIPLET: x64-windows-static-md
43+
44+
jobs:
45+
test:
46+
strategy:
47+
fail-fast: false
48+
matrix:
49+
include:
50+
- os: ubuntu-latest
51+
name: linux-x64
52+
build_cmd: ./build.sh release-tests
53+
e2e-testing: true
54+
- os: ubuntu-24.04-arm
55+
name: linux-arm64
56+
build_cmd: ./build.sh release-tests
57+
e2e-testing: true
58+
- os: macos-26-xlarge
59+
name: macos-arm64
60+
build_cmd: ./build.sh release-tests
61+
# E2E not possible on GHA Mac runner currently
62+
e2e-testing: false
63+
- os: macos-26-large
64+
name: macos-x64
65+
build_cmd: ./build.sh release-tests --macos-arch x86_64
66+
# E2E not possible on GHA Mac runner currently
67+
e2e-testing: false
68+
# Pinned to Windows 2022 for current VS 17 implementation
69+
- os: windows-2022
70+
name: windows-x64
71+
build_cmd: .\build.cmd release-tests
72+
73+
name: Test (${{ matrix.name }})
74+
runs-on: ${{ matrix.os }}
75+
76+
steps:
77+
- name: Checkout (with submodules)
78+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
79+
with:
80+
submodules: recursive
81+
fetch-depth: 1
82+
83+
- name: Pull LFS files
84+
run: git lfs pull
85+
86+
# ---------- vcpkg caching for Windows (mirrors builds.yml) ----------
87+
- name: Export GitHub Actions cache environment variables
88+
if: runner.os == 'Windows'
89+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
90+
with:
91+
script: |
92+
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
93+
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
94+
95+
- name: Setup vcpkg (Windows only)
96+
if: runner.os == 'Windows'
97+
uses: lukka/run-vcpkg@6fe69898af670ac05f4a8427cc5cff4fb361cee5 # v11.5
98+
with:
99+
vcpkgGitCommitId: 'fb87e2bb3fe69e16c224989acb5a61349166c782'
100+
101+
# ---------- OS-specific deps ----------
102+
- name: Install deps (Ubuntu)
103+
if: runner.os == 'Linux'
104+
run: |
105+
set -eux
106+
sudo apt-get update
107+
sudo apt-get install -y \
108+
build-essential cmake ninja-build pkg-config \
109+
llvm-dev libclang-dev clang \
110+
libva-dev libdrm-dev libgbm-dev libx11-dev libgl1-mesa-dev \
111+
libxext-dev libxcomposite-dev libxdamage-dev libxfixes-dev \
112+
libxrandr-dev libxi-dev libxkbcommon-dev \
113+
libasound2-dev libpulse-dev \
114+
libssl-dev \
115+
libprotobuf-dev protobuf-compiler \
116+
libabsl-dev \
117+
libwayland-dev libdecor-0-dev \
118+
libspdlog-dev \
119+
jq
120+
121+
- name: Install deps (macOS)
122+
if: runner.os == 'macOS'
123+
run: |
124+
set -eux
125+
brew update
126+
brew install cmake ninja protobuf abseil spdlog jq
127+
128+
# ---------- Rust toolchain ----------
129+
- name: Install Rust (stable)
130+
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9
131+
with:
132+
toolchain: stable
133+
134+
- name: Install Rust cross-compilation target
135+
if: matrix.name == 'macos-x64'
136+
run: rustup target add x86_64-apple-darwin
137+
138+
# ---------- Cache Cargo ----------
139+
- name: Cache Cargo
140+
uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1
141+
with:
142+
workspaces: client-sdk-rust -> target
143+
144+
# ---------- Build environment setup ----------
145+
- name: Set Linux build environment
146+
if: runner.os == 'Linux'
147+
run: |
148+
echo "CXXFLAGS=-Wno-deprecated-declarations" >> $GITHUB_ENV
149+
echo "CFLAGS=-Wno-deprecated-declarations" >> $GITHUB_ENV
150+
LLVM_VERSION=$(llvm-config --version | cut -d. -f1)
151+
echo "LIBCLANG_PATH=/usr/lib/llvm-${LLVM_VERSION}/lib" >> $GITHUB_ENV
152+
153+
# ---------- Build (release-tests: tests on, examples off) ----------
154+
- name: Build tests (Unix)
155+
if: runner.os != 'Windows'
156+
shell: bash
157+
run: |
158+
chmod +x build.sh
159+
${{ matrix.build_cmd }}
160+
161+
- name: Build tests (Windows)
162+
if: runner.os == 'Windows'
163+
shell: pwsh
164+
run: ${{ matrix.build_cmd }}
165+
166+
# ---------- Run unit tests ----------
167+
- name: Run unit tests (Unix)
168+
if: runner.os != 'Windows'
169+
timeout-minutes: 1
170+
shell: bash
171+
run: |
172+
build-release/bin/livekit_unit_tests \
173+
--gtest_output=xml:build-release/unit-test-results.xml
174+
175+
- name: Run unit tests (Windows)
176+
if: runner.os == 'Windows'
177+
timeout-minutes: 1
178+
shell: pwsh
179+
run: |
180+
build-release\bin\livekit_unit_tests.exe `
181+
--gtest_output="xml:build-release\unit-test-results.xml"
182+
183+
# ---------- Install + start livekit-server for integration tests ----------
184+
- name: Install livekit-server and lk CLI
185+
if: matrix.e2e-testing
186+
shell: bash
187+
run: |
188+
set -euxo pipefail
189+
if [[ "$RUNNER_OS" == "Linux" ]]; then
190+
# Linux: official install scripts. lk's installer parses the GitHub
191+
# API JSON with jq (already installed above).
192+
curl -sSL https://get.livekit.io | bash
193+
curl -sSL https://get.livekit.io/cli | bash
194+
else
195+
# macOS: Homebrew formulas. Server install script aborts on Darwin.
196+
brew install livekit livekit-cli
197+
fi
198+
livekit-server --version
199+
lk --version
200+
201+
- name: Start livekit-server
202+
if: matrix.e2e-testing
203+
shell: bash
204+
env:
205+
LIVEKIT_CONFIG: "enable_data_tracks: true"
206+
run: |
207+
set -euxo pipefail
208+
# Background the server with nohup so it survives this step's shell
209+
# exit and remains running for the integration-test step.
210+
nohup livekit-server --dev > livekit-server.log 2>&1 &
211+
echo $! > livekit-server.pid
212+
# Port 7880 is a WebSocket endpoint, so a TCP-connect probe is the
213+
# most reliable readiness signal.
214+
for i in $(seq 1 30); do
215+
if nc -z 127.0.0.1 7880 >/dev/null 2>&1; then
216+
echo "livekit-server is ready"
217+
exit 0
218+
fi
219+
sleep 1
220+
done
221+
echo "::error::livekit-server failed to start within 30s"
222+
tail -n 200 livekit-server.log || true
223+
exit 1
224+
225+
- name: Run integration tests
226+
if: matrix.e2e-testing
227+
timeout-minutes: 5
228+
shell: bash
229+
env:
230+
RUST_LOG: "metrics=debug"
231+
run: |
232+
set -euo pipefail
233+
source .token_helpers/set_data_track_test_tokens.bash
234+
build-release/bin/livekit_integration_tests \
235+
--gtest_output=xml:build-release/integration-test-results.xml
236+
237+
- name: Stop livekit-server
238+
if: always() && matrix.e2e-testing
239+
shell: bash
240+
run: |
241+
if [ -f livekit-server.pid ]; then
242+
kill "$(cat livekit-server.pid)" 2>/dev/null || true
243+
rm -f livekit-server.pid
244+
fi
245+
246+
- name: Dump livekit-server log on failure
247+
if: failure() && matrix.e2e-testing
248+
shell: bash
249+
run: tail -n 500 livekit-server.log || true
250+
251+
# ---------- Upload results ----------
252+
- name: Upload test results
253+
if: always()
254+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
255+
with:
256+
name: test-results-${{ matrix.name }}
257+
path: |
258+
build-release/unit-test-results.xml
259+
build-release/integration-test-results.xml
260+
livekit-server.log
261+
if-no-files-found: ignore
262+
retention-days: 7

.token_helpers/README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ Examples of generating tokens
55
Generate tokens and then set them as env vars for the current terminal session
66

77
## set_data_track_test_tokens.bash
8-
Generate tokens for data track integration tests and set them as env vars for the current terminal session.
8+
Generate the two participant tokens required by the C++ SDK's integration
9+
and stress test suites (data tracks, RPC, media multistream, etc.) and
10+
export them as `LIVEKIT_TOKEN_A`, `LIVEKIT_TOKEN_B`, and `LIVEKIT_URL` for
11+
the current terminal session.

0 commit comments

Comments
 (0)