This repository has been archived by the owner on Mar 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
/
Rakefile
128 lines (103 loc) · 3.59 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#
# The various workspaces, schemes and destinations we test using
#
# Workspaces
CDTDATASTORE_WS = 'CDTDatastore.xcworkspace'
SAMPLE_APP_WS = 'Project/Project.xcworkspace'
# Schemes
TESTS_IOS = 'CDTDatastoreTests'
TESTS_OSX = 'CDTDatastoreTestsOSX'
REPLICATION_ACCEPTANCE_IOS = 'CDTDatastoreReplicationAcceptanceTests'
REPLICATION_ACCEPTANCE_OSX = 'CDTDatastoreReplicationAcceptanceTestsOSX'
SAMPLE_IOS = "Project"
# Destinations
IPHONE_DEST = (ENV["IPHONE_DEST"] == nil || ENV["IPHONE_DEST"] == "null") ? 'platform=iOS Simulator,OS=latest,name=iPhone SE' : ENV["IPHONE_DEST"]
OSX_DEST = (ENV["OSX_DEST"] == nil || ENV["IPHONE_DEST"] == "null") ? 'platform=OS X' : ENV["OSX_DEST"]
#
# Primary tasks
#
desc "Run tests for all platforms"
task :test => [:testios, :testosx] do
end
desc "Task for travis"
task :travis => [:podupdate, :test, :sample, :podliblint] do
end
#
# Linting pod
#
desc "pod lib lint"
task :podliblint do
sh "pod lib lint --allow-warnings --use-libraries --verbose | xcpretty; exit ${PIPESTATUS[0]}"
end
#
# Update pods
#
desc "pod update"
task :podupdatetests do
sh "pod update"
end
desc "sample pod update"
task :podupdatesample do
sh "cd Project && pod update"
end
desc "pod update"
task :podupdate => [:podupdatetests] do
end
# Sample build task
desc "Build sample iOS application"
task :sample => [:podupdatesample] do
unless run_build(SAMPLE_APP_WS,SAMPLE_IOS,IPHONE_DEST)
fail "[FAILED] Sample failed to compile"
end
end
#
# Specific test tasks
#
desc "Run the CDTDatastore Tests for iOS"
task :testios do
if (ENV["PLATFORM"] == nil || ENV["PLATFORM"] == "iOS")
test(CDTDATASTORE_WS, TESTS_IOS, IPHONE_DEST)
end
end
desc "Run the CDTDatastore Tests for OS X"
task :testosx do
if (ENV["PLATFORM"] == nil || ENV["PLATFORM"] == "OSX")
test(CDTDATASTORE_WS, TESTS_OSX, OSX_DEST)
end
end
desc "Run the replication acceptance tests for OS X"
task :replicationacceptanceosx do
test(CDTDATASTORE_WS, REPLICATION_ACCEPTANCE_OSX, OSX_DEST)
end
desc "Run the replication acceptance tests for iOS"
task :replicationacceptanceios do
test(CDTDATASTORE_WS, REPLICATION_ACCEPTANCE_IOS, IPHONE_DEST)
end
#
# Update docs
#
desc "Build docs and install to Xcode"
task :docs do
system("appledoc --keep-intermediate-files --project-name CDTDatastore --project-company Cloudant -o build/docs --company-id com.cloudant -i CDTDatastore/vendor/ -i CDTDatastore/touchdb/ CDTDatastore")
end
#
# Helper methods
#
# Runs `build` target for workspace/scheme/destination
def run_build(workspace, scheme, destination)
settings = "GCC_PREPROCESSOR_DEFINITIONS='${inherited} ENCRYPT_DATABASE=1'" unless !ENV["encrypted"]
# build using xcpretty as otherwise it's very verbose when running tests
return system("xcodebuild -configuration Release -workspace #{workspace} -scheme '#{scheme}' -destination '#{destination}' #{settings} build | xcpretty; exit ${PIPESTATUS[0]}")
end
# Runs `test` target for workspace/scheme/destination
def run_tests(workspace, scheme, destination)
settings = "GCC_PREPROCESSOR_DEFINITIONS='${inherited} ENCRYPT_DATABASE=1'" unless !ENV["encrypted"]
# if jenkins passed us a log name, use that, otherwise default to "#{scheme}.log"
logName = (ENV["LOG_NAME"] == nil ? "#{scheme}.log" : ENV["LOG_NAME"])
return system("xcodebuild -configuration Release -verbose -workspace #{workspace} -scheme '#{scheme}' -destination '#{destination}' #{settings} test | tee #{logName} | xcpretty -r junit; exit ${PIPESTATUS[0]}")
end
def test(workspace, scheme, destination)
unless run_tests(workspace, scheme, destination)
fail "[FAILED] Tests #{workspace}, #{scheme}"
end
end