Skip to content

Commit 88264eb

Browse files
pblazejclaude
andauthored
ci: switch benchmarks to cloud (#980)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 745f832 commit 88264eb

3 files changed

Lines changed: 43 additions & 12 deletions

File tree

.github/workflows/benchmark.yaml

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ permissions:
55

66
on:
77
workflow_dispatch:
8+
inputs:
9+
target:
10+
description: 'Benchmark target'
11+
type: choice
12+
default: cloud
13+
options:
14+
- cloud
15+
- local
816
schedule:
917
- cron: '0 0 * * *'
1018

@@ -15,16 +23,17 @@ jobs:
1523
timeout-minutes: 60
1624
env:
1725
LK_BENCHMARK: 1
18-
# LIVEKIT_URL: ${{ secrets.BENCHMARK_URL }}
19-
# LIVEKIT_API_KEY: ${{ secrets.BENCHMARK_API_KEY }}
20-
# LIVEKIT_API_SECRET: ${{ secrets.BENCHMARK_API_SECRET }}
26+
LIVEKIT_URL: ${{ inputs.target != 'local' && secrets.BENCHMARK_URL || '' }}
27+
LIVEKIT_API_KEY: ${{ inputs.target != 'local' && secrets.BENCHMARK_API_KEY || '' }}
28+
LIVEKIT_API_SECRET: ${{ inputs.target != 'local' && secrets.BENCHMARK_API_SECRET || '' }}
2129
steps:
2230
- uses: actions/checkout@v6
2331

2432
- name: Install dependencies
2533
run: brew install livekit jemalloc swiftly && swiftly init --quiet-shell-followup --skip-install -y
2634

2735
- name: Run LiveKit Server
36+
if: inputs.target == 'local'
2837
run: livekit-server --dev &
2938

3039
- uses: maxim-lobanov/setup-xcode@v1
@@ -39,8 +48,12 @@ jobs:
3948
4049
- name: Benchmark Report
4150
working-directory: Benchmarks
51+
env:
52+
TARGET: ${{ inputs.target || 'cloud' }}
4253
run: |
43-
swiftly run +xcode swift package --disable-sandbox \
44-
benchmark baseline read current \
45-
--format markdown \
46-
| tee -a "$GITHUB_STEP_SUMMARY"
54+
{
55+
echo "## Target: \`${TARGET}\`"
56+
echo
57+
swiftly run +xcode swift package --disable-sandbox \
58+
benchmark baseline read current --format markdown
59+
} | tee -a "$GITHUB_STEP_SUMMARY"

Benchmarks/LiveKitBenchmark/BenchmarkSupport/BenchmarkConfig.swift

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,30 @@ struct BenchmarkConfig {
3131
/// Read benchmark configuration from environment variables.
3232
///
3333
/// Falls back to local defaults (`ws://localhost:7880`, `devkey`/`secret`)
34-
/// when environment variables are not set.
34+
/// when environment variables are not set or are empty.
3535
///
3636
/// Override with:
3737
/// - `LIVEKIT_URL`: WebSocket URL (e.g., `wss://my-project.livekit.cloud`)
3838
/// - `LIVEKIT_API_KEY`: API key for token generation
3939
/// - `LIVEKIT_API_SECRET`: API secret for token generation
4040
/// - `LIVEKIT_BENCHMARK_REGION`: Server region (only used for cloud)
4141
static func fromEnvironment() -> BenchmarkConfig {
42-
let url = ProcessInfo.processInfo.environment["LIVEKIT_URL"] ?? "ws://localhost:7880"
43-
let apiKey = ProcessInfo.processInfo.environment["LIVEKIT_API_KEY"] ?? "devkey"
44-
let apiSecret = ProcessInfo.processInfo.environment["LIVEKIT_API_SECRET"] ?? "secret"
42+
// GitHub Actions interpolates missing `${{ secrets.X }}` to an empty
43+
// string, so treat empty values the same as unset to fall back cleanly.
44+
func env(_ key: String) -> String? {
45+
guard let value = ProcessInfo.processInfo.environment[key], !value.isEmpty else { return nil }
46+
return value
47+
}
48+
49+
let url = env("LIVEKIT_URL") ?? "ws://localhost:7880"
50+
let apiKey = env("LIVEKIT_API_KEY") ?? "devkey"
51+
let apiSecret = env("LIVEKIT_API_SECRET") ?? "secret"
4552

4653
// Auto-detect mode from URL
4754
let mode: InfrastructureMode = if url.hasPrefix("ws://") || url.contains("localhost") {
4855
.local
4956
} else {
50-
.cloud(region: ProcessInfo.processInfo.environment["LIVEKIT_BENCHMARK_REGION"])
57+
.cloud(region: env("LIVEKIT_BENCHMARK_REGION"))
5158
}
5259

5360
return BenchmarkConfig(
@@ -58,3 +65,12 @@ struct BenchmarkConfig {
5865
)
5966
}
6067
}
68+
69+
extension BenchmarkConfig.InfrastructureMode: CustomStringConvertible {
70+
var description: String {
71+
switch self {
72+
case .local: "local"
73+
case let .cloud(region): region.map { "cloud (\($0))" } ?? "cloud"
74+
}
75+
}
76+
}

Benchmarks/LiveKitBenchmark/Benchmarks.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ let benchmarkTracer = BenchmarkTracer()
2828
///
2929
/// Run with: `swift package benchmark`
3030
let benchmarks: @Sendable () -> Void = {
31+
print("Benchmark target: \(BenchmarkConfig.fromEnvironment().mode)")
32+
3133
// Inject our tracing so we can capture timing data
3234
LiveKitSDK.setTracing(benchmarkTracer)
3335

0 commit comments

Comments
 (0)