Skip to content

Commit 3846ed8

Browse files
authored
Improve GitHub CI runtime (#82)
* Build fast on GitHub * Skip build for github ci * Increase AppKit timeout to 5 * Add try_scan * Disable parallel testing * Use multi_scan instead of try_scan * Use normal scan for macOS * Fix seemingly random test failures on macOS * Also add `layoutIfNeeded` to iOS/tvOS tests
1 parent da25d9e commit 3846ed8

File tree

7 files changed

+45
-16
lines changed

7 files changed

+45
-16
lines changed

.github/workflows/build-and-test.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,15 @@ jobs:
4040
- name: Install cocoapods dependencies
4141
if: steps.cache-pods.outputs.cache-hit != 'true'
4242
run: bundle exec pod install
43+
44+
- name: Build Swift Package
45+
run: swift build -j 2 --disable-index-store -v
4346

4447
- name: Test Framework on iOS and tvOS
45-
run: bundle exec fastlane ios test
48+
run: bundle exec fastlane ios test ci:github
4649

4750
- name: Test Framework on macOS
48-
run: bundle exec fastlane mac test
51+
run: bundle exec fastlane mac test ci:github
4952

5053
- name: Lint podspec
5154
run: bundle exec pod lib lint
52-
53-
- name: Build Swift Package
54-
run: swift build -v
55-
56-
- name: Test Swift Package
57-
run: swift test -v

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,6 @@ source "https://rubygems.org"
22

33
gem "cocoapods", "1.10.1"
44
gem "fastlane", "~> 2.137"
5+
6+
plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
7+
eval_gemfile(plugins_path) if File.exist?(plugins_path)

Gemfile.lock

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ GEM
7070
cocoapods-try (1.2.0)
7171
colored (1.2)
7272
colored2 (3.1.2)
73+
colorize (0.8.1)
7374
commander-fastlane (4.4.6)
7475
highline (~> 1.7.2)
7576
concurrent-ruby (1.1.8)
@@ -130,6 +131,13 @@ GEM
130131
xcodeproj (>= 1.13.0, < 2.0.0)
131132
xcpretty (~> 0.3.0)
132133
xcpretty-travis-formatter (>= 0.0.3)
134+
fastlane-plugin-test_center (3.15.3)
135+
colorize
136+
json
137+
plist
138+
trainer
139+
xcodeproj
140+
xctest_list (>= 1.2.1)
133141
ffi (1.15.0)
134142
fourflusher (2.3.1)
135143
fuzzy_match (2.0.4)
@@ -209,6 +217,9 @@ GEM
209217
terminal-table (1.8.0)
210218
unicode-display_width (~> 1.1, >= 1.1.1)
211219
thread_safe (0.3.6)
220+
trainer (0.9.1)
221+
fastlane (>= 2.25.0)
222+
plist (>= 3.1.0, < 4.0.0)
212223
tty-cursor (0.7.1)
213224
tty-screen (0.8.1)
214225
tty-spinner (0.9.3)
@@ -233,13 +244,15 @@ GEM
233244
rouge (~> 2.0.7)
234245
xcpretty-travis-formatter (1.0.0)
235246
xcpretty (~> 0.2, >= 0.0.7)
247+
xctest_list (1.2.1)
236248

237249
PLATFORMS
238250
ruby
239251

240252
DEPENDENCIES
241253
cocoapods (= 1.10.1)
242254
fastlane (~> 2.137)
255+
fastlane-plugin-test_center
243256

244257
BUNDLED WITH
245258
1.17.3

IntrospectTests/AppKitTests.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import SwiftUI
77
@available(macOS 10.15.0, *)
88
enum TestUtils {
99
enum Constants {
10-
static let timeout: TimeInterval = 2
10+
static let timeout: TimeInterval = 5
1111
}
1212

1313
static func present<ViewType: View>(view: ViewType) {
@@ -20,6 +20,7 @@ enum TestUtils {
2020
window.setFrameAutosaveName("Main Window")
2121
window.contentView = NSHostingView(rootView: view)
2222
window.makeKeyAndOrderFront(nil)
23+
window.layoutIfNeeded()
2324
}
2425
}
2526

IntrospectTests/UIKitTests.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ enum TestUtils {
2828
hostingController.beginAppearanceTransition(true, animated: false)
2929
window.rootViewController = hostingController
3030
window.makeKeyAndVisible()
31+
window.layoutIfNeeded()
3132
hostingController.endAppearanceTransition()
3233
}
3334
}

fastlane/Fastfile

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,32 @@ default_platform(:ios)
22
skip_docs
33

44
platform :ios do
5-
lane :test do
6-
scan(
5+
lane :test do |options|
6+
puts 'Running on GitHub CI.' if options[:ci] == 'github'
7+
multi_scan(
78
devices: ["iPhone 8"],
8-
scheme: "Introspect iOS"
9+
scheme: "Introspect iOS",
10+
skip_build: options[:ci] == 'github',
11+
try_count: 3,
12+
quit_simulators: false
913
)
1014

11-
scan(
15+
multi_scan(
1216
devices: ["Apple TV"],
13-
scheme: "Introspect tvOS"
17+
scheme: "Introspect tvOS",
18+
skip_build: options[:ci] == 'github',
19+
try_count: 3,
20+
quit_simulators: false
1421
)
1522
end
1623
end
1724

1825
platform :mac do
19-
lane :test do
26+
lane :test do |options|
27+
puts 'Running on GitHub CI.' if options[:ci] == 'github'
2028
scan(
21-
scheme: "Introspect macOS"
29+
scheme: "Introspect macOS",
30+
skip_build: options[:ci] == 'github'
2231
)
2332
end
2433
end

fastlane/Pluginfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Autogenerated by fastlane
2+
#
3+
# Ensure this file is checked in to source control!
4+
5+
gem 'fastlane-plugin-test_center'

0 commit comments

Comments
 (0)