|
1 | 1 | task default: "ci:test"
|
2 | 2 |
|
3 |
| -latest = "10.1" |
4 |
| - |
5 | 3 | namespace :ci do
|
6 |
| - desc "Build targets on Travis CI with a specified OS version, default OS=#{latest}" |
| 4 | + desc "Build targets on Travis CI with a specified OS version, default OS=latest" |
7 | 5 | task :build, [:os] do |t, args|
|
8 |
| - version = args[:os] || latest |
9 |
| - Rake::Task["framework:build"].invoke version |
10 |
| - Rake::Task["example:build"].invoke version |
| 6 | + Rake::Task["build"].execute os: args[:os], scheme: "ICInputAccessory-iOS" |
| 7 | + Rake::Task["build"].execute os: args[:os], scheme: "Example" |
11 | 8 | end
|
12 | 9 |
|
13 |
| - desc "Run tests on Travis CI with a specified OS version, default OS=#{latest}" |
| 10 | + desc "Run tests on Travis CI with a specified OS version, default OS=latest" |
14 | 11 | task :test, [:os] do |t, args|
|
15 |
| - version = args[:os] || latest |
16 |
| - Rake::Task["framework:build"].invoke version |
17 | 12 | # UI Testing requires iOS Simulator 9.0 or later.
|
18 |
| - if Gem::Version.new("9.0") <= Gem::Version.new(version) |
19 |
| - Rake::Task["example:test"].invoke version |
20 |
| - else |
21 |
| - Rake::Task["example:build"].invoke version |
22 |
| - end |
| 13 | + action = !args[:os] || Gem::Version.new("9.0") <= Gem::Version.new(args[:os]) ? "test" : "build" |
| 14 | + Rake::Task[action].execute os: args[:os], scheme: "Example" |
23 | 15 | end
|
24 | 16 | end
|
25 | 17 |
|
26 | 18 |
|
27 |
| -namespace :example do |
28 |
| - desc "Build the example project" |
29 |
| - task :build, [:os] do |t, args| |
30 |
| - version = args[:os] || latest |
31 |
| - sh %(xcodebuild -workspace ICInputAccessory.xcworkspace -scheme Example -sdk iphonesimulator -destination "name=iPhone 6s,OS=#{version}" clean build | xcpretty -c && exit ${PIPESTATUS[0]}) |
32 |
| - exit $?.exitstatus if not $?.success? |
33 |
| - end |
| 19 | +def xcodebuild(params) |
| 20 | + [ |
| 21 | + %(xcodebuild), |
| 22 | + %(-workspace ICInputAccessory.xcworkspace), |
| 23 | + %(-scheme #{params[:scheme]}), |
| 24 | + %(-sdk iphonesimulator), |
| 25 | + %(-destination 'name=iPhone 7,OS=#{params[:version] || "latest"}'), |
| 26 | + %(#{params[:action]} | xcpretty -c && exit ${PIPESTATUS[0]}) |
| 27 | + ].join " " |
| 28 | +end |
34 | 29 |
|
35 |
| - desc "Run the UI tests in the example project" |
36 |
| - task :test, [:os] do |t, args| |
37 |
| - version = args[:os] || latest |
38 |
| - sh %(xcodebuild -workspace ICInputAccessory.xcworkspace -scheme Example -sdk iphonesimulator -destination "name=iPhone 6s,OS=#{version}" clean test | xcpretty -c && exit ${PIPESTATUS[0]}) |
39 |
| - exit $?.exitstatus if not $?.success? |
40 |
| - end |
| 30 | + |
| 31 | +desc "Build the target with the specified scheme" |
| 32 | +task :build, [:os, :scheme] do |t, args| |
| 33 | + sh xcodebuild(scheme: args[:scheme], version: args[:os], action: "clean build") |
| 34 | + exit $?.exitstatus if not $?.success? |
41 | 35 | end
|
42 | 36 |
|
43 |
| -namespace :framework do |
44 |
| - desc "Build the framework project" |
45 |
| - task :build, [:os] do |t, args| |
46 |
| - version = args[:os] || "latest" |
47 |
| - sh %(xcodebuild -project ICInputAccessory.xcodeproj -scheme ICInputAccessory-iOS -sdk iphonesimulator -destination "name=iPhone 6s,OS=#{version}" clean build | xcpretty -c && exit ${PIPESTATUS[0]}) |
48 |
| - exit $?.exitstatus if not $?.success? |
49 |
| - end |
| 37 | + |
| 38 | +desc "Run the UI tests in the example project" |
| 39 | +task :test, [:os] do |t, args| |
| 40 | + sh xcodebuild(scheme: "Example", version: args[:os], action: "clean test") |
| 41 | + exit $?.exitstatus if not $?.success? |
50 | 42 | end
|
51 | 43 |
|
52 | 44 |
|
|
0 commit comments