Skip to content

Commit 634be84

Browse files
Try separate tests.yml stage
1 parent e3a2470 commit 634be84

2 files changed

Lines changed: 219 additions & 99 deletions

File tree

.github/workflows/builds.yml

Lines changed: 5 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -65,23 +65,23 @@ 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
7474
- os: macos-latest
7575
name: macos-arm64
76-
build_cmd: ./build.sh release-all
76+
build_cmd: ./build.sh release-examples
7777
build_dir: build-release
7878
- os: macos-latest
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
8282
- os: windows-latest
8383
name: windows-x64
84-
build_cmd: .\build.cmd release-all
84+
build_cmd: .\build.cmd release-examples
8585
build_dir: build-release
8686

8787
name: Build (${{ matrix.name }})
@@ -288,100 +288,6 @@ jobs:
288288
}
289289
if ($failed) { exit 1 } else { exit 0 }
290290
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-
# ---------- Run integration tests (Linux only) ----------
307-
# Integration tests require a live LiveKit server. The official
308-
# install scripts (https://get.livekit.io and https://get.livekit.io/cli)
309-
# are Linux-only today; macOS/Windows runners are skipped here and
310-
# tracked as deferred work.
311-
- name: Install livekit-server and lk CLI (Linux)
312-
if: runner.os == 'Linux'
313-
shell: bash
314-
run: |
315-
set -euxo pipefail
316-
# The lk installer parses GitHub's API JSON with jq. jq is on the
317-
# GitHub-hosted Linux runner image today; install defensively in
318-
# case that ever changes.
319-
sudo apt-get update
320-
sudo apt-get install -y jq curl
321-
curl -sSL https://get.livekit.io | bash
322-
curl -sSL https://get.livekit.io/cli | bash
323-
livekit-server --version
324-
lk --version
325-
326-
- name: Start livekit-server (Linux)
327-
if: runner.os == 'Linux'
328-
shell: bash
329-
env:
330-
LIVEKIT_CONFIG: "enable_data_tracks: true"
331-
run: |
332-
set -euxo pipefail
333-
# Background the server; nohup detaches it from this step's shell so
334-
# it survives into the next step.
335-
nohup livekit-server --dev > livekit-server.log 2>&1 &
336-
echo $! > livekit-server.pid
337-
# Port 7880 is a WebSocket endpoint, so a TCP-connect check (nc -z)
338-
# is the most reliable signal that the server has bound the port.
339-
for i in $(seq 1 30); do
340-
if nc -z 127.0.0.1 7880 >/dev/null 2>&1; then
341-
echo "livekit-server is ready"
342-
exit 0
343-
fi
344-
sleep 1
345-
done
346-
echo "::error::livekit-server failed to start within 30s"
347-
tail -n 200 livekit-server.log || true
348-
exit 1
349-
350-
- name: Run integration tests (Linux)
351-
if: runner.os == 'Linux'
352-
shell: bash
353-
run: |
354-
set -euo pipefail
355-
source .token_helpers/set_data_track_test_tokens.bash
356-
${{ matrix.build_dir }}/bin/livekit_integration_tests \
357-
--gtest_output=xml:${{ matrix.build_dir }}/integration-test-results.xml
358-
359-
- name: Stop livekit-server (Linux)
360-
if: always() && runner.os == 'Linux'
361-
shell: bash
362-
run: |
363-
if [ -f livekit-server.pid ]; then
364-
kill "$(cat livekit-server.pid)" 2>/dev/null || true
365-
rm -f livekit-server.pid
366-
fi
367-
368-
- name: Dump livekit-server log on failure (Linux)
369-
if: failure() && runner.os == 'Linux'
370-
shell: bash
371-
run: tail -n 500 livekit-server.log || true
372-
373-
- name: Upload test results
374-
if: always()
375-
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
376-
with:
377-
name: test-results-${{ matrix.name }}
378-
path: |
379-
${{ matrix.build_dir }}/unit-test-results.xml
380-
${{ matrix.build_dir }}/integration-test-results.xml
381-
livekit-server.log
382-
if-no-files-found: ignore
383-
retention-days: 7
384-
385291
# ---------- Upload artifacts ----------
386292
- name: Upload build artifacts
387293
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1

.github/workflows/tests.yml

Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
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+
40+
jobs:
41+
test:
42+
strategy:
43+
fail-fast: false
44+
matrix:
45+
include:
46+
- os: ubuntu-latest
47+
name: linux-x64
48+
- os: macos-latest
49+
name: macos-arm64
50+
51+
name: Test (${{ matrix.name }})
52+
runs-on: ${{ matrix.os }}
53+
54+
steps:
55+
- name: Checkout (with submodules)
56+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
57+
with:
58+
submodules: recursive
59+
fetch-depth: 1
60+
61+
- name: Pull LFS files
62+
run: git lfs pull
63+
64+
# ---------- OS-specific deps ----------
65+
- name: Install deps (Ubuntu)
66+
if: runner.os == 'Linux'
67+
run: |
68+
set -eux
69+
sudo apt-get update
70+
sudo apt-get install -y \
71+
build-essential cmake ninja-build pkg-config \
72+
llvm-dev libclang-dev clang \
73+
libva-dev libdrm-dev libgbm-dev libx11-dev libgl1-mesa-dev \
74+
libxext-dev libxcomposite-dev libxdamage-dev libxfixes-dev \
75+
libxrandr-dev libxi-dev libxkbcommon-dev \
76+
libasound2-dev libpulse-dev \
77+
libssl-dev \
78+
libprotobuf-dev protobuf-compiler \
79+
libabsl-dev \
80+
libwayland-dev libdecor-0-dev \
81+
libspdlog-dev \
82+
jq
83+
84+
- name: Install deps (macOS)
85+
if: runner.os == 'macOS'
86+
run: |
87+
set -eux
88+
brew update
89+
brew install cmake ninja protobuf abseil spdlog jq
90+
91+
# ---------- Rust toolchain ----------
92+
- name: Install Rust (stable)
93+
uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9
94+
with:
95+
toolchain: stable
96+
97+
# ---------- Cache Cargo ----------
98+
# Share cache keys with builds.yml so the two workflows reuse each
99+
# other's cargo registry / target output instead of doubling network
100+
# and disk I/O.
101+
- name: Cache Cargo registry
102+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
103+
with:
104+
path: |
105+
~/.cargo/registry
106+
~/.cargo/git
107+
key: ${{ runner.os }}-${{ matrix.name }}-cargo-reg-${{ hashFiles('**/Cargo.lock') }}
108+
restore-keys: ${{ runner.os }}-${{ matrix.name }}-cargo-reg-
109+
110+
- name: Cache Cargo target
111+
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
112+
with:
113+
path: client-sdk-rust/target
114+
key: ${{ runner.os }}-${{ matrix.name }}-cargo-target-${{ hashFiles('**/Cargo.lock') }}
115+
restore-keys: |
116+
${{ runner.os }}-${{ matrix.name }}-cargo-target-
117+
118+
# ---------- Build environment setup ----------
119+
- name: Set Linux build environment
120+
if: runner.os == 'Linux'
121+
run: |
122+
echo "CXXFLAGS=-Wno-deprecated-declarations" >> $GITHUB_ENV
123+
echo "CFLAGS=-Wno-deprecated-declarations" >> $GITHUB_ENV
124+
LLVM_VERSION=$(llvm-config --version | cut -d. -f1)
125+
echo "LIBCLANG_PATH=/usr/lib/llvm-${LLVM_VERSION}/lib" >> $GITHUB_ENV
126+
127+
# ---------- Build (release-tests: tests on, examples off) ----------
128+
- name: Build tests
129+
shell: bash
130+
run: |
131+
chmod +x build.sh
132+
./build.sh release-tests
133+
134+
# ---------- Run unit tests ----------
135+
- name: Run unit tests
136+
shell: bash
137+
run: |
138+
build-release/bin/livekit_unit_tests \
139+
--gtest_output=xml:build-release/unit-test-results.xml
140+
141+
# ---------- Install + start livekit-server for integration tests ----------
142+
- name: Install livekit-server and lk CLI
143+
shell: bash
144+
run: |
145+
set -euxo pipefail
146+
if [[ "$RUNNER_OS" == "Linux" ]]; then
147+
# Linux: official install scripts. lk's installer parses the GitHub
148+
# API JSON with jq (already installed above).
149+
curl -sSL https://get.livekit.io | bash
150+
curl -sSL https://get.livekit.io/cli | bash
151+
else
152+
# macOS: Homebrew formulas. Server install script aborts on Darwin.
153+
brew install livekit livekit-cli
154+
fi
155+
livekit-server --version
156+
lk --version
157+
158+
- name: Start livekit-server
159+
shell: bash
160+
env:
161+
LIVEKIT_CONFIG: "enable_data_tracks: true"
162+
run: |
163+
set -euxo pipefail
164+
# Background the server with nohup so it survives this step's shell
165+
# exit and remains running for the integration-test step.
166+
nohup livekit-server --dev > livekit-server.log 2>&1 &
167+
echo $! > livekit-server.pid
168+
# Port 7880 is a WebSocket endpoint, so a TCP-connect probe is the
169+
# most reliable readiness signal.
170+
for i in $(seq 1 30); do
171+
if nc -z 127.0.0.1 7880 >/dev/null 2>&1; then
172+
echo "livekit-server is ready"
173+
exit 0
174+
fi
175+
sleep 1
176+
done
177+
echo "::error::livekit-server failed to start within 30s"
178+
tail -n 200 livekit-server.log || true
179+
exit 1
180+
181+
- name: Run integration tests
182+
shell: bash
183+
run: |
184+
set -euo pipefail
185+
source .token_helpers/set_data_track_test_tokens.bash
186+
build-release/bin/livekit_integration_tests \
187+
--gtest_output=xml:build-release/integration-test-results.xml
188+
189+
- name: Stop livekit-server
190+
if: always()
191+
shell: bash
192+
run: |
193+
if [ -f livekit-server.pid ]; then
194+
kill "$(cat livekit-server.pid)" 2>/dev/null || true
195+
rm -f livekit-server.pid
196+
fi
197+
198+
- name: Dump livekit-server log on failure
199+
if: failure()
200+
shell: bash
201+
run: tail -n 500 livekit-server.log || true
202+
203+
# ---------- Upload results ----------
204+
- name: Upload test results
205+
if: always()
206+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
207+
with:
208+
name: test-results-${{ matrix.name }}
209+
path: |
210+
build-release/unit-test-results.xml
211+
build-release/integration-test-results.xml
212+
livekit-server.log
213+
if-no-files-found: ignore
214+
retention-days: 7

0 commit comments

Comments
 (0)