|
| 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