Jenkinsfile.releasability 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. 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']
  2. platforms = ['osx', 'ios', 'watchos', 'tvos']
  3. platformNames = ['osx': 'macOS', 'ios': 'iOS', 'watchos': 'watchOS', 'tvos': 'tvOS']
  4. carthageXcodeVersion = '10.1'
  5. carthageSwiftVersion = '3.4.1'
  6. def installationTest(platform, test, language) {
  7. return {
  8. node('osx') {
  9. deleteDir()
  10. unstash 'source'
  11. if (test == "dynamic" || test == "static") {
  12. unstash "${language}-packaged"
  13. }
  14. sh """
  15. archive=\$(echo \$PWD/realm-${language}-*.zip)
  16. cd examples/installation
  17. if [[ -f \$archive ]]; then
  18. mv \$archive .
  19. unzip realm-${language}-*zip
  20. find . -name 'realm-${language}-*' -print0 | xargs -J% mv % realm-${language}-latest
  21. fi
  22. sed -i '' 's/swift-3.[0-9.]*/swift-${carthageSwiftVersion}/g' osx/swift/DynamicExample/DynamicExample.xcodeproj/project.pbxproj
  23. sed -i '' 's/swift-3.[0-9.]*/swift-${carthageSwiftVersion}/g' ios/swift/DynamicExample/DynamicExample.xcodeproj/project.pbxproj
  24. export REALM_XCODE_VERSION=${carthageXcodeVersion}
  25. ./build.sh test-${platform}-${language}-${test}
  26. """
  27. }
  28. }
  29. }
  30. def buildObjC(platform, outputDirectory=null) {
  31. return {
  32. node('osx') {
  33. deleteDir()
  34. unstash 'source'
  35. sh "XCMODE=xcpretty ./build.sh package-${platform}"
  36. dir(outputDirectory ?: "build/${platform}") {
  37. stash includes: "realm-framework-${platform}.zip", name: "${platform}-objc"
  38. }
  39. }
  40. }
  41. }
  42. def doBuild() {
  43. stage('prepare') {
  44. node('docker') {
  45. deleteDir()
  46. checkout(
  47. [
  48. $class : 'GitSCM',
  49. branches : scm.branches,
  50. gitTool : 'native git',
  51. extensions : scm.extensions + [[$class: 'CleanCheckout'],
  52. [$class: 'SubmoduleOption', parentCredentials: true]],
  53. userRemoteConfigs: scm.userRemoteConfigs,
  54. ]
  55. )
  56. stash includes: '**', name: 'source'
  57. }
  58. }
  59. stage('build') {
  60. def parallelBuilds = [
  61. 'Docs': {
  62. node('osx') {
  63. deleteDir()
  64. unstash 'source'
  65. sh """
  66. export REALM_SWIFT_VERSION=${swiftVersions.last()}
  67. ./scripts/reset-simulators.sh
  68. ./build.sh docs
  69. cd docs
  70. zip -r objc-docs.zip objc_output
  71. zip -r swift-docs.zip swift_output
  72. """
  73. dir('docs') {
  74. archiveArtifacts artifacts: '*-docs.zip'
  75. }
  76. }
  77. },
  78. 'Examples': {
  79. node('osx') {
  80. deleteDir()
  81. unstash 'source'
  82. sh 'XCMODE=xcpretty ./build.sh package-examples'
  83. stash includes: 'realm-examples.zip', name: 'examples'
  84. }
  85. },
  86. 'macOS Obj-C': buildObjC('osx', 'build/DerivedData/Realm/Build/Products/Release'),
  87. 'iOS Obj-C': buildObjC('ios'),
  88. 'watchOS Obj-C': buildObjC('watchos'),
  89. 'tvOS Obj-C': buildObjC('tvos'),
  90. 'iOS Obj-C static': buildObjC('ios-static'),
  91. ]
  92. for (def p in platforms) {
  93. def platform = p
  94. def platformName = platformNames[platform]
  95. parallelBuilds["${platformName} Carthage"] = {
  96. node('osx') {
  97. deleteDir()
  98. unstash 'source'
  99. sh """
  100. export REALM_XCODE_VERSION=${carthageXcodeVersion}
  101. . ./scripts/swift-version.sh
  102. set_xcode_and_swift_versions
  103. carthage build --no-skip-current --platform ${platform}
  104. carthage archive --output Carthage-${platform}.framework.zip
  105. """
  106. stash includes: "Carthage-${platform}.framework.zip",
  107. name: "${platform}-carthage"
  108. }
  109. }
  110. }
  111. for (def p in platforms) {
  112. def platform = p
  113. def platformName = platformNames[platform]
  114. for (def v in swiftVersions) {
  115. def swiftVersion = v
  116. parallelBuilds["${platformName} Swift ${swiftVersion}"] = {
  117. node('osx') {
  118. deleteDir()
  119. unstash 'source'
  120. sh "XCMODE=xcpretty ./build.sh package-${platform}-swift-${swiftVersion}"
  121. dir("build/${platform}") {
  122. stash includes: "realm-swift-framework-${platform}-swift-${swiftVersion}.zip",
  123. name: "${platform}-swift-${swiftVersion}"
  124. }
  125. }
  126. }
  127. }
  128. }
  129. parallel parallelBuilds
  130. }
  131. stage('package') {
  132. parallel (
  133. "Obj-C": {
  134. node('osx') {
  135. deleteDir()
  136. for (def platform in platforms) {
  137. unstash "${platform}-objc"
  138. }
  139. unstash 'ios-static-objc'
  140. unstash 'examples'
  141. unstash 'source'
  142. sh './build.sh package-release objc'
  143. stash include: 'realm-objc-*.zip', name: 'objc-packaged'
  144. archiveArtifacts artifacts: 'realm-objc-*.zip'
  145. }
  146. },
  147. "Swift": {
  148. node('osx') {
  149. deleteDir()
  150. for (def platform in platforms) {
  151. for (def swiftVersion in swiftVersions) {
  152. unstash "${platform}-swift-${swiftVersion}"
  153. }
  154. }
  155. unstash 'examples'
  156. unstash 'source'
  157. sh './build.sh package-release swift'
  158. sh 'rm realm-swift-framework-*.zip'
  159. stash include: 'realm-swift-*.zip', name: 'swift-packaged'
  160. archiveArtifacts artifacts: 'realm-swift-*.zip'
  161. }
  162. },
  163. "Carthage": {
  164. node('osx') {
  165. deleteDir()
  166. for (def platform in platforms) {
  167. unstash "${platform}-carthage"
  168. }
  169. sh '''
  170. for zip in Carthage-*.framework.zip; do
  171. ditto -xk $zip merged/
  172. done
  173. ditto -ck merged/ Carthage.framework.zip
  174. '''
  175. archiveArtifacts artifacts: 'Carthage.framework.zip'
  176. }
  177. }
  178. )
  179. }
  180. stage('test') {
  181. def parallelBuilds = [
  182. 'Test Examples': {
  183. node('osx') {
  184. deleteDir()
  185. // FIXME: Split Obj-C and Swift.
  186. unstash 'objc-packaged'
  187. unstash 'swift-packaged'
  188. def sha = params.sha
  189. sh """
  190. curl -O https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/build.sh
  191. mkdir -p scripts
  192. curl https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/scripts/swift-version.sh -o scripts/swift-version.sh
  193. curl https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/scripts/reset-simulators.sh -o scripts/reset-simulators.sh
  194. curl https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/scripts/reset-simulators.rb -o scripts/reset-simulators.rb
  195. chmod +x scripts/reset-simulators.rb
  196. XCMODE=xcpretty sh build.sh package-test-examples
  197. """
  198. }
  199. },
  200. 'Test iOS static': {
  201. node('osx') {
  202. deleteDir()
  203. unstash 'source'
  204. sh 'XCMODE=xcpretty IS_RUNNING_PACKAGING=1 sh build.sh test-ios-static'
  205. }
  206. },
  207. 'Test macOS': {
  208. node('osx') {
  209. deleteDir()
  210. unstash 'source'
  211. sh 'XCMODE=xcpretty sh build.sh test-osx'
  212. }
  213. }
  214. ]
  215. for (def platform in ["osx", "ios"]) {
  216. def platformName = platformNames[platform]
  217. for (def test in ["dynamic", "cocoapods", "carthage"]) {
  218. parallelBuilds["Installation - ${platformName} Obj-C ${test}"] = installationTest(platform, test, 'objc')
  219. }
  220. }
  221. parallelBuilds["Installation - iOS Obj-C static"] = installationTest('ios', 'static', 'objc')
  222. parallelBuilds["Installation - iOS Obj-C CocoaPods dynamic"] = installationTest('ios', 'cocoapods-dynamic', 'objc')
  223. for (def platform in ["osx", "ios"]) {
  224. def platformName = platformNames[platform]
  225. for (def test in ["cocoapods", "carthage"]) {
  226. parallelBuilds["Installation - ${platformName} Swift ${test}"] = installationTest(platform, test, 'swift')
  227. }
  228. }
  229. parallel parallelBuilds
  230. }
  231. }
  232. try {
  233. doBuild()
  234. } catch (e) {
  235. // If there was an exception thrown, the build failed
  236. currentBuild.result = "FAILED"
  237. throw e
  238. }