forked from realm/realm-swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.releasability
299 lines (253 loc) · 8.63 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
xcodeVersions = ['10.0', '10.1', '10.2.1', '10.3', '11.1', '11.2']
platforms = ['osx', 'ios', 'watchos', 'tvos', 'catalyst']
carthagePlatforms = ['osx', 'ios', 'watchos', 'tvos']
platformNames = ['osx': 'macOS', 'ios': 'iOS', 'watchos': 'watchOS', 'tvos': 'tvOS', 'catalyst': 'Catalyst']
carthageXcodeVersion = '11.2'
objcXcodeVersion = '10.1'
docsSwiftVersion = '5.1'
def installationTest(platform, test, language) {
return {
node('osx') {
deleteDir()
unstash 'source'
if (test == "dynamic" || test == "static") {
unstash "${language}-packaged"
}
sh """
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
export REALM_XCODE_VERSION=${carthageXcodeVersion}
./build.sh test-${platform}-${language}-${test}
"""
}
}
}
def doBuild() {
stage('prepare') {
node('docker') {
deleteDir()
checkout(
[
$class : 'GitSCM',
branches : scm.branches,
gitTool : 'native git',
extensions : scm.extensions + [[$class: 'CleanCheckout'],
[$class: 'SubmoduleOption', parentCredentials: true]],
userRemoteConfigs: scm.userRemoteConfigs,
]
)
stash includes: '**', name: 'source'
}
}
stage('build') {
def parallelBuilds = [
'Docs': {
node('osx') {
deleteDir()
unstash 'source'
sh """
export REALM_SWIFT_VERSION=${docsSwiftVersion}
./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 'XCMODE=xcpretty ./build.sh package-examples'
stash includes: 'realm-examples.zip', name: 'examples'
}
},
'iOS Obj-C static': {
node('osx') {
deleteDir()
unstash 'source'
sh "XCMODE=xcpretty 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 """
export REALM_XCODE_VERSION=${carthageXcodeVersion}
. ./scripts/swift-version.sh
set_xcode_and_swift_versions
if [ "${platform}" != osx ]; then
./scripts/reset-simulators.rb
fi
carthage build --no-skip-current --platform ${platform}
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 "XCMODE=xcpretty 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}"
}
// The 10.x builds don't actually have a framework for catalyst, so
// use the 11.0 version instead
unstash 'catalyst-11.1'
sh "mv realm-framework-catalyst-11.1.zip realm-framework-catalyst-${objcXcodeVersion}.zip"
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 """
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
XCMODE=xcpretty sh build.sh package-test-examples-objc
"""
}
},
'Test Swift Examples': {
node('osx') {
deleteDir()
unstash 'swift-packaged'
def sha = params.sha
sh """
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
XCMODE=xcpretty sh build.sh package-test-examples-swift
"""
}
},
'Test iOS static': {
node('osx') {
deleteDir()
unstash 'source'
sh './scripts/reset-simulators.rb'
sh 'XCMODE=xcpretty sh build.sh test-ios-static'
}
},
'Test macOS': {
node('osx') {
deleteDir()
unstash 'source'
sh 'XCMODE=xcpretty 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')
for (def platform in ["osx", "ios", "watchos"]) {
def platformName = platformNames[platform]
for (def test in ["cocoapods", "carthage"]) {
parallelBuilds["Installation - ${platformName} Swift ${test}"] = installationTest(platform, test, 'swift')
}
}
parallel parallelBuilds
}
}
try {
doBuild()
} catch (e) {
// If there was an exception thrown, the build failed
currentBuild.result = "FAILED"
throw e
}