Skip to content

Commit

Permalink
Merge pull request #1510 from danielgindi/fix-ci
Browse files Browse the repository at this point in the history
Attempt to make CI more stable
  • Loading branch information
pmairoldi authored Sep 25, 2016
2 parents ebcb608 + 09216b7 commit 1fc15fb
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 31 deletions.
3 changes: 1 addition & 2 deletions Charts.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,7 @@
);
inputPaths = (
FBSnapshotTestCase,
Realm,
);
name = "Copy Carthage Frameworks";
outputPaths = (
Expand Down Expand Up @@ -1423,7 +1424,6 @@
baseConfigurationReference = 063FF0401D8CC9940094A042 /* Carthage.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "-";
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = "$(SRCROOT)/Tests/Supporting Files/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
Expand All @@ -1439,7 +1439,6 @@
baseConfigurationReference = 063FF0401D8CC9940094A042 /* Carthage.xcconfig */;
buildSettings = {
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "-";
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = "$(SRCROOT)/Tests/Supporting Files/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
Expand Down
81 changes: 52 additions & 29 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,43 @@ def configuration
"Debug"
end

def test_targets
def test_platforms
[
:ios,
:tvos
]
end

def schemes
{
ios: 'Charts',
tvos: 'Charts',
osx: 'Charts'
}
[
"Charts",
"ChartsRealm"
]
end

def sdks
def devices
{
ios: 'iphonesimulator',
osx: 'macosx',
tvos: 'appletvsimulator'
ios: {
sdk: "iphonesimulator",
device: "name='iPhone 7'",
uuid: "5F911B30-5F23-403B-9697-1DFDC24773C8"
},
macos: {
sdk: "macosx",
device: "arch='x86_64'",
uuid: nil
},
tvos: {
sdk: "appletvsimulator",
device: "name='Apple TV 1080p'",
uuid: "273D776F-196E-4F2A-AEF2-E1E3EAE99B47"
}
}
end

def devices
{
ios: "name='iPhone 7'",
osx: "arch='x86_64'",
tvos: "name='Apple TV 1080p'"
}
def open_simulator_and_sleep(uuid)
return if uuid.nil? # Don't need a sleep on macOS because it runs first.
sh "xcrun instruments -w '#{uuid}' || sleep 15"
end

def xcodebuild(type, name, scheme, configuration, sdk, destination, tasks, xcprety_args: '')
Expand All @@ -57,31 +65,46 @@ def xcodebuild(type, name, scheme, configuration, sdk, destination, tasks, xcpre

end

def run_xcodebuild(schemes, tasks, destination, is_test, xcprety_args)
sdk = destination[:sdk]
device = destination[:device]
uuid = destination[:uuid]

if is_test
open_simulator_and_sleep uuid
end

schemes.each do |scheme|
xcodebuild type, project_name, scheme, configuration, sdk, device, tasks, xcprety_args
end

if is_test
sh "killall Simulator"
end
end

def execute(tasks, platform, xcprety_args)

is_test = tasks.include?("test")

# platform specific settings
sdk = sdks[platform]
scheme = schemes[platform]
destination = devices[platform]

# check if xcodebuild needs to be run on multiple devices
if destination.respond_to?('map')
destination.map do |destination|
xcodebuild type, project_name, scheme, configuration, sdk, destination, tasks, xcprety_args
if destination.is_a?(Array)
destination.each do |destination|
run_xcodebuild schemes, tasks, destination, is_test, xcprety_args
end
else
xcodebuild type, project_name, scheme, configuration, sdk, destination, tasks, xcprety_args
else
run_xcodebuild schemes, tasks, destination, is_test, xcprety_args
end

end

desc 'Build, then run tests.'
desc "Build, then run tests."
task :test do

test_targets.map do |platform|
execute 'build test', platform, xcprety_args: '--test'
test_platforms.each do |platform|
execute "build test", platform, xcprety_args: "--test"
end

sh "killall Simulator"

end

0 comments on commit 1fc15fb

Please sign in to comment.