forked from realm/realm-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
executable file
·668 lines (596 loc) · 22.8 KB
/
Jenkinsfile
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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
#!groovy
import groovy.json.JsonOutput
@Library('realm-ci') _
repoName = 'realm-js' // This is a global variable
// These versions must be written in ascending order (lowest version is used when testing)
def nodeVersions = ['10.22.0']
nodeTestVersion = nodeVersions[0]
nodePublishVersion = '10.22.0';
//Changing electron versions for testing requires upgrading the spectron dependency in tests/electron/package.json to a specific version.
//For more see https://www.npmjs.com/package/spectron
def electronVersions = ['8.4.1']
electronTestVersion = electronVersions[0]
def gitTag = null
def formattedVersion = null
dependencies = null
objectStoreDependencies = null
def packagesExclusivelyChanged = null
environment {
GIT_COMMITTER_NAME="ci"
GIT_COMMITTER_EMAIL="ci@realm.io"
ELECTRON_DISABLE_SANDBOX=1
}
// == Stages
stage('check') {
node('docker') {
checkout([
$class: 'GitSCM',
branches: scm.branches,
gitTool: 'native git',
extensions: scm.extensions + [
[$class: 'WipeWorkspace'],
[$class: 'CleanCheckout'],
[$class: 'CloneOption', depth: 1, shallow: true, noTags: false],
[$class: 'SubmoduleOption', recursiveSubmodules: true, shallow: true, depth: 1]
],
userRemoteConfigs: scm.userRemoteConfigs
])
// Abort early if only files in "packages/**" changed, since these will migrate to another CI platform
packagesExclusivelyChanged = exclusivelyChanged("^packages/.*")
if (packagesExclusivelyChanged) {
currentBuild.result = 'SUCCESS'
echo 'Stopped since there were only changes to "/packages"'
return
}
dependencies = readProperties file: 'dependencies.list'
objectStoreDependencies = readProperties file: 'src/object-store/dependencies.list'
gitTag = readGitTag()
def gitSha = readGitSha()
def version = getVersion()
echo "tag: ${gitTag}"
if (gitTag == "") {
echo "No tag given for this build"
setBuildName("${gitSha}")
} else {
if (gitTag != "v${dependencies.VERSION}") {
echo "Git tag '${gitTag}' does not match v${dependencies.VERSION}"
} else {
echo "Building release: '${gitTag}'"
setBuildName("Tag ${gitTag}")
}
}
echo "version: ${version}"
stash name: 'source', includes:'**/*', excludes:'react-native/android/src/main/jni/src/object-store/.dockerignore'
if (['master'].contains(env.BRANCH_NAME)) {
// If we're on master, instruct the docker image builds to push to the
// cache registry
env.DOCKER_PUSH = "1"
}
}
}
// Ensure no other stages are executed
if (packagesExclusivelyChanged) {
return
}
stage('pretest') {
parallelExecutors = [:]
parallelExecutors["eslint"] = testLinux("eslint-ci Release ${nodeTestVersion}", { // "Release" is not used
step([
$class: 'CheckStylePublisher',
canComputeNew: false,
canRunOnFailed: true,
defaultEncoding: '',
healthy: '',
pattern: 'eslint.xml',
unHealthy: '',
maxWarnings: 0,
ignoreFailures: false])
})
parallelExecutors["jsdoc"] = testLinux("jsdoc Release ${nodeTestVersion}", { // "Release is not used
publishHTML([
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: false,
reportDir: 'docs/output',
reportFiles: 'index.html',
reportName: 'Docs'
])
})
parallel parallelExecutors
}
stage('build') {
parallelExecutors = [:]
nodeVersions.each { nodeVersion ->
parallelExecutors["macOS Node ${nodeVersion}"] = buildMacOS { buildCommon(nodeVersion, it) }
parallelExecutors["Linux Node ${nodeVersion}"] = buildLinux { buildCommon(nodeVersion, it) }
parallelExecutors["Linux Rpi Node ${nodeVersion}"] = buildLinuxRpi { buildCommon(nodeVersion, it, '--arch=arm') }
parallelExecutors["Windows Node ${nodeVersion} ia32"] = buildWindows(nodeVersion, 'ia32')
parallelExecutors["Windows Node ${nodeVersion} x64"] = buildWindows(nodeVersion, 'x64')
}
electronVersions.each { electronVersion ->
parallelExecutors["macOS Electron ${electronVersion}"] = buildMacOS { buildElectronCommon(electronVersion, it) }
parallelExecutors["Linux Electron ${electronVersion}"] = buildLinux { buildElectronCommon(electronVersion, it) }
parallelExecutors["Windows Electron ${electronVersion} ia32"] = buildWindowsElectron(electronVersion, 'ia32')
parallelExecutors["Windows Electron ${electronVersion} x64"] = buildWindowsElectron(electronVersion, 'x64')
}
parallelExecutors["Android React Native"] = buildAndroid()
parallel parallelExecutors
}
if (gitTag) {
stage('publish') {
publish(nodeVersions, electronVersions, dependencies, gitTag)
}
}
stage('test') {
parallelExecutors = [:]
parallelExecutors["macOS node ${nodeTestVersion} Debug"] = testMacOS("node Debug ${nodeTestVersion}")
parallelExecutors["macOS node ${nodeTestVersion} Release"] = testMacOS("node Release ${nodeTestVersion}")
parallelExecutors["macOS test runners ${nodeTestVersion}"] = testMacOS("test-runners Release ${nodeTestVersion}")
parallelExecutors["Linux node ${nodeTestVersion} Release"] = testLinux("node Release ${nodeTestVersion}", null, true)
parallelExecutors["Linux test runners ${nodeTestVersion}"] = testLinux("test-runners Release ${nodeTestVersion}")
parallelExecutors["Windows node ${nodeTestVersion}"] = testWindows(nodeTestVersion)
//parallelExecutors["React Native iOS Debug"] = testMacOS('react-tests Debug')
parallelExecutors["React Native iOS Release"] = testMacOS('react-tests Release')
//parallelExecutors["React Native iOS Example Debug"] = testMacOS('react-example Debug')
parallelExecutors["React Native iOS Example Release"] = testMacOS('react-example Release')
parallelExecutors["macOS Electron Debug"] = testMacOS('electron Debug')
parallelExecutors["macOS Electron Release"] = testMacOS('electron Release')
//android_react_tests: testAndroid('react-tests-android', {
// junit 'tests/react-test-app/tests.xml'
//}),
parallel parallelExecutors
}
stage('prepare integration tests') {
parallel(
'Build integration tests': buildLinux {
sh "./scripts/nvm-wrapper.sh ${nodeTestVersion} npm ci --ignore-scripts"
dir('integration-tests/tests') {
sh "../../scripts/nvm-wrapper.sh ${nodeTestVersion} npm ci --ignore-scripts"
sh "../../scripts/nvm-wrapper.sh ${nodeTestVersion} npm pack"
sh 'mv realm-integration-tests-*.tgz realm-integration-tests.tgz'
stash includes: 'realm-integration-tests.tgz', name: 'integration-tests-tgz'
}
}
)
}
stage('integration tests') {
parallel(
'React Native on Android': inAndroidContainer { reactNativeIntegrationTests('android') },
'React Native on iOS': buildMacOS { reactNativeIntegrationTests('ios') },
'Electron on Mac': buildMacOS { electronIntegrationTests(electronTestVersion, it) },
'Electron on Linux': buildLinux { electronIntegrationTests(electronTestVersion, it) },
'Node.js v10 on Mac': buildMacOS { nodeIntegrationTests(nodeTestVersion, it) },
'Node.js v10 on Linux': buildLinux { nodeIntegrationTests(nodeTestVersion, it) }
)
}
def exclusivelyChanged(regexp) {
// Checks if this is a change/pull request and if the files changed exclusively match the provided regular expression
return env.CHANGE_TARGET && sh(
returnStatus: true,
script: "git diff origin/$CHANGE_TARGET --name-only | grep --invert-match '${regexp}'"
) != 0
}
// == Methods
def nodeIntegrationTests(nodeVersion, platform) {
unstash 'source'
unstash "pre-gyp-${platform}-${nodeVersion}"
sh "./scripts/nvm-wrapper.sh ${nodeVersion} ./scripts/pack-with-pre-gyp.sh"
dir('integration-tests') {
// Renaming the package to avoid having to specify version in the apps package.json
sh 'mv realm-*.tgz realm.tgz'
// Unstash the integration tests package
unstash 'integration-tests-tgz'
}
dir('integration-tests/environments/node') {
sh "../../../scripts/nvm-wrapper.sh ${nodeVersion} npm install"
try {
sh "../../../scripts/nvm-wrapper.sh ${nodeVersion} npm test -- --reporter mocha-junit-reporter"
} finally {
junit(
allowEmptyResults: true,
testResults: 'test-results.xml',
)
}
}
}
def electronIntegrationTests(electronVersion, platform) {
def nodeVersion = nodeTestVersion
unstash 'source'
unstash "electron-pre-gyp-${platform}-${electronVersion}"
sh "./scripts/nvm-wrapper.sh ${nodeVersion} ./scripts/pack-with-pre-gyp.sh"
dir('integration-tests') {
// Renaming the package to avoid having to specify version in the apps package.json
sh 'mv realm-*.tgz realm.tgz'
// Unstash the integration tests package
unstash 'integration-tests-tgz'
}
// On linux we need to use xvfb to let up open GUI windows on the headless machine
def commandPrefix = platform == 'linux' ? 'xvfb-run ' : ''
dir('integration-tests/environments/electron') {
sh "../../../scripts/nvm-wrapper.sh ${nodeVersion} npm install"
try {
sh "../../../scripts/nvm-wrapper.sh ${nodeVersion} ${commandPrefix} npm run test/main -- main-test-results.xml"
sh "../../../scripts/nvm-wrapper.sh ${nodeVersion} ${commandPrefix} npm run test/renderer -- renderer-test-results.xml"
} finally {
junit(
allowEmptyResults: true,
testResults: '*-test-results.xml',
)
}
}
}
def reactNativeIntegrationTests(targetPlatform) {
def nodeVersion = nodeTestVersion
unstash 'source'
def nvm
if (targetPlatform == "android") {
nvm = ""
} else {
nvm = "${env.WORKSPACE}/scripts/nvm-wrapper.sh ${nodeVersion}"
}
dir('integration-tests') {
if (targetPlatform == "android") {
unstash 'android'
} else {
// Pack up Realm JS into a .tar
sh "${nvm} npm pack .."
}
// Renaming the package to avoid having to specify version in the apps package.json
sh 'mv realm-*.tgz realm.tgz'
// Unstash the integration tests package
unstash 'integration-tests-tgz'
}
dir('integration-tests/environments/react-native') {
sh "${nvm} npm install"
if (targetPlatform == "android") {
// In case the tests fail, it's nice to have an idea on the devices attached to the machine
sh 'adb devices'
sh 'adb wait-for-device'
// Uninstall any other installations of this package before trying to install it again
sh 'adb uninstall io.realm.tests.reactnative || true' // '|| true' because the app might already not be installed
} else if (targetPlatform == "ios") {
dir('ios') {
sh 'pod install --verbose'
}
}
timeout(30) { // minutes
try {
sh "${nvm} npm run test/${targetPlatform} -- --junit-output-path test-results.xml"
} finally {
junit(
allowEmptyResults: true,
testResults: 'test-results.xml',
)
if (targetPlatform == "android") {
// Read out the logs in case we want some more information to debug from
sh 'adb logcat -d -s ReactNativeJS:*'
}
}
}
}
}
def myNode(nodeSpec, block) {
node(nodeSpec) {
echo "Running job on ${env.NODE_NAME}"
try {
block.call()
} finally {
deleteDir()
}
}
}
def buildDockerEnv(name, extra_args='') {
docker.withRegistry("https://${env.DOCKER_REGISTRY}", "ecr:eu-west-1:aws-ci-user") {
sh "sh ./scripts/docker_build_wrapper.sh $name . ${extra_args}"
}
return docker.image(name)
}
def buildCommon(nodeVersion, platform, extraFlags='') {
sshagent(credentials: ['realm-ci-ssh']) {
sh "mkdir -p ~/.ssh"
sh "ssh-keyscan github.com >> ~/.ssh/known_hosts"
sh "echo \"Host github.com\n\tStrictHostKeyChecking no\n\" >> ~/.ssh/config"
sh "./scripts/nvm-wrapper.sh ${nodeVersion} npm run package ${extraFlags}"
}
dir("build/stage/node-pre-gyp/napi-v${dependencies.NAPI_VERSION}/realm-v${dependencies.VERSION}") {
// Uncomment this when testing build changes if you want to be able to download pre-built artifacts from Jenkins.
// archiveArtifacts("realm-*")
stash includes: 'realm-*', name: "pre-gyp-${platform}-${nodeVersion}"
}
}
def buildElectronCommon(electronVersion, platform) {
withEnv([
"npm_config_target=${electronVersion}",
"npm_config_disturl=https://atom.io/download/electron",
"npm_config_runtime=electron",
"npm_config_devdir=${env.HOME}/.electron-gyp"
]) {
sh "./scripts/nvm-wrapper.sh ${nodeTestVersion} npm run package"
dir("build/stage/node-pre-gyp/napi-v${dependencies.NAPI_VERSION}/realm-v${dependencies.VERSION}") {
stash includes: 'realm-*', name: "electron-pre-gyp-${platform}-${electronVersion}"
}
}
}
def buildLinux(workerFunction) {
return {
myNode('docker') {
unstash 'source'
def image
withCredentials([[$class: 'StringBinding', credentialsId: 'packagecloud-sync-devel-master-token', variable: 'PACKAGECLOUD_MASTER_TOKEN']]) {
image = buildDockerEnv('ci/realm-js:build')
}
sh "bash ./scripts/utils.sh set-version ${dependencies.VERSION}"
image.inside('-e HOME=/tmp') {
workerFunction('linux')
}
}
}
}
def buildLinuxRpi(workerFunction) {
return {
myNode('docker') {
unstash 'source'
sh "bash ./scripts/utils.sh set-version ${dependencies.VERSION}"
buildDockerEnv("ci/realm-js:rpi", '-f armhf.Dockerfile').inside('-e HOME=/tmp') {
withEnv(['CC=arm-linux-gnueabihf-gcc', 'CXX=arm-linux-gnueabihf-g++']) {
workerFunction('linux-armhf')
}
}
}
}
}
def buildMacOS(workerFunction) {
return {
myNode('osx_vegas') {
withEnv([
"DEVELOPER_DIR=/Applications/Xcode-11.2.app/Contents/Developer",
]) {
unstash 'source'
sh "bash ./scripts/utils.sh set-version ${dependencies.VERSION}"
workerFunction('macos')
}
}
}
}
def buildWindows(nodeVersion, arch) {
return {
myNode('windows && nodejs') {
unstash 'source'
bat 'npm install --ignore-scripts --production'
withEnv(["_MSPDBSRV_ENDPOINT_=${UUID.randomUUID().toString()}"]) {
retry(3) {
bat ".\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp.cmd rebuild --build_v8_with_gn=false --v8_enable_pointer_compression=0 --v8_enable_31bit_smis_on_64bit_arch=0 --target_arch=${arch} --target=${nodeVersion}"
}
}
bat ".\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp.cmd package --build_v8_with_gn=false --v8_enable_pointer_compression=0 --v8_enable_31bit_smis_on_64bit_arch=0 --target_arch=${arch} --target=${nodeVersion}"
dir("build/stage/node-pre-gyp/napi-v${dependencies.NAPI_VERSION}/realm-v${dependencies.VERSION}") {
stash includes: 'realm-*', name: "pre-gyp-windows-${arch}-${nodeVersion}"
}
}
}
}
def buildWindowsElectron(electronVersion, arch) {
return {
myNode('windows && nodejs') {
unstash 'source'
bat 'npm install --ignore-scripts --production'
withEnv([
"npm_config_target=${electronVersion}",
"npm_config_target_arch=${arch}",
'npm_config_disturl=https://atom.io/download/electron',
'npm_config_runtime=electron',
"npm_config_devdir=${env.HOME}/.electron-gyp"
]) {
withEnv(["_MSPDBSRV_ENDPOINT_=${UUID.randomUUID().toString()}"]) {
bat '.\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp.cmd rebuild --realm_enable_sync'
}
bat '.\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp.cmd package'
}
dir("build/stage/node-pre-gyp/napi-v${dependencies.NAPI_VERSION}/realm-v${dependencies.VERSION}") {
stash includes: 'realm-*', name: "electron-pre-gyp-windows-${arch}-${electronVersion}"
}
}
}
}
def inAndroidContainer(workerFunction) {
return {
myNode('android') {
unstash 'source'
def image
withCredentials([[$class: 'StringBinding', credentialsId: 'packagecloud-sync-devel-master-token', variable: 'PACKAGECLOUD_MASTER_TOKEN']]) {
image = buildDockerEnv('ci/realm-js:android-build', '-f Dockerfile.android')
}
// Locking on the "android" lock to prevent concurrent usage of the gradle-cache
// @see https://github.com/realm/realm-java/blob/00698d1/Jenkinsfile#L65
lock("${env.NODE_NAME}-android") {
image.inside(
// Mounting ~/.android/adbkey(.pub) to reuse the adb keys
"-v ${HOME}/.android/adbkey:/home/jenkins/.android/adbkey:ro -v ${HOME}/.android/adbkey.pub:/home/jenkins/.android/adbkey.pub:ro " +
// Mounting ~/gradle-cache as ~/.gradle to prevent gradle from being redownloaded
"-v ${HOME}/gradle-cache:/home/jenkins/.gradle " +
// Mounting ~/ccache as ~/.ccache to reuse the cache across builds
"-v ${HOME}/ccache:/home/jenkins/.ccache " +
// Mounting /dev/bus/usb with --privileged to allow connecting to the device via USB
"-v /dev/bus/usb:/dev/bus/usb --privileged"
) {
workerFunction()
}
}
}
}
}
def buildAndroid() {
inAndroidContainer {
sh 'npm ci --ignore-scripts'
sh 'cd react-native/android && ./gradlew publishAndroid'
sh 'npm pack'
stash includes: 'realm-*.tgz', name: 'android'
}
}
def publish(nodeVersions, electronVersions, dependencies, tag) {
myNode('docker') {
for (def platform in ['macos', 'linux', 'windows-ia32', 'windows-x64']) {
unstash "pre-gyp-${platform}-${nodePublishVersion}"
}
unstash "pre-gyp-linux-armhf-${nodePublishVersion}"
withCredentials([[$class: 'FileBinding', credentialsId: 'c0cc8f9e-c3f1-4e22-b22f-6568392e26ae', variable: 's3cfg_config_file']]) {
sh "s3cmd -c \$s3cfg_config_file put --multipart-chunk-size-mb 5 realm-* 's3://static.realm.io/node-pre-gyp/napi-v${dependencies.NAPI_VERSION}/realm-v${dependencies.VERSION}/'"
}
}
}
def readGitTag() {
return sh(returnStdout: true, script: 'git describe --exact-match --tags HEAD || echo ""').readLines().last().trim()
}
def readGitSha() {
return sh(returnStdout: true, script: 'git rev-parse --short HEAD').readLines().last().trim()
}
def getVersion() {
def dependencies = readProperties file: 'dependencies.list'
if (readGitTag() == "") {
return "${dependencies.VERSION}-g${readGitSha()}"
}
else {
return dependencies.VERSION
}
}
def setBuildName(newBuildName) {
currentBuild.displayName = "${currentBuild.displayName} - ${newBuildName}"
}
def reportStatus(target, state, String message) {
echo "Reporting Status ${state} to GitHub: ${message}"
if (message && message.length() > 140) {
message = message.take(137) + '...' // GitHub API only allows for 140 characters
}
try {
step([
$class: 'GitHubCommitStatusSetter',
contextSource: [$class: 'ManuallyEnteredCommitContextSource', context: target],
statusResultSource: [$class: 'ConditionalStatusResultSource', results: [[
$class: 'AnyBuildResult', message: message, state: state]]
],
reposSource: [$class: 'ManuallyEnteredRepositorySource', url: 'https://github.com/realm/realm-js']
])
} catch(Exception err) {
echo "Error posting to GitHub: ${err}"
}
}
def doInside(script, target, postStep = null) {
try {
reportStatus(target, 'PENDING', 'Build has started')
retry(3) { // retry unstash up to three times to mitigate network and contention
dir(env.WORKSPACE) {
deleteDir()
unstash 'source'
}
}
wrap([$class: 'AnsiColorBuildWrapper']) {
timeout(time: 1, unit: 'HOURS') {
sh "bash ${script} ${target}"
}
}
if (postStep) {
postStep.call()
}
dir(env.WORKSPACE) {
deleteDir() // solving realm/realm-js#734
}
reportStatus(target, 'SUCCESS', 'Success!')
} catch(Exception e) {
reportStatus(target, 'FAILURE', e.toString())
currentBuild.rawBuild.setResult(Result.FAILURE)
e.printStackTrace()
throw e
}
}
def doDockerInside(script, target, postStep = null) {
docker.withRegistry("https://${env.DOCKER_REGISTRY}", "ecr:eu-west-1:aws-ci-user") {
doInside(script, target, postStep)
}
}
def testAndroid(target, postStep = null) {
return {
node('android') {
timeout(time: 1, unit: 'HOURS') {
doDockerInside('./scripts/docker-android-wrapper.sh ./scripts/test.sh', target, postStep)
}
}
}
}
def testLinux(target, postStep = null, Boolean enableSync = false) {
return {
node('docker') {
def reportName = "Linux ${target}"
deleteDir()
unstash 'source'
def image
withCredentials([[$class: 'StringBinding', credentialsId: 'packagecloud-sync-devel-master-token', variable: 'PACKAGECLOUD_MASTER_TOKEN']]) {
image = buildDockerEnv('ci/realm-js:build')
}
sh "bash ./scripts/utils.sh set-version ${dependencies.VERSION}"
def buildSteps = { String dockerArgs = "" ->
image.inside("-e HOME=/tmp ${dockerArgs}") {
if (enableSync) {
// check the network connection to local mongodb before continuing to compile everything
sh "curl http://mongodb-realm:9090"
}
timeout(time: 1, unit: 'HOURS') {
sh "scripts/test.sh ${target}"
}
if (postStep) {
postStep.call()
}
deleteDir()
reportStatus(reportName, 'SUCCESS', 'Success!')
}
}
try {
reportStatus(reportName, 'PENDING', 'Build has started')
if (enableSync) {
// stitch images are auto-published every day to our CI
// see https://github.com/realm/ci/tree/master/realm/docker/mongodb-realm
// we refrain from using "latest" here to optimise docker pull cost due to a new image being built every day
// if there's really a new feature you need from the latest stitch, upgrade this manually
withRealmCloud(version: objectStoreDependencies.MDBREALM_TEST_SERVER_TAG, appsToImport: ['auth-integration-tests': "${env.WORKSPACE}/src/object-store/tests/mongodb"]) { networkName ->
buildSteps("-e MONGODB_REALM_ENDPOINT=\"http://mongodb-realm\" --network=${networkName}")
}
} else {
buildSteps("")
}
} catch(Exception e) {
reportStatus(reportName, 'FAILURE', e.toString())
throw e
}
}
}
}
def testMacOS(target, postStep = null) {
return {
node('osx_vegas') {
withEnv(['DEVELOPER_DIR=/Applications/Xcode-11.2.app/Contents/Developer',
'REALM_SET_NVM_ALIAS=1',
'REALM_DISABLE_SYNC_TESTS=1']) {
doInside('./scripts/test.sh', target, postStep)
}
}
}
}
def testWindows(nodeVersion) {
return {
node('windows && nodist') {
unstash 'source'
bat "nodist add ${nodeVersion}"
try {
withEnv(["NODE_NODIST_VERSION=${nodeVersion}"]) {
bat 'npm install --build-from-source=realm --realm_enable_sync'
dir('tests') {
bat 'npm install'
bat 'npm run test'
junit 'junitresults-*.xml'
}
}
} finally {
deleteDir()
}
}
}
}