Jenkinsfile.releasability 7.6 KB

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