-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRakefile
More file actions
74 lines (60 loc) · 2.01 KB
/
Rakefile
File metadata and controls
74 lines (60 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
include FileUtils::Verbose
namespace :test do
desc 'Prepare tests'
task :prepare do
end
desc 'Run the unit tests'
task ios: :prepare do
run('test', 'PollingKit', 'Debug', 'iPhone 7', '10.3.1')
run('test', 'PollingKit', 'Debug', 'iPhone 8', '11.4')
run('test', 'PollingKit', 'Debug', 'iPhone Xs', '12.4')
run('test', 'PollingKit', 'Debug', 'iPhone SE (2nd generation)', '13.6')
run('test', 'PollingKit', 'Debug', 'iPhone SE (2nd generation)', '14.5')
run('test', 'PollingKit', 'Debug', 'iPhone SE (2nd generation)', '15.2')
end
desc 'Build the Demo App'
task ios_example: :prepare do
run('build', 'PollingKitDemo', 'Release', 'iPhone SE (2nd generation)', '13.6')
end
end
namespace :package_manager do
desc 'Prepare tests'
task :prepare do
end
desc 'Builds the project with the Swift Package Manager'
task spm: :prepare do
sh("swift build \
-Xswiftc \"-sdk\" -Xswiftc \"\`xcrun --sdk iphonesimulator --show-sdk-path\`\" \
-Xswiftc \"-target\" -Xswiftc \"x86_64-apple-ios13.0-simulator\"") rescue nil
package_manager_failed('Swift Package Manager') unless $?.success?
end
end
desc 'Run the tests'
task :test do
Rake::Task['test:ios'].invoke
Rake::Task['test:ios_example'].invoke
Rake::Task['package_manager:spm'].invoke
end
task default: 'test'
private
def run(operation, scheme, configuration, device, os)
sh("xcodebuild -workspace PollingKit.xcworkspace -scheme '#{scheme}' -sdk 'iphonesimulator' -destination 'platform=iOS Simulator,name=#{device},OS=#{os}' -configuration #{configuration} clean #{operation} | xcpretty") rescue nil
if $?.success?
succeeded("#{device}, #{os}", operation)
else
failed("#{device}, #{os}", operation)
end
end
def failed(platform, subject)
puts red("#{platform} #{subject} failed.")
exit $?.exitstatus
end
def succeeded(platform, subject)
puts green("#{platform} #{subject} succeeded.")
end
def red(string)
"\033[0;31m#{string}\033[0m"
end
def green(string)
"\033[0;32m#{string}\033[0m"
end