|
| 1 | +# Copyright 2026 LiveKit, Inc. |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +name: Smoke test example binaries |
| 16 | +description: Run the example collection help commands through the built SDK. |
| 17 | +inputs: |
| 18 | + build-dir: |
| 19 | + description: SDK CMake build directory. |
| 20 | + required: true |
| 21 | +runs: |
| 22 | + using: composite |
| 23 | + steps: |
| 24 | + - name: Smoke test examples (Unix) |
| 25 | + if: runner.os != 'Windows' |
| 26 | + shell: bash |
| 27 | + run: | |
| 28 | + set -x |
| 29 | + failed=false |
| 30 | + examples_base="${{ inputs.build-dir }}/cpp-example-collection-build" |
| 31 | + resolve_exe() { |
| 32 | + local dir="$1" name="$2" |
| 33 | + local p="${examples_base}/${dir}/${name}" |
| 34 | + if [[ -x "${p}" ]]; then |
| 35 | + printf '%s' "${p}" |
| 36 | + return 0 |
| 37 | + fi |
| 38 | + p="${examples_base}/${dir}/Release/${name}" |
| 39 | + if [[ -x "${p}" ]]; then |
| 40 | + printf '%s' "${p}" |
| 41 | + return 0 |
| 42 | + fi |
| 43 | + return 1 |
| 44 | + } |
| 45 | + for pair in "SimpleRoom:simple_room" "SimpleRpc:simple_rpc" "SimpleDataStream:simple_data_stream"; do |
| 46 | + exe="${pair%%:*}" |
| 47 | + dir="${pair#*:}" |
| 48 | + if ! exe_path="$(resolve_exe "${dir}" "${exe}")"; then |
| 49 | + echo "ERROR: ${exe} not found under ${examples_base}/${dir}/" |
| 50 | + failed=true |
| 51 | + continue |
| 52 | + fi |
| 53 | + echo "Testing ${exe}..." |
| 54 | + output=$("${exe_path}" --help 2>&1) || true |
| 55 | + if [[ -z "${output}" ]]; then |
| 56 | + echo "ERROR: ${exe} produced no output" |
| 57 | + failed=true |
| 58 | + else |
| 59 | + echo "${output}" |
| 60 | + echo "${exe} ran successfully" |
| 61 | + fi |
| 62 | + done |
| 63 | + if [[ "$failed" == "true" ]]; then exit 1; fi |
| 64 | +
|
| 65 | + - name: Smoke test examples (Windows) |
| 66 | + if: runner.os == 'Windows' |
| 67 | + shell: pwsh |
| 68 | + run: | |
| 69 | + $ErrorActionPreference = 'Continue' |
| 70 | + $examplesBase = "${{ inputs.build-dir }}/cpp-example-collection-build" |
| 71 | + $examples = @( |
| 72 | + @{ Name = 'SimpleRoom'; Dir = 'simple_room' }, |
| 73 | + @{ Name = 'SimpleRpc'; Dir = 'simple_rpc' }, |
| 74 | + @{ Name = 'SimpleDataStream'; Dir = 'simple_data_stream' } |
| 75 | + ) |
| 76 | + $failed = $false |
| 77 | + foreach ($ex in $examples) { |
| 78 | + $name = $ex.Name |
| 79 | + $dir = $ex.Dir |
| 80 | + $inDir = Join-Path $examplesBase $dir |
| 81 | + $candidates = @( |
| 82 | + (Join-Path $inDir "$name.exe"), |
| 83 | + (Join-Path (Join-Path $inDir 'Release') "$name.exe") |
| 84 | + ) |
| 85 | + $exePath = $null |
| 86 | + foreach ($p in $candidates) { |
| 87 | + if (Test-Path -LiteralPath $p) { |
| 88 | + $exePath = $p |
| 89 | + break |
| 90 | + } |
| 91 | + } |
| 92 | + if ($null -ne $exePath) { |
| 93 | + Write-Host "Testing ${name}..." |
| 94 | + $pinfo = New-Object System.Diagnostics.ProcessStartInfo |
| 95 | + $pinfo.FileName = $exePath |
| 96 | + $pinfo.Arguments = "--help" |
| 97 | + $pinfo.RedirectStandardOutput = $true |
| 98 | + $pinfo.RedirectStandardError = $true |
| 99 | + $pinfo.UseShellExecute = $false |
| 100 | + $p = New-Object System.Diagnostics.Process |
| 101 | + $p.StartInfo = $pinfo |
| 102 | + $p.Start() | Out-Null |
| 103 | + $stdout = $p.StandardOutput.ReadToEnd() |
| 104 | + $stderr = $p.StandardError.ReadToEnd() |
| 105 | + $p.WaitForExit() |
| 106 | + $output = $stdout + $stderr |
| 107 | + if ([string]::IsNullOrWhiteSpace($output)) { |
| 108 | + Write-Host "ERROR: ${name} produced no output" |
| 109 | + $failed = $true |
| 110 | + } else { |
| 111 | + Write-Host $output |
| 112 | + Write-Host "${name} ran successfully" |
| 113 | + } |
| 114 | + } else { |
| 115 | + Write-Host "ERROR: ${name} not found under ${examplesBase}/${dir}/" |
| 116 | + $failed = $true |
| 117 | + } |
| 118 | + } |
| 119 | + if ($failed) { exit 1 } else { exit 0 } |
| 120 | +
|
0 commit comments