Skip to content

Commit 0db6951

Browse files
[CI] Testing infra refactoring (#782)
1 parent 077807a commit 0db6951

File tree

7 files changed

+21
-47
lines changed

7 files changed

+21
-47
lines changed

.github/workflows/cron-checks.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ jobs:
9797
STREAM_SDK_TEST_ACCOUNT_EMAIL: ${{ secrets.STREAM_SDK_TEST_ACCOUNT_EMAIL }}
9898
STREAM_SDK_TEST_ACCOUNT_PASSWORD: ${{ secrets.STREAM_SDK_TEST_ACCOUNT_PASSWORD }}
9999
STREAM_SDK_TEST_ACCOUNT_OTP_SECRET: ${{ secrets.STREAM_SDK_TEST_ACCOUNT_OTP_SECRET }}
100-
STREAM_VIDEO_SECRET: ${{ secrets.STREAM_VIDEO_SECRET }}
101100
- name: Allure TestOps Upload
102101
if: success() || failure()
103102
run: bundle exec fastlane allure_upload launch_id:$LAUNCH_ID
@@ -149,7 +148,6 @@ jobs:
149148
runs-on: ${{ matrix.os }}
150149
env:
151150
XCODE_VERSION: ${{ matrix.xcode }}
152-
STREAM_VIDEO_SECRET: ${{ secrets.STREAM_VIDEO_SECRET }}
153151
steps:
154152
- uses: actions/checkout@v4.1.1
155153
- uses: ./.github/actions/bootstrap

.github/workflows/smoke-checks.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ jobs:
3434
name: Test LLC (Debug)
3535
runs-on: macos-15
3636
if: ${{ github.event.inputs.record_snapshots_swiftui != 'true' && github.event.inputs.record_snapshots_uikit != 'true' }}
37-
env:
38-
STREAM_VIDEO_SECRET: ${{ secrets.STREAM_VIDEO_SECRET }}
3937
steps:
4038
- uses: actions/checkout@v4.1.1
4139
with:
@@ -280,7 +278,6 @@ jobs:
280278
STREAM_SDK_TEST_ACCOUNT_EMAIL: ${{ secrets.STREAM_SDK_TEST_ACCOUNT_EMAIL }}
281279
STREAM_SDK_TEST_ACCOUNT_PASSWORD: ${{ secrets.STREAM_SDK_TEST_ACCOUNT_PASSWORD }}
282280
STREAM_SDK_TEST_ACCOUNT_OTP_SECRET: ${{ secrets.STREAM_SDK_TEST_ACCOUNT_OTP_SECRET }}
283-
STREAM_VIDEO_SECRET: ${{ secrets.STREAM_VIDEO_SECRET }}
284281
- name: Allure TestOps Upload
285282
if: env.LAUNCH_ID != '' && (success() || failure())
286283
run: bundle exec fastlane allure_upload launch_id:$LAUNCH_ID

StreamVideoTests/StreamVideo.xctestplan

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@
2020
},
2121
"defaultTestExecutionTimeAllowance" : 100,
2222
"environmentVariableEntries" : [
23-
{
24-
"key" : "STREAM_VIDEO_SECRET",
25-
"value" : "$(STREAM_VIDEO_SECRET)"
26-
}
23+
2724
],
2825
"maximumTestExecutionTimeAllowance" : 100,
2926
"maximumTestRepetitions" : 3,

SwiftUIDemoAppUITests/SwiftUIDemoApp.xctestplan

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010
],
1111
"defaultOptions" : {
1212
"environmentVariableEntries" : [
13-
{
14-
"key" : "STREAM_VIDEO_SECRET",
15-
"value" : "$(STREAM_VIDEO_SECRET)"
16-
}
13+
1714
],
1815
"preferredScreenCaptureFormat" : "screenshot",
1916
"targetForVariableExpansion" : {

SwiftUIDemoAppUITests/Tests/StreamTestCase.swift

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ let app = XCUIApplication()
88
var userRobot = UserRobot()
99

1010
class StreamTestCase: XCTestCase {
11-
11+
1212
let deviceRobot = DeviceRobot(app)
1313
var participantRobot = ParticipantRobot()
1414
var sinatra = Sinatra()
@@ -20,8 +20,7 @@ class StreamTestCase: XCTestCase {
2020
override func setUpWithError() throws {
2121
try super.setUpWithError()
2222
continueAfterFailure = false
23-
24-
setLaunchArguments()
23+
2524
alertHandler()
2625
ipadSetup()
2726
startVideo()
@@ -42,19 +41,14 @@ class StreamTestCase: XCTestCase {
4241
}
4342

4443
extension StreamTestCase {
45-
44+
4645
static var randomCallId: String {
4746
let uuid = UUID().uuidString.split(separator: "-")
4847
if let first = uuid.first { return String(first) } else { return "Test" }
4948
}
5049
}
5150

5251
extension StreamTestCase {
53-
54-
private func setLaunchArguments() {
55-
let secret = ProcessInfo.processInfo.environment[EnvironmentVariable.streamVideoSecret.rawValue] ?? ""
56-
app.setEnvironmentVariables([.streamVideoSecret: secret])
57-
}
5852

5953
private func attachElementTree() {
6054
let attachment = XCTAttachment(string: app.debugDescription)
@@ -73,7 +67,7 @@ extension StreamTestCase {
7367
return false
7468
}
7569
}
76-
70+
7771
private func ipadSetup() {
7872
if UIDevice.current.userInterfaceIdiom == .pad {
7973
app.landscape()

TestTools/TestData/LaunchArgument.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import XCTest
77

88
public enum EnvironmentVariable: String {
99
case jwtExpiration = "JWT_EXPIRATION"
10-
case streamVideoSecret = "STREAM_VIDEO_SECRET"
1110
}
1211

1312
public enum LaunchArgument: String {
@@ -26,7 +25,7 @@ public extension XCUIApplication {
2625
func setLaunchArguments(_ args: LaunchArgument...) {
2726
launchArguments.append(contentsOf: args.map { $0.rawValue })
2827
}
29-
28+
3029
func setEnvironmentVariables(_ envVars: [EnvironmentVariable: String]) {
3130
envVars.forEach { envVar in
3231
launchEnvironment[envVar.key.rawValue] = envVar.value

fastlane/Fastfile

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ podspec_names = ['StreamVideo', 'StreamVideo-XCFramework', 'StreamVideoSwiftUI',
1313
github_repo = ENV['GITHUB_REPOSITORY'] || 'GetStream/stream-video-swift'
1414
sinatra_port = 4567
1515
video_buddy_port = 5678
16-
app_secret = ENV.fetch('STREAM_VIDEO_SECRET', nil)
1716
derived_data_path = 'derived_data'
1817
source_packages_path = 'spm_cache'
1918
gci = ENV['GOOGLE_CLIENT_ID'] || ''
@@ -234,8 +233,7 @@ lane :test do |options|
234233
devices: options[:device],
235234
number_of_retries: 3,
236235
skip_build: options[:skip_build],
237-
build_for_testing: options[:build_for_testing],
238-
xcargs: is_ci ? "STREAM_VIDEO_SECRET=#{app_secret}" : ''
236+
build_for_testing: options[:build_for_testing]
239237
}
240238

241239
begin
@@ -423,33 +421,27 @@ lane :test_e2e do |options|
423421
build_for_testing: options[:build_for_testing],
424422
devices: options[:device],
425423
prelaunch_simulator: is_ci,
426-
number_of_retries: 3,
427-
xcargs: is_ci ? "STREAM_VIDEO_SECRET=#{app_secret}" : ''
424+
number_of_retries: 3
428425
}
429426

430-
if is_localhost
431-
scan(scan_options)
432-
else
433-
parallelize_tests_on_ci(scan: scan_options, batch: options[:batch], cron: options[:cron])
427+
if ENV['MATRIX_SIZE'] && options[:batch]
428+
products_dir = File.expand_path("../#{derived_data_path}/Build/Products")
429+
xctestrun = Dir.glob(File.expand_path("#{products_dir}/*.xctestrun")).first
430+
tests = retrieve_xctest_names(xctestrun: xctestrun).values.flatten
431+
slice_size = (tests.size / ENV['MATRIX_SIZE'].to_f).ceil
432+
only_testing = []
433+
tests.each_slice(slice_size) { |test| only_testing << test }
434+
only_testing_batch = only_testing[options[:batch].to_i]
435+
scan_options[:only_testing] = only_testing_batch
436+
UI.important("Tests in total: #{only_testing.flatten.size}. Running #{only_testing_batch.size} of them ⌛️")
434437
end
435-
end
436-
437-
private_lane :parallelize_tests_on_ci do |options|
438-
products_dir = File.expand_path("../#{derived_data_path}/Build/Products")
439-
xctestrun = Dir.glob(File.expand_path("#{products_dir}/*.xctestrun")).first
440-
tests = retrieve_xctest_names(xctestrun: xctestrun).values.flatten
441-
slice_size = options[:cron] ? tests.size : (tests.size / ENV['MATRIX_SIZE'].to_f).ceil
442-
only_testing = []
443-
tests.each_slice(slice_size) { |test| only_testing << test }
444-
only_testing_batch = only_testing[options[:batch].to_i]
445438

446439
begin
447-
UI.success("Tests in total: #{only_testing.flatten.size}. Running #{only_testing_batch.size} of them ⌛️")
448-
scan(options[:scan].merge(only_testing: only_testing_batch))
440+
scan(scan_options)
449441
rescue StandardError
450442
failed_tests = retreive_failed_tests
451443
UI.important("Re-running #{failed_tests.size} failed tests ⌛️")
452-
scan(options[:scan].merge(only_testing: failed_tests))
444+
scan(scan_options.merge(only_testing: failed_tests))
453445
end
454446
end
455447

0 commit comments

Comments
 (0)