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
This commit is contained in:
Marco Quinten 2021-03-16 16:51:11 +01:00 committed by GitHub
parent da25d9eade
commit 3846ed81c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 45 additions and 16 deletions

View File

@ -40,18 +40,15 @@ jobs:
- name: Install cocoapods dependencies - name: Install cocoapods dependencies
if: steps.cache-pods.outputs.cache-hit != 'true' if: steps.cache-pods.outputs.cache-hit != 'true'
run: bundle exec pod install run: bundle exec pod install
- name: Build Swift Package
run: swift build -j 2 --disable-index-store -v
- name: Test Framework on iOS and tvOS - name: Test Framework on iOS and tvOS
run: bundle exec fastlane ios test run: bundle exec fastlane ios test ci:github
- name: Test Framework on macOS - name: Test Framework on macOS
run: bundle exec fastlane mac test run: bundle exec fastlane mac test ci:github
- name: Lint podspec - name: Lint podspec
run: bundle exec pod lib lint run: bundle exec pod lib lint
- name: Build Swift Package
run: swift build -v
- name: Test Swift Package
run: swift test -v

View File

@ -2,3 +2,6 @@ source "https://rubygems.org"
gem "cocoapods", "1.10.1" gem "cocoapods", "1.10.1"
gem "fastlane", "~> 2.137" gem "fastlane", "~> 2.137"
plugins_path = File.join(File.dirname(__FILE__), 'fastlane', 'Pluginfile')
eval_gemfile(plugins_path) if File.exist?(plugins_path)

View File

@ -70,6 +70,7 @@ GEM
cocoapods-try (1.2.0) cocoapods-try (1.2.0)
colored (1.2) colored (1.2)
colored2 (3.1.2) colored2 (3.1.2)
colorize (0.8.1)
commander-fastlane (4.4.6) commander-fastlane (4.4.6)
highline (~> 1.7.2) highline (~> 1.7.2)
concurrent-ruby (1.1.8) concurrent-ruby (1.1.8)
@ -130,6 +131,13 @@ GEM
xcodeproj (>= 1.13.0, < 2.0.0) xcodeproj (>= 1.13.0, < 2.0.0)
xcpretty (~> 0.3.0) xcpretty (~> 0.3.0)
xcpretty-travis-formatter (>= 0.0.3) xcpretty-travis-formatter (>= 0.0.3)
fastlane-plugin-test_center (3.15.3)
colorize
json
plist
trainer
xcodeproj
xctest_list (>= 1.2.1)
ffi (1.15.0) ffi (1.15.0)
fourflusher (2.3.1) fourflusher (2.3.1)
fuzzy_match (2.0.4) fuzzy_match (2.0.4)
@ -209,6 +217,9 @@ GEM
terminal-table (1.8.0) terminal-table (1.8.0)
unicode-display_width (~> 1.1, >= 1.1.1) unicode-display_width (~> 1.1, >= 1.1.1)
thread_safe (0.3.6) thread_safe (0.3.6)
trainer (0.9.1)
fastlane (>= 2.25.0)
plist (>= 3.1.0, < 4.0.0)
tty-cursor (0.7.1) tty-cursor (0.7.1)
tty-screen (0.8.1) tty-screen (0.8.1)
tty-spinner (0.9.3) tty-spinner (0.9.3)
@ -233,6 +244,7 @@ GEM
rouge (~> 2.0.7) rouge (~> 2.0.7)
xcpretty-travis-formatter (1.0.0) xcpretty-travis-formatter (1.0.0)
xcpretty (~> 0.2, >= 0.0.7) xcpretty (~> 0.2, >= 0.0.7)
xctest_list (1.2.1)
PLATFORMS PLATFORMS
ruby ruby
@ -240,6 +252,7 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
cocoapods (= 1.10.1) cocoapods (= 1.10.1)
fastlane (~> 2.137) fastlane (~> 2.137)
fastlane-plugin-test_center
BUNDLED WITH BUNDLED WITH
1.17.3 1.17.3

View File

@ -7,7 +7,7 @@ import SwiftUI
@available(macOS 10.15.0, *) @available(macOS 10.15.0, *)
enum TestUtils { enum TestUtils {
enum Constants { enum Constants {
static let timeout: TimeInterval = 2 static let timeout: TimeInterval = 5
} }
static func present<ViewType: View>(view: ViewType) { static func present<ViewType: View>(view: ViewType) {
@ -20,6 +20,7 @@ enum TestUtils {
window.setFrameAutosaveName("Main Window") window.setFrameAutosaveName("Main Window")
window.contentView = NSHostingView(rootView: view) window.contentView = NSHostingView(rootView: view)
window.makeKeyAndOrderFront(nil) window.makeKeyAndOrderFront(nil)
window.layoutIfNeeded()
} }
} }

View File

@ -28,6 +28,7 @@ enum TestUtils {
hostingController.beginAppearanceTransition(true, animated: false) hostingController.beginAppearanceTransition(true, animated: false)
window.rootViewController = hostingController window.rootViewController = hostingController
window.makeKeyAndVisible() window.makeKeyAndVisible()
window.layoutIfNeeded()
hostingController.endAppearanceTransition() hostingController.endAppearanceTransition()
} }
} }

View File

@ -2,23 +2,32 @@ default_platform(:ios)
skip_docs skip_docs
platform :ios do platform :ios do
lane :test do lane :test do |options|
scan( puts 'Running on GitHub CI.' if options[:ci] == 'github'
multi_scan(
devices: ["iPhone 8"], devices: ["iPhone 8"],
scheme: "Introspect iOS" scheme: "Introspect iOS",
skip_build: options[:ci] == 'github',
try_count: 3,
quit_simulators: false
) )
scan( multi_scan(
devices: ["Apple TV"], devices: ["Apple TV"],
scheme: "Introspect tvOS" scheme: "Introspect tvOS",
skip_build: options[:ci] == 'github',
try_count: 3,
quit_simulators: false
) )
end end
end end
platform :mac do platform :mac do
lane :test do lane :test do |options|
puts 'Running on GitHub CI.' if options[:ci] == 'github'
scan( scan(
scheme: "Introspect macOS" scheme: "Introspect macOS",
skip_build: options[:ci] == 'github'
) )
end end
end end

5
fastlane/Pluginfile Normal file
View File

@ -0,0 +1,5 @@
# Autogenerated by fastlane
#
# Ensure this file is checked in to source control!
gem 'fastlane-plugin-test_center'