forked from realm/realm-swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.releasability
330 lines (280 loc) · 9.75 KB
/
Jenkinsfile.releasability
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
xcodeVersions = ['11.3', '11.7', '12.1', '12.2', '12.4']
platforms = ['osx', 'ios', 'watchos', 'tvos', 'catalyst']
carthagePlatforms = ['osx', 'ios', 'watchos', 'tvos']
platformNames = ['osx': 'macOS', 'ios': 'iOS', 'watchos': 'watchOS', 'tvos': 'tvOS', 'catalyst': 'Catalyst']
carthageXcodeVersion = '12.4'
objcXcodeVersion = '11.3'
docsSwiftVersion = '5.3.2'
def installationTest(platform, test, language) {
return {
node('osx') {
deleteDir()
unstash 'source'
if (test == "dynamic" || test == "static") {
unstash "${language}-packaged"
}
sh """
hostname
export REALM_XCODE_VERSION=${carthageXcodeVersion}
archive=\$(echo \$PWD/realm-${language}-*.zip)
cd examples/installation
if [[ -f \$archive ]]; then
mv \$archive .
unzip realm-${language}-*.zip
rm realm-${language}-*.zip
mv realm-${language}-* realm-${language}-latest
fi
./build.sh test-${platform}-${language}-${test}
"""
}
}
}
def spmInstallationTest(platform) {
return {
node('osx') {
deleteDir()
unstash 'source'
sh """
hostname
export REALM_XCODE_VERSION=${carthageXcodeVersion}
cd examples/installation
./build.sh test-${platform}-spm
"""
}
}
}
def doBuild() {
stage('prepare') {
node('docker') {
deleteDir()
checkout(
[
$class : 'GitSCM',
branches : scm.branches,
gitTool : 'native git',
extensions : scm.extensions + [[$class: 'CleanCheckout']],
userRemoteConfigs: scm.userRemoteConfigs,
]
)
stash includes: '**', name: 'source'
}
}
stage('build') {
def parallelBuilds = [
'Docs': {
node('osx') {
deleteDir()
unstash 'source'
sh """
hostname
export REALM_SWIFT_VERSION=${docsSwiftVersion}
export PATH='/Users/realm/.rbenv/bin:/Users/realm/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/realm/.gems/bin'
./scripts/reset-simulators.sh
./build.sh docs
cd docs
zip -r objc-docs.zip objc_output
zip -r swift-docs.zip swift_output
"""
dir('docs') {
archiveArtifacts artifacts: '*-docs.zip'
}
}
},
'Examples': {
node('osx') {
deleteDir()
unstash 'source'
sh './build.sh package-examples'
stash includes: 'realm-examples.zip', name: 'examples'
}
},
'iOS Obj-C static': {
node('osx') {
deleteDir()
unstash 'source'
sh "REALM_XCODE_VERSION=${objcXcodeVersion} ./build.sh package-ios-static"
dir("build/ios-static") {
stash includes: "realm-framework-ios-static.zip", name: "ios-static"
}
}
}
]
for (def p in carthagePlatforms) {
def platform = p
def platformName = platformNames[platform]
parallelBuilds["${platformName} Carthage"] = {
node('osx') {
deleteDir()
unstash 'source'
sh """
hostname
export REALM_XCODE_VERSION=${carthageXcodeVersion}
. ./scripts/swift-version.sh
set_xcode_and_swift_versions
# Carthage scans every xcodeproj in the directory looking for
# targets. This can be very slow and even spuriously time out, so
# remove the ones we don't want it to build.
rm -r examples plugin
# For whatever reason 'xcodebuild -list' is very slow sometimes which
# makes Carthage time out, but it's a lot faster if no simulators
# exist, so delete them all first and only create a single simulator
# for each platform.
./scripts/reset-simulators.rb -firstOnly
# Building the iOS static scheme just wastes time, so delete it
rm 'Realm.xcodeproj/xcshareddata/xcschemes/Realm iOS static.xcscheme'
carthage build --no-skip-current --platform ${platform} --derived-data DerivedData
carthage archive --output Carthage-${platform}.framework.zip
"""
stash includes: "Carthage-${platform}.framework.zip",
name: "${platform}-carthage"
}
}
}
for (def p in platforms) {
def platform = p
def platformName = platformNames[platform]
for (def v in xcodeVersions) {
def xcodeVersion = v
parallelBuilds["${platformName} ${xcodeVersion}"] = {
node('osx') {
deleteDir()
unstash 'source'
sh "REALM_XCODE_VERSION=${xcodeVersion} ./build.sh package ${platform}"
dir("build/${platform}") {
stash includes: "realm-framework-${platform}-${xcodeVersion}.zip",
name: "${platform}-${xcodeVersion}"
}
}
}
}
}
parallel parallelBuilds
}
stage('package') {
parallel (
"Obj-C": {
node('osx') {
deleteDir()
for (def platform in platforms) {
unstash "${platform}-${objcXcodeVersion}"
}
unstash 'ios-static'
unstash 'examples'
unstash 'source'
sh "REALM_XCODE_VERSION=${objcXcodeVersion} ./build.sh package-release objc"
stash include: 'realm-objc-*.zip', name: 'objc-packaged'
archiveArtifacts artifacts: 'realm-objc-*.zip'
}
},
"Swift": {
node('osx') {
deleteDir()
for (def platform in platforms) {
for (def xcodeVersion in xcodeVersions) {
unstash "${platform}-${xcodeVersion}"
}
}
unstash 'examples'
unstash 'source'
sh './build.sh package-release swift'
stash include: 'realm-swift-*.zip', name: 'swift-packaged'
archiveArtifacts artifacts: 'realm-swift-*.zip'
}
},
"Carthage": {
node('osx') {
deleteDir()
for (def platform in carthagePlatforms) {
unstash "${platform}-carthage"
}
sh '''
for zip in Carthage-*.framework.zip; do
ditto -xk $zip merged/
done
ditto -ck merged/ Carthage.framework.zip
'''
archiveArtifacts artifacts: 'Carthage.framework.zip'
}
}
)
}
stage('test') {
def parallelBuilds = [
'Test Obj-C Examples': {
node('osx') {
deleteDir()
unstash 'objc-packaged'
def sha = params.sha
sh """
hostname
curl -O https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/build.sh
mkdir -p scripts
curl https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/scripts/swift-version.sh -o scripts/swift-version.sh
curl https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/scripts/reset-simulators.sh -o scripts/reset-simulators.sh
curl https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/scripts/reset-simulators.rb -o scripts/reset-simulators.rb
chmod +x scripts/reset-simulators.rb
sh build.sh package-test-examples-objc
"""
}
},
'Test Swift Examples': {
node('osx') {
deleteDir()
unstash 'swift-packaged'
def sha = params.sha
sh """
hostname
curl -O https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/build.sh
mkdir -p scripts
curl https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/scripts/swift-version.sh -o scripts/swift-version.sh
curl https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/scripts/reset-simulators.sh -o scripts/reset-simulators.sh
curl https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/scripts/reset-simulators.rb -o scripts/reset-simulators.rb
chmod +x scripts/reset-simulators.rb
sh build.sh package-test-examples-swift
"""
}
},
'Test iOS static': {
node('osx') {
deleteDir()
unstash 'source'
sh './scripts/reset-simulators.rb'
sh 'sh build.sh test-ios-static'
}
},
'Test macOS': {
node('osx') {
deleteDir()
unstash 'source'
sh 'sh build.sh test-osx'
}
}
]
for (def platform in ["osx", "ios", "watchos"]) {
def platformName = platformNames[platform]
for (def test in ["dynamic", "cocoapods", "carthage"]) {
parallelBuilds["Installation - ${platformName} Obj-C ${test}"] = installationTest(platform, test, 'objc')
}
}
parallelBuilds["Installation - iOS Obj-C static"] = installationTest('ios', 'static', 'objc')
parallelBuilds["Installation - iOS Obj-C CocoaPods dynamic"] = installationTest('ios', 'cocoapods-dynamic', 'objc')
parallelBuilds["Installation - iOS Swift Package Manager"] = spmInstallationTest('ios')
parallelBuilds["Installation - Mac Catalyst Obj-C CocoaPods"] = installationTest('catalyst', 'cocoapods', 'objc')
parallelBuilds["Installation - Mac Catalyst Obj-C CocoaPods dynamic"] = installationTest('catalyst', 'cocoapods-dynamic', 'objc')
for (def platform in ["osx", "ios", "watchos"]) {
def platformName = platformNames[platform]
for (def test in ["dynamic", "cocoapods", "carthage"]) {
parallelBuilds["Installation - ${platformName} Swift ${test}"] = installationTest(platform, test, 'swift')
}
}
parallelBuilds["Installation - Mac Catalyst Swift CocoaPods"] = installationTest('catalyst', 'cocoapods', 'swift')
parallel parallelBuilds
}
}
try {
doBuild()
} catch (e) {
// If there was an exception thrown, the build failed
currentBuild.result = "FAILED"
throw e
}