-
Notifications
You must be signed in to change notification settings - Fork 164
/
Rakefile
106 lines (85 loc) · 3.23 KB
/
Rakefile
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
include FileUtils::Verbose
namespace :test do
desc 'Prepare tests'
task :prepare do
end
desc 'Run the MatomoTracker Unit tests'
task ios: :prepare do
run_tests('MatomoTracker', 'iphonesimulator', 'platform=iOS Simulator,name=iPhone 6,OS=12.4')
build_failed('tests') unless $?.success?
run_tests('MatomoTracker', 'iphonesimulator', 'platform=iOS Simulator,name=iPhone 6,OS=11.4')
build_failed('tests') unless $?.success?
# When running Quick on iOS 10.3.1 it fails with a EXC_BAD_ACCESS
# run_tests('MatomoTracker', 'iphonesimulator', 'platform=iOS Simulator,name=iPhone 6,OS=10.3.1')
# build_failed('tests') unless $?.success?
end
desc 'Build the MatomoTracker iOS demo'
task ios_demo: :prepare do
run_build('ios', 'iphonesimulator', 'platform=iOS Simulator,name=iPhone 6,OS=12.4')
build_failed('iOS') unless $?.success?
end
desc 'Build the MatomoTracker OSX demo'
task osx_demo: :prepare do
run_build('macos', 'macosx', 'platform=macOS,arch=x86_64')
build_failed('macOS') unless $?.success?
end
desc 'Build the MatomoTracker tvOS demo'
task tvos_demo: :prepare do
run_build('tvos', 'appletvsimulator', 'platform=tvOS Simulator,name=Apple TV,OS=14.3')
build_failed('tvOS') unless $?.success?
end
end
namespace :package_manager do
desc 'Prepare tests'
task :prepare do
end
desc 'Builds the project with Carthage'
task carthage: :prepare do
sh("carthage build --no-skip-current") rescue nil
package_manager_failed('Carthage integration') unless $?.success?
end
desc 'Builds the project with the Swift Package Manager'
task spm: :prepare do
sh("swift build") rescue nil
package_manager_failed('Swift Package Manager') unless $?.success?
end
end
desc 'Run the MatomoTracker tests for iOS & Mac OS X'
task :test do
Rake::Task['test:ios'].invoke
Rake::Task['test:ios_demo'].invoke
Rake::Task['test:osx_demo'].invoke
Rake::Task['test:tvos_demo'].invoke
end
desc 'Check the integration of MatomoTracker with package managers'
task :build_with_package_manager do
Rake::Task['package_manager:carthage'].invoke
Rake::Task['package_manager:spm'].invoke
end
task default: 'test'
private
def run_build(scheme, sdk, destination = 'platform=iOS Simulator,name=iPhone 6,OS=12.4')
sh("xcodebuild -workspace MatomoTracker.xcworkspace -scheme '#{scheme}' -sdk '#{sdk}' -destination '#{destination}' -configuration Release clean build | xcpretty -c ; exit ${PIPESTATUS[0]}") rescue nil
end
def run_tests(scheme, sdk, destination = 'platform=iOS Simulator,name=iPhone 6,OS=12.4')
sh("xcodebuild -workspace MatomoTracker.xcworkspace -scheme '#{scheme}' -sdk '#{sdk}' -destination '#{destination}' -configuration Debug clean test | xcpretty -c ; exit ${PIPESTATUS[0]}") rescue nil
end
def is_mavericks_or_above
osx_version = `sw_vers -productVersion`.chomp
Gem::Version.new(osx_version) >= Gem::Version.new('10.9')
end
def build_failed(platform)
puts red("#{platform} build failed")
exit $?.exitstatus
end
def tests_failed(platform)
puts red("#{platform} unit tests failed")
exit $?.exitstatus
end
def package_manager_failed(package_manager)
puts red("Integration with #{package_manager} failed")
exit $?.exitstatus
end
def red(string)
"\033[0;31m! #{string}"
end