Skip to content

Commit 9d6b121

Browse files
pipelines/testing for specific capture sources
1 parent fd8942d commit 9d6b121

11 files changed

Lines changed: 461 additions & 53 deletions

File tree

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
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: Test one selective capture bundle
16+
description: Restore, build, verify, cache, and release one source variant's Cargo output.
17+
inputs:
18+
preset:
19+
description: SDK build preset without tests or examples (debug or release).
20+
default: release
21+
sources:
22+
description: Comma-separated capture sources for this variant.
23+
required: true
24+
verify-pixel-sources:
25+
description: Require successful GPU source creation on a prepared runner.
26+
default: 'false'
27+
macos-arch:
28+
description: Optional macOS architecture override.
29+
default: ''
30+
runs:
31+
using: composite
32+
steps:
33+
- name: Identify feature-specific Cargo cache
34+
id: variant
35+
shell: bash
36+
env:
37+
VARIANT_SOURCES: ${{ inputs.sources }}
38+
VARIANT_PRESET: ${{ inputs.preset }}
39+
VARIANT_ARCH: ${{ inputs.macos-arch }}
40+
VARIANT_CONFIG_HASH: ${{ hashFiles('CMakeLists.txt', 'build.sh', 'build.cmd', '.github/actions/setup-capture/action.yml', '.github/actions/test-capture-variant/action.yml') }}
41+
run: |
42+
set -euo pipefail
43+
variant_python=python
44+
if ! command -v "$variant_python" >/dev/null 2>&1; then variant_python=python3; fi
45+
"$variant_python" - <<'PYCODE'
46+
import hashlib
47+
import os
48+
import pathlib
49+
import subprocess
50+
import time
51+
sources = sorted(set(os.environ["VARIANT_SOURCES"].split(",")))
52+
if not sources or any(source not in {"clock", "gstreamer", "pattern"} for source in sources):
53+
raise SystemExit("Invalid selective capture source set")
54+
features = ",".join("capture-" + source for source in sources)
55+
feature_hash = hashlib.sha256(features.encode()).hexdigest()[:16]
56+
root = pathlib.Path(os.environ["CARGO_TARGET_DIR"]).resolve()
57+
cargo_dir = root / ("cpp-" + feature_hash)
58+
rust_sha = subprocess.check_output(["git", "-C", "client-sdk-rust", "rev-parse", "HEAD"], text=True).strip()
59+
key = "-".join(["capture-variant", os.environ["RUNNER_OS"], os.environ.get("ImageOS", os.environ["RUNNER_OS"]),
60+
os.environ["RUNNER_ARCH"], os.environ["VARIANT_ARCH"] or "native",
61+
os.environ["VARIANT_PRESET"], feature_hash,
62+
os.environ["VARIANT_CONFIG_HASH"], rust_sha])
63+
with open(os.environ["GITHUB_OUTPUT"], "a") as output:
64+
output.write(f"cargo-dir={cargo_dir.as_posix()}\nkey={key}\n")
65+
output.write(f"started-at={time.monotonic()}\n")
66+
output.write("bundle-dir=sdk-out/capture-" + "-".join(sources) + "\n")
67+
PYCODE
68+
- name: Restore variant Cargo cache
69+
id: cache
70+
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
71+
with:
72+
path: ${{ steps.variant.outputs.cargo-dir }}
73+
key: ${{ steps.variant.outputs.key }}
74+
- name: Build variant
75+
uses: ./.github/actions/build-sdk
76+
with:
77+
preset: ${{ inputs.preset }}
78+
capture: ${{ inputs.sources }}
79+
bundle-dir: ${{ steps.variant.outputs.bundle-dir }}
80+
macos-arch: ${{ inputs.macos-arch }}
81+
- name: Test installed variant
82+
uses: ./.github/actions/test-sdk-bundle
83+
with:
84+
bundle-dir: ${{ steps.variant.outputs.bundle-dir }}
85+
expected-sources: ${{ inputs.sources }}
86+
verify-pixel-sources: ${{ inputs.verify-pixel-sources }}
87+
build-type: ${{ inputs.preset == 'debug' && 'Debug' || 'Release' }}
88+
macos-arch: ${{ inputs.macos-arch }}
89+
- name: Save verified variant Cargo cache
90+
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request' && steps.cache.outputs.cache-hit != 'true'
91+
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
92+
with:
93+
path: ${{ steps.variant.outputs.cargo-dir }}
94+
key: ${{ steps.variant.outputs.key }}
95+
# The installed bundle owns copies of the libraries. Releasing the Rust
96+
# build tree bounds disk use across the sequence of feature configurations.
97+
- name: Release temporary Cargo output
98+
if: always() && steps.variant.outputs.cargo-dir != ''
99+
shell: bash
100+
env:
101+
VARIANT_CARGO_DIR: ${{ steps.variant.outputs.cargo-dir }}
102+
VARIANT_SOURCES: ${{ inputs.sources }}
103+
VARIANT_STARTED_AT: ${{ steps.variant.outputs.started-at }}
104+
VARIANT_CACHE_HIT: ${{ steps.cache.outputs.cache-hit }}
105+
run: |
106+
set -euo pipefail
107+
variant_python=python
108+
if ! command -v "$variant_python" >/dev/null 2>&1; then variant_python=python3; fi
109+
"$variant_python" - <<'PYCODE'
110+
import os
111+
import pathlib
112+
import shutil
113+
import time
114+
path = pathlib.Path(os.environ["VARIANT_CARGO_DIR"]).resolve()
115+
root = pathlib.Path(os.environ["CARGO_TARGET_DIR"]).resolve()
116+
if path.parent != root or not path.name.startswith("cpp-"):
117+
raise SystemExit("Refusing to remove a path outside the feature-specific Cargo root")
118+
if path.exists():
119+
shutil.rmtree(path)
120+
elapsed = time.monotonic() - float(os.environ["VARIANT_STARTED_AT"])
121+
cache = "hit" if os.environ["VARIANT_CACHE_HIT"] == "true" else "miss"
122+
with open(os.environ["GITHUB_STEP_SUMMARY"], "a") as summary:
123+
summary.write(f"Capture `{os.environ['VARIANT_SOURCES']}`: {elapsed:.0f}s; Cargo cache {cache}.\n\n")
124+
PYCODE
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
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: Test selective capture bundles
16+
description: Build and validate singleton capture sources, with optional pair combinations.
17+
inputs:
18+
preset:
19+
description: SDK build preset without tests or examples (debug or release).
20+
default: release
21+
combinations:
22+
description: Also validate each two-source combination.
23+
default: 'false'
24+
verify-pixel-sources:
25+
description: Require successful GPU source creation on a prepared runner.
26+
default: 'false'
27+
macos-arch:
28+
description: Optional macOS architecture override.
29+
default: ''
30+
runs:
31+
using: composite
32+
steps:
33+
- name: Check pattern bundle
34+
uses: ./.github/actions/test-capture-variant
35+
with:
36+
preset: ${{ inputs.preset }}
37+
sources: 'pattern'
38+
verify-pixel-sources: ${{ inputs.verify-pixel-sources }}
39+
macos-arch: ${{ inputs.macos-arch }}
40+
- name: Check clock bundle
41+
uses: ./.github/actions/test-capture-variant
42+
with:
43+
preset: ${{ inputs.preset }}
44+
sources: 'clock'
45+
verify-pixel-sources: ${{ inputs.verify-pixel-sources }}
46+
macos-arch: ${{ inputs.macos-arch }}
47+
# Pixel-only variants run before installing GStreamer.
48+
- name: Set up GStreamer dependencies
49+
uses: ./.github/actions/setup-capture
50+
- name: Check gstreamer bundle
51+
uses: ./.github/actions/test-capture-variant
52+
with:
53+
preset: ${{ inputs.preset }}
54+
sources: 'gstreamer'
55+
verify-pixel-sources: ${{ inputs.verify-pixel-sources }}
56+
macos-arch: ${{ inputs.macos-arch }}
57+
- name: Check pattern,clock bundle
58+
if: inputs.combinations == 'true'
59+
uses: ./.github/actions/test-capture-variant
60+
with:
61+
preset: ${{ inputs.preset }}
62+
sources: 'pattern,clock'
63+
verify-pixel-sources: ${{ inputs.verify-pixel-sources }}
64+
macos-arch: ${{ inputs.macos-arch }}
65+
- name: Check gstreamer,pattern bundle
66+
if: inputs.combinations == 'true'
67+
uses: ./.github/actions/test-capture-variant
68+
with:
69+
preset: ${{ inputs.preset }}
70+
sources: 'gstreamer,pattern'
71+
verify-pixel-sources: ${{ inputs.verify-pixel-sources }}
72+
macos-arch: ${{ inputs.macos-arch }}
73+
- name: Check gstreamer,clock bundle
74+
if: inputs.combinations == 'true'
75+
uses: ./.github/actions/test-capture-variant
76+
with:
77+
preset: ${{ inputs.preset }}
78+
sources: 'gstreamer,clock'
79+
verify-pixel-sources: ${{ inputs.verify-pixel-sources }}
80+
macos-arch: ${{ inputs.macos-arch }}

‎.github/actions/test-sdk-bundle/action.yml‎

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@ inputs:
2020
required: true
2121
capture:
2222
description: Expected capture support (ON or OFF).
23-
required: true
23+
default: 'ON'
24+
expected-sources:
25+
description: Expected source set (all, none, or comma-separated sources); empty derives from capture.
26+
default: ''
27+
verify-pixel-sources:
28+
description: Require successful pattern/clock creation using a GPU or software adapter.
29+
default: 'false'
2430
build-type:
2531
description: Consumer configuration (Debug or Release).
2632
default: Release
@@ -39,17 +45,20 @@ runs:
3945
env:
4046
SDK_BUNDLE_DIR: ${{ inputs.bundle-dir }}
4147
SDK_CAPTURE: ${{ inputs.capture }}
48+
SDK_EXPECTED_SOURCES: ${{ inputs.expected-sources }}
49+
SDK_VERIFY_PIXEL_SOURCES: ${{ inputs.verify-pixel-sources }}
4250
SDK_BUILD_TYPE: ${{ inputs.build-type }}
4351
SDK_VERSION: ${{ inputs.version }}
4452
SDK_MACOS_ARCH: ${{ inputs.macos-arch }}
4553
run: |
4654
bundle="$GITHUB_WORKSPACE/$SDK_BUNDLE_DIR"
47-
build_dir="build-packaging-$SDK_CAPTURE"
55+
build_dir="${RUNNER_TEMP}/livekit-packaging-${SDK_EXPECTED_SOURCES:-$SDK_CAPTURE}"
4856
arch_args=()
4957
if [[ -n "$SDK_MACOS_ARCH" ]]; then arch_args+=(-DCMAKE_OSX_ARCHITECTURES="$SDK_MACOS_ARCH"); fi
5058
cmake -S src/tests/packaging -B "$build_dir" -G Ninja \
5159
-DCMAKE_BUILD_TYPE="$SDK_BUILD_TYPE" -DCMAKE_PREFIX_PATH="$bundle" \
52-
-DLIVEKIT_EXPECT_CAPTURE="$SDK_CAPTURE" -DLIVEKIT_EXPECT_VERSION="$SDK_VERSION" "${arch_args[@]}"
60+
-DLIVEKIT_EXPECT_CAPTURE="$SDK_CAPTURE" -DLIVEKIT_EXPECT_SOURCES="$SDK_EXPECTED_SOURCES" \
61+
-DLIVEKIT_VERIFY_PIXEL_SOURCES="$SDK_VERIFY_PIXEL_SOURCES" -DLIVEKIT_EXPECT_VERSION="$SDK_VERSION" "${arch_args[@]}"
5362
cmake --build "$build_dir" --config "$SDK_BUILD_TYPE"
5463
ctest --test-dir "$build_dir" -C "$SDK_BUILD_TYPE" --output-on-failure -L packaging
5564
- name: Test bundle (Windows)
@@ -58,12 +67,15 @@ runs:
5867
env:
5968
SDK_BUNDLE_DIR: ${{ inputs.bundle-dir }}
6069
SDK_CAPTURE: ${{ inputs.capture }}
70+
SDK_EXPECTED_SOURCES: ${{ inputs.expected-sources }}
71+
SDK_VERIFY_PIXEL_SOURCES: ${{ inputs.verify-pixel-sources }}
6172
SDK_BUILD_TYPE: ${{ inputs.build-type }}
6273
SDK_VERSION: ${{ inputs.version }}
6374
run: |
6475
$bundle = Join-Path $env:GITHUB_WORKSPACE $env:SDK_BUNDLE_DIR
65-
$buildDir = "build-packaging-$env:SDK_CAPTURE"
66-
cmake -S src/tests/packaging -B "$buildDir" -DCMAKE_PREFIX_PATH="$bundle" -DLIVEKIT_EXPECT_CAPTURE="$env:SDK_CAPTURE" -DLIVEKIT_EXPECT_VERSION="$env:SDK_VERSION"
76+
$selection = if ($env:SDK_EXPECTED_SOURCES) { $env:SDK_EXPECTED_SOURCES } else { $env:SDK_CAPTURE }
77+
$buildDir = Join-Path $env:RUNNER_TEMP "livekit-packaging-$selection"
78+
cmake -S src/tests/packaging -B "$buildDir" -DCMAKE_PREFIX_PATH="$bundle" -DLIVEKIT_EXPECT_CAPTURE="$env:SDK_CAPTURE" -DLIVEKIT_EXPECT_SOURCES="$env:SDK_EXPECTED_SOURCES" -DLIVEKIT_VERIFY_PIXEL_SOURCES="$env:SDK_VERIFY_PIXEL_SOURCES" -DLIVEKIT_EXPECT_VERSION="$env:SDK_VERSION"
6779
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
6880
cmake --build "$buildDir" --config "$env:SDK_BUILD_TYPE"
6981
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

‎.github/workflows/builds.yml‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,11 @@ jobs:
141141
path: |
142142
client-sdk-rust/target/
143143
${{ env.CARGO_TARGET_DIR }}
144-
key: ${{ matrix.os }}-${{ matrix.name }}-cargo-target-${{ runner.os == 'macOS' && hashFiles('.github/actions/setup-capture/action.yml') || 'v3' }}-${{ steps.rust_sha.outputs.sha }}
145-
restore-keys: |
146-
${{ matrix.os }}-${{ matrix.name }}-cargo-target-${{ runner.os == 'macOS' && hashFiles('.github/actions/setup-capture/action.yml') || 'v3' }}-
144+
key: ${{ matrix.os }}-${{ matrix.name }}-cargo-target-release-standard-${{ hashFiles('CMakeLists.txt', 'build.sh', 'build.cmd', '.github/actions/setup-capture/action.yml', '.github/actions/test-capture-variants/action.yml') }}-${{ steps.rust_sha.outputs.sha }}
147145

148-
# restore-keys can hydrate target/ from a prior submodule SHA. cxxbridge
149-
# artifacts in webrtc-sys are not compatible across those bumps.
146+
# Restore exact keys only: webrtc-sys cxxbridge artifacts are not
147+
# compatible across Rust submodule bumps. Avoid downloading a fallback
148+
# cache that this cleanup would immediately discard.
150149
- name: Drop stale cargo target on submodule SHA cache miss
151150
if: steps.cache-cargo-target.outputs.cache-hit != 'true'
152151
shell: bash
@@ -237,7 +236,7 @@ jobs:
237236
path: |
238237
client-sdk-rust/target/
239238
${{ env.CARGO_TARGET_DIR }}
240-
key: ${{ matrix.os }}-${{ matrix.name }}-cargo-target-${{ runner.os == 'macOS' && hashFiles('.github/actions/setup-capture/action.yml') || 'v3' }}-${{ steps.rust_sha.outputs.sha }}
239+
key: ${{ matrix.os }}-${{ matrix.name }}-cargo-target-release-standard-${{ hashFiles('CMakeLists.txt', 'build.sh', 'build.cmd', '.github/actions/setup-capture/action.yml', '.github/actions/test-capture-variants/action.yml') }}-${{ steps.rust_sha.outputs.sha }}
241240

242241
- name: Save vcpkg binary cache
243242
if: runner.os == 'Windows' && steps.cache-vcpkg-binary.outputs.cache-hit != 'true'

‎.github/workflows/ci.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ jobs:
5656
- .github/actions/cargo-target-root/**
5757
- .github/actions/smoke-examples/**
5858
- .github/actions/test-sdk-bundle/**
59+
- .github/actions/test-capture-variants/**
60+
- .github/actions/test-capture-variant/**
5961
- .github/actions/check-sdk-symbols/**
6062
- .github/scripts/check_no_private_symbols.py
6163
tests:
@@ -79,6 +81,8 @@ jobs:
7981
- .github/actions/build-sdk/**
8082
- .github/actions/cargo-target-root/**
8183
- .github/actions/test-sdk-bundle/**
84+
- .github/actions/test-capture-variants/**
85+
- .github/actions/test-capture-variant/**
8286
docs:
8387
- README.md
8488
- include/**

‎.github/workflows/make-release.yml‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,11 @@ jobs:
149149
path: |
150150
client-sdk-rust/target/
151151
${{ env.CARGO_TARGET_DIR }}
152-
key: ${{ matrix.os }}-${{ matrix.name }}-cargo-target-${{ runner.os == 'macOS' && hashFiles('.github/actions/setup-capture/action.yml') || 'v3' }}-${{ steps.rust_sha.outputs.sha }}
153-
restore-keys: |
154-
${{ matrix.os }}-${{ matrix.name }}-cargo-target-${{ runner.os == 'macOS' && hashFiles('.github/actions/setup-capture/action.yml') || 'v3' }}-
152+
key: ${{ matrix.os }}-${{ matrix.name }}-cargo-target-release-standard-${{ hashFiles('CMakeLists.txt', 'build.sh', 'build.cmd', '.github/actions/setup-capture/action.yml', '.github/actions/test-capture-variants/action.yml') }}-${{ steps.rust_sha.outputs.sha }}
155153

156-
# restore-keys can hydrate target/ from a prior submodule SHA. cxxbridge
157-
# artifacts in webrtc-sys are not compatible across those bumps.
154+
# Restore exact keys only: webrtc-sys cxxbridge artifacts are not
155+
# compatible across Rust submodule bumps. Avoid downloading a fallback
156+
# cache that this cleanup would immediately discard.
158157
- name: Drop stale cargo target on submodule SHA cache miss
159158
if: steps.cache-cargo-target.outputs.cache-hit != 'true'
160159
shell: bash

‎.github/workflows/nightly.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ jobs:
2626
stress_timeout_minutes: 120
2727
artifact_retention_days: 14
2828
run_coverage: false
29+
extended_capture_sources: true
2930
secrets: inherit

0 commit comments

Comments
 (0)