Integration tests in CI #13
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Tests | |
| on: | |
| push: | |
| branches: ["main"] | |
| paths: | |
| - src/** | |
| - include/** | |
| - client-sdk-rust/** | |
| - CMakeLists.txt | |
| - CMakePresets.json | |
| - build.sh | |
| - build.cmd | |
| - vcpkg.json | |
| - .token_helpers/** | |
| - .github/workflows/tests.yml | |
| pull_request: | |
| branches: ["main"] | |
| paths: | |
| - src/** | |
| - include/** | |
| - client-sdk-rust/** | |
| - CMakeLists.txt | |
| - CMakePresets.json | |
| - build.sh | |
| - build.cmd | |
| - vcpkg.json | |
| - .token_helpers/** | |
| - .github/workflows/tests.yml | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| actions: read | |
| packages: read | |
| env: | |
| CARGO_TERM_COLOR: always | |
| # vcpkg binary caching for Windows (mirrors builds.yml) | |
| VCPKG_DEFAULT_TRIPLET: x64-windows-static-md | |
| VCPKG_DEFAULT_HOST_TRIPLET: x64-windows-static-md | |
| VCPKG_TARGET_TRIPLET: x64-windows-static-md | |
| jobs: | |
| test: | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| name: linux-x64 | |
| - os: macos-latest-xlarge | |
| name: macos-arm64 | |
| - os: windows-latest | |
| name: windows-x64 | |
| name: Test (${{ matrix.name }}) | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout (with submodules) | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| submodules: recursive | |
| fetch-depth: 1 | |
| - name: Pull LFS files | |
| run: git lfs pull | |
| # ---------- vcpkg caching for Windows (mirrors builds.yml) ---------- | |
| - name: Export GitHub Actions cache environment variables | |
| if: runner.os == 'Windows' | |
| uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 | |
| 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@6fe69898af670ac05f4a8427cc5cff4fb361cee5 # v11.5 | |
| 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 \ | |
| jq | |
| - name: Install deps (macOS) | |
| if: runner.os == 'macOS' | |
| run: | | |
| set -eux | |
| brew update | |
| brew install cmake ninja protobuf abseil spdlog jq | |
| # ---------- Rust toolchain ---------- | |
| - name: Install Rust (stable) | |
| uses: dtolnay/rust-toolchain@3c5f7ea28cd621ae0bf5283f0e981fb97b8a7af9 | |
| with: | |
| toolchain: stable | |
| # ---------- Cache Cargo ---------- | |
| - name: Cache Cargo | |
| uses: Swatinem/rust-cache@c19371144df3bb44fab255c43d04cbc2ab54d1c4 # v2.9.1 | |
| with: | |
| workspaces: client-sdk-rust -> 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 (release-tests: tests on, examples off) ---------- | |
| - name: Build tests (Unix) | |
| if: runner.os != 'Windows' | |
| shell: bash | |
| run: | | |
| chmod +x build.sh | |
| ./build.sh release-tests | |
| - name: Build tests (Windows) | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| run: .\build.cmd release-tests | |
| # ---------- Run unit tests ---------- | |
| - name: Run unit tests (Unix) | |
| if: runner.os != 'Windows' | |
| timeout-minutes: 1 | |
| shell: bash | |
| run: | | |
| build-release/bin/livekit_unit_tests \ | |
| --gtest_output=xml:build-release/unit-test-results.xml | |
| - name: Run unit tests (Windows) | |
| if: runner.os == 'Windows' | |
| timeout-minutes: 1 | |
| shell: pwsh | |
| run: | | |
| build-release\bin\livekit_unit_tests.exe ` | |
| --gtest_output="xml:build-release\unit-test-results.xml" | |
| # ---------- Install + start livekit-server for integration tests ---------- | |
| - name: Install livekit-server and lk CLI (Unix) | |
| if: runner.os != 'Windows' | |
| shell: bash | |
| run: | | |
| set -euxo pipefail | |
| if [[ "$RUNNER_OS" == "Linux" ]]; then | |
| # Linux: official install scripts. lk's installer parses the GitHub | |
| # API JSON with jq (already installed above). | |
| curl -sSL https://get.livekit.io | bash | |
| curl -sSL https://get.livekit.io/cli | bash | |
| else | |
| # macOS: Homebrew formulas. Server install script aborts on Darwin. | |
| brew install livekit livekit-cli | |
| fi | |
| livekit-server --version | |
| lk --version | |
| - name: Install livekit-server and lk CLI (Windows) | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| env: | |
| # `gh release download` authenticates via GH_TOKEN. | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| $ErrorActionPreference = 'Stop' | |
| $bin = Join-Path $env:RUNNER_TEMP 'livekit-bin' | |
| New-Item -ItemType Directory -Force -Path $bin | Out-Null | |
| Push-Location $env:RUNNER_TEMP | |
| gh release download --repo livekit/livekit ` | |
| --pattern '*windows_amd64.zip' --output livekit-server.zip --clobber | |
| gh release download --repo livekit/livekit-cli ` | |
| --pattern 'lk_*_windows_amd64.zip' --output lk.zip --clobber | |
| Expand-Archive -Force -Path livekit-server.zip -DestinationPath livekit-server | |
| Expand-Archive -Force -Path lk.zip -DestinationPath lk | |
| Copy-Item livekit-server\livekit-server.exe $bin\ | |
| Copy-Item lk\lk.exe $bin\ | |
| Pop-Location | |
| # Persist on PATH for subsequent steps. | |
| Add-Content -Path $env:GITHUB_PATH -Value $bin | |
| & "$bin\livekit-server.exe" --version | |
| & "$bin\lk.exe" --version | |
| - name: Start livekit-server (Unix) | |
| if: runner.os != 'Windows' | |
| shell: bash | |
| env: | |
| LIVEKIT_CONFIG: "enable_data_tracks: true" | |
| run: | | |
| set -euxo pipefail | |
| # Background the server with nohup so it survives this step's shell | |
| # exit and remains running for the integration-test step. | |
| nohup livekit-server --dev > livekit-server.log 2>&1 & | |
| echo $! > livekit-server.pid | |
| # Port 7880 is a WebSocket endpoint, so a TCP-connect probe is the | |
| # most reliable readiness signal. | |
| for i in $(seq 1 30); do | |
| if nc -z 127.0.0.1 7880 >/dev/null 2>&1; then | |
| echo "livekit-server is ready" | |
| exit 0 | |
| fi | |
| sleep 1 | |
| done | |
| echo "::error::livekit-server failed to start within 30s" | |
| tail -n 200 livekit-server.log || true | |
| exit 1 | |
| - name: Start livekit-server (Windows) | |
| if: runner.os == 'Windows' | |
| shell: pwsh | |
| env: | |
| LIVEKIT_CONFIG: "enable_data_tracks: true" | |
| run: | | |
| $ErrorActionPreference = 'Stop' | |
| # Start-Process backgrounds livekit-server so it survives this step | |
| # and is reachable from the integration-test step. | |
| $proc = Start-Process -FilePath 'livekit-server' ` | |
| -ArgumentList '--dev' ` | |
| -RedirectStandardOutput 'livekit-server.log' ` | |
| -RedirectStandardError 'livekit-server-stderr.log' ` | |
| -NoNewWindow -PassThru | |
| $proc.Id | Out-File -Encoding ascii livekit-server.pid | |
| # TCP-connect probe to 127.0.0.1:7880 — the WebSocket endpoint. | |
| for ($i = 0; $i -lt 30; $i++) { | |
| try { | |
| $tcp = New-Object System.Net.Sockets.TcpClient | |
| $tcp.Connect('127.0.0.1', 7880) | |
| $tcp.Close() | |
| Write-Host 'livekit-server is ready' | |
| exit 0 | |
| } catch { | |
| Start-Sleep -Seconds 1 | |
| } | |
| } | |
| Write-Host '::error::livekit-server failed to start within 30s' | |
| if (Test-Path livekit-server.log) { Get-Content livekit-server.log -Tail 200 } | |
| if (Test-Path livekit-server-stderr.log) { Get-Content livekit-server-stderr.log -Tail 200 } | |
| exit 1 | |
| - name: Run integration tests | |
| timeout-minutes: 5 | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| source .token_helpers/set_data_track_test_tokens.bash | |
| test_exe=build-release/bin/livekit_integration_tests | |
| if [[ "$RUNNER_OS" == "Windows" ]]; then | |
| test_exe=${test_exe}.exe | |
| fi | |
| "${test_exe}" \ | |
| --gtest_output=xml:build-release/integration-test-results.xml | |
| - name: Stop livekit-server (Unix) | |
| if: always() && runner.os != 'Windows' | |
| shell: bash | |
| run: | | |
| if [ -f livekit-server.pid ]; then | |
| kill "$(cat livekit-server.pid)" 2>/dev/null || true | |
| rm -f livekit-server.pid | |
| fi | |
| - name: Stop livekit-server (Windows) | |
| if: always() && runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| if (Test-Path livekit-server.pid) { | |
| $serverPid = [int](Get-Content livekit-server.pid) | |
| Stop-Process -Id $serverPid -Force -ErrorAction SilentlyContinue | |
| Remove-Item livekit-server.pid -ErrorAction SilentlyContinue | |
| } | |
| - name: Dump livekit-server log on failure (Unix) | |
| if: failure() && runner.os != 'Windows' | |
| shell: bash | |
| run: tail -n 500 livekit-server.log || true | |
| - name: Dump livekit-server log on failure (Windows) | |
| if: failure() && runner.os == 'Windows' | |
| shell: pwsh | |
| run: | | |
| if (Test-Path livekit-server.log) { Get-Content livekit-server.log -Tail 500 } | |
| if (Test-Path livekit-server-stderr.log) { Get-Content livekit-server-stderr.log -Tail 500 } | |
| # ---------- Upload results ---------- | |
| - name: Upload test results | |
| if: always() | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: test-results-${{ matrix.name }} | |
| path: | | |
| build-release/unit-test-results.xml | |
| build-release/integration-test-results.xml | |
| livekit-server.log | |
| livekit-server-stderr.log | |
| if-no-files-found: ignore | |
| retention-days: 7 |