@@ -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+ }
0 commit comments