xcodeVersions = ['10.0', '10.1', '10.3', '11.1', '11.2.1', '11.3'] platforms = ['osx', 'ios', 'watchos', 'tvos', 'catalyst'] carthagePlatforms = ['osx', 'ios', 'watchos', 'tvos'] platformNames = ['osx': 'macOS', 'ios': 'iOS', 'watchos': 'watchOS', 'tvos': 'tvOS', 'catalyst': 'Catalyst'] carthageXcodeVersion = '11.3' objcXcodeVersion = '10.1' docsSwiftVersion = '5.1.2' def installationTest(platform, test, language) { return { node('osx') { deleteDir() unstash 'source' if (test == "dynamic" || test == "static") { unstash "${language}-packaged" } sh """ export REALM_XCODE_VERSION=${carthageXcodeVersion} if [ "${platform}" != osx ]; then ./scripts/reset-simulators.sh fi cd examples/installation archive=\$(echo \$PWD/realm-${language}-*.zip) 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 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} 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 '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 }