123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- swiftVersions = ['3.2.3', '3.3', '3.3.2', '3.4', '3.4.1', '4.0.3', '4.1', '4.1.2', '4.2', '4.2.1']
- platforms = ['osx', 'ios', 'watchos', 'tvos']
- platformNames = ['osx': 'macOS', 'ios': 'iOS', 'watchos': 'watchOS', 'tvos': 'tvOS']
- carthageXcodeVersion = '10.1'
- carthageSwiftVersion = '3.4.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
- find . -name 'realm-${language}-*' -print0 | xargs -J% mv % realm-${language}-latest
- fi
- sed -i '' 's/swift-3.[0-9.]*/swift-${carthageSwiftVersion}/g' osx/swift/DynamicExample/DynamicExample.xcodeproj/project.pbxproj
- sed -i '' 's/swift-3.[0-9.]*/swift-${carthageSwiftVersion}/g' ios/swift/DynamicExample/DynamicExample.xcodeproj/project.pbxproj
- export REALM_XCODE_VERSION=${carthageXcodeVersion}
- ./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
- }
|