|
| 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 |
0 commit comments