forked from realm/realm-swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile.releasability
276 lines (234 loc) · 7.58 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
swiftVersions = ['3.1', '3.2', '3.2.2', '3.2.3', '3.3', '4.0', '4.0.2', '4.0.3', '4.1']
platforms = ['osx', 'ios', 'watchos', 'tvos']
platformNames = ['osx': 'macOS', 'ios': 'iOS', 'watchos': 'watchOS', 'tvos': 'tvOS']
carthageXcodeVersion = '9.3'
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
find . -name 'realm-${language}-*' -print0 | xargs -J% mv % realm-${language}-latest
fi
./build.sh test-${platform}-${language}-${test}
"""
}
}
}
def buildObjC(platform, outputDirectory=null) {
return {
node('osx') {
deleteDir()
unstash 'source'
sh "XCMODE=xcpretty ./build.sh package-${platform}"
dir(outputDirectory ?: "build/${platform}") {
stash includes: "realm-framework-${platform}.zip", name: "${platform}-objc"
}
}
}
}
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=${swiftVersions.last()}
./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'
}
},
'macOS Obj-C': buildObjC('osx', 'build/DerivedData/Realm/Build/Products/Release'),
'iOS Obj-C': buildObjC('ios'),
'watchOS Obj-C': buildObjC('watchos'),
'tvOS Obj-C': buildObjC('tvos'),
'iOS Obj-C static': buildObjC('ios-static'),
]
for (def p in platforms) {
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
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 swiftVersions) {
def swiftVersion = v
parallelBuilds["${platformName} Swift ${swiftVersion}"] = {
node('osx') {
deleteDir()
unstash 'source'
sh "XCMODE=xcpretty ./build.sh package-${platform}-swift-${swiftVersion}"
dir("build/${platform}") {
stash includes: "realm-swift-framework-${platform}-swift-${swiftVersion}.zip",
name: "${platform}-swift-${swiftVersion}"
}
}
}
}
}
parallel parallelBuilds
}
stage('package') {
parallel (
"Obj-C": {
node('osx') {
deleteDir()
for (def platform in platforms) {
unstash "${platform}-objc"
}
unstash 'ios-static-objc'
unstash 'examples'
unstash 'source'
sh './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 swiftVersion in swiftVersions) {
unstash "${platform}-swift-${swiftVersion}"
}
}
unstash 'examples'
unstash 'source'
sh './build.sh package-release swift'
sh 'rm realm-swift-framework-*.zip'
stash include: 'realm-swift-*.zip', name: 'swift-packaged'
archiveArtifacts artifacts: 'realm-swift-*.zip'
}
},
"Carthage": {
node('osx') {
deleteDir()
for (def platform in platforms) {
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 Examples': {
node('osx') {
deleteDir()
// FIXME: Split Obj-C and Swift.
unstash 'objc-packaged'
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
"""
}
},
'Test iOS static': {
node('osx') {
deleteDir()
unstash 'source'
sh 'XCMODE=xcpretty IS_RUNNING_PACKAGING=1 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"]) {
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"]) {
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
}