Jenkinsfile.releasability 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. xcodeVersions = ['10.3', '11.1', '11.2.1', '11.3', '11.4.1', '11.5']
  2. platforms = ['osx', 'ios', 'watchos', 'tvos', 'catalyst']
  3. carthagePlatforms = ['osx', 'ios', 'watchos', 'tvos']
  4. platformNames = ['osx': 'macOS', 'ios': 'iOS', 'watchos': 'watchOS', 'tvos': 'tvOS', 'catalyst': 'Catalyst']
  5. carthageXcodeVersion = '11.5'
  6. objcXcodeVersion = '10.3'
  7. docsSwiftVersion = '5.2.4'
  8. def installationTest(platform, test, language) {
  9. return {
  10. node('osx') {
  11. deleteDir()
  12. unstash 'source'
  13. if (test == "dynamic" || test == "static") {
  14. unstash "${language}-packaged"
  15. }
  16. sh """
  17. hostname
  18. export REALM_XCODE_VERSION=${carthageXcodeVersion}
  19. cd examples/installation
  20. archive=\$(echo \$PWD/realm-${language}-*.zip)
  21. if [[ -f \$archive ]]; then
  22. mv \$archive .
  23. unzip realm-${language}-*.zip
  24. rm realm-${language}-*.zip
  25. mv realm-${language}-* realm-${language}-latest
  26. fi
  27. ./build.sh test-${platform}-${language}-${test}
  28. """
  29. }
  30. }
  31. }
  32. def doBuild() {
  33. stage('prepare') {
  34. node('docker') {
  35. deleteDir()
  36. checkout(
  37. [
  38. $class : 'GitSCM',
  39. branches : scm.branches,
  40. gitTool : 'native git',
  41. extensions : scm.extensions + [[$class: 'CleanCheckout'],
  42. [$class: 'SubmoduleOption', parentCredentials: true]],
  43. userRemoteConfigs: scm.userRemoteConfigs,
  44. ]
  45. )
  46. stash includes: '**', name: 'source'
  47. }
  48. }
  49. stage('build') {
  50. def parallelBuilds = [
  51. 'Docs': {
  52. node('osx') {
  53. deleteDir()
  54. unstash 'source'
  55. sh """
  56. hostname
  57. export REALM_SWIFT_VERSION=${docsSwiftVersion}
  58. export PATH='/Users/realm/.rbenv/bin:/Users/realm/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/realm/.gems/bin'
  59. ./scripts/reset-simulators.sh
  60. ./build.sh docs
  61. cd docs
  62. zip -r objc-docs.zip objc_output
  63. zip -r swift-docs.zip swift_output
  64. """
  65. dir('docs') {
  66. archiveArtifacts artifacts: '*-docs.zip'
  67. }
  68. }
  69. },
  70. 'Examples': {
  71. node('osx') {
  72. deleteDir()
  73. unstash 'source'
  74. sh './build.sh package-examples'
  75. stash includes: 'realm-examples.zip', name: 'examples'
  76. }
  77. },
  78. 'iOS Obj-C static': {
  79. node('osx') {
  80. deleteDir()
  81. unstash 'source'
  82. sh "REALM_XCODE_VERSION=${objcXcodeVersion} ./build.sh package-ios-static"
  83. dir("build/ios-static") {
  84. stash includes: "realm-framework-ios-static.zip", name: "ios-static"
  85. }
  86. }
  87. }
  88. ]
  89. for (def p in carthagePlatforms) {
  90. def platform = p
  91. def platformName = platformNames[platform]
  92. parallelBuilds["${platformName} Carthage"] = {
  93. node('osx') {
  94. deleteDir()
  95. unstash 'source'
  96. sh """
  97. hostname
  98. export REALM_XCODE_VERSION=${carthageXcodeVersion}
  99. . ./scripts/swift-version.sh
  100. set_xcode_and_swift_versions
  101. # Carthage scans every xcodeproj in the directory looking for
  102. # targets. This can be very slow and even spuriously time out, so
  103. # remove the ones we don't want it to build.
  104. rm -r examples plugin
  105. # For whatever reason 'xcodebuild -list' is very slow sometimes which
  106. # makes Carthage time out, but it's a lot faster if no simulators
  107. # exist, so delete them all first and only create a single simulator
  108. # for each platform.
  109. ./scripts/reset-simulators.rb -firstOnly
  110. carthage build --no-skip-current --platform ${platform}
  111. carthage archive --output Carthage-${platform}.framework.zip
  112. """
  113. stash includes: "Carthage-${platform}.framework.zip",
  114. name: "${platform}-carthage"
  115. }
  116. }
  117. }
  118. for (def p in platforms) {
  119. def platform = p
  120. def platformName = platformNames[platform]
  121. for (def v in xcodeVersions) {
  122. def xcodeVersion = v
  123. parallelBuilds["${platformName} ${xcodeVersion}"] = {
  124. node('osx') {
  125. deleteDir()
  126. unstash 'source'
  127. sh "REALM_XCODE_VERSION=${xcodeVersion} ./build.sh package ${platform}"
  128. dir("build/${platform}") {
  129. stash includes: "realm-framework-${platform}-${xcodeVersion}.zip",
  130. name: "${platform}-${xcodeVersion}"
  131. }
  132. }
  133. }
  134. }
  135. }
  136. parallel parallelBuilds
  137. }
  138. stage('package') {
  139. parallel (
  140. "Obj-C": {
  141. node('osx') {
  142. deleteDir()
  143. for (def platform in platforms) {
  144. unstash "${platform}-${objcXcodeVersion}"
  145. }
  146. // The 10.x builds don't actually have a framework for catalyst, so
  147. // use the 11.0 version instead
  148. unstash 'catalyst-11.1'
  149. sh "mv realm-framework-catalyst-11.1.zip realm-framework-catalyst-${objcXcodeVersion}.zip"
  150. unstash 'ios-static'
  151. unstash 'examples'
  152. unstash 'source'
  153. sh "REALM_XCODE_VERSION=${objcXcodeVersion} ./build.sh package-release objc"
  154. stash include: 'realm-objc-*.zip', name: 'objc-packaged'
  155. archiveArtifacts artifacts: 'realm-objc-*.zip'
  156. }
  157. },
  158. "Swift": {
  159. node('osx') {
  160. deleteDir()
  161. for (def platform in platforms) {
  162. for (def xcodeVersion in xcodeVersions) {
  163. unstash "${platform}-${xcodeVersion}"
  164. }
  165. }
  166. unstash 'examples'
  167. unstash 'source'
  168. sh './build.sh package-release swift'
  169. stash include: 'realm-swift-*.zip', name: 'swift-packaged'
  170. archiveArtifacts artifacts: 'realm-swift-*.zip'
  171. }
  172. },
  173. "Carthage": {
  174. node('osx') {
  175. deleteDir()
  176. for (def platform in carthagePlatforms) {
  177. unstash "${platform}-carthage"
  178. }
  179. sh '''
  180. for zip in Carthage-*.framework.zip; do
  181. ditto -xk $zip merged/
  182. done
  183. ditto -ck merged/ Carthage.framework.zip
  184. '''
  185. archiveArtifacts artifacts: 'Carthage.framework.zip'
  186. }
  187. }
  188. )
  189. }
  190. stage('test') {
  191. def parallelBuilds = [
  192. 'Test Obj-C Examples': {
  193. node('osx') {
  194. deleteDir()
  195. unstash 'objc-packaged'
  196. def sha = params.sha
  197. sh """
  198. hostname
  199. curl -O https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/build.sh
  200. mkdir -p scripts
  201. curl https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/scripts/swift-version.sh -o scripts/swift-version.sh
  202. curl https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/scripts/reset-simulators.sh -o scripts/reset-simulators.sh
  203. curl https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/scripts/reset-simulators.rb -o scripts/reset-simulators.rb
  204. chmod +x scripts/reset-simulators.rb
  205. sh build.sh package-test-examples-objc
  206. """
  207. }
  208. },
  209. 'Test Swift Examples': {
  210. node('osx') {
  211. deleteDir()
  212. unstash 'swift-packaged'
  213. def sha = params.sha
  214. sh """
  215. hostname
  216. curl -O https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/build.sh
  217. mkdir -p scripts
  218. curl https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/scripts/swift-version.sh -o scripts/swift-version.sh
  219. curl https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/scripts/reset-simulators.sh -o scripts/reset-simulators.sh
  220. curl https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/scripts/reset-simulators.rb -o scripts/reset-simulators.rb
  221. chmod +x scripts/reset-simulators.rb
  222. sh build.sh package-test-examples-swift
  223. """
  224. }
  225. },
  226. 'Test iOS static': {
  227. node('osx') {
  228. deleteDir()
  229. unstash 'source'
  230. sh './scripts/reset-simulators.rb'
  231. sh 'sh build.sh test-ios-static'
  232. }
  233. },
  234. 'Test macOS': {
  235. node('osx') {
  236. deleteDir()
  237. unstash 'source'
  238. sh 'sh build.sh test-osx'
  239. }
  240. }
  241. ]
  242. for (def platform in ["osx", "ios", "watchos"]) {
  243. def platformName = platformNames[platform]
  244. for (def test in ["dynamic", "cocoapods", "carthage"]) {
  245. parallelBuilds["Installation - ${platformName} Obj-C ${test}"] = installationTest(platform, test, 'objc')
  246. }
  247. }
  248. parallelBuilds["Installation - iOS Obj-C static"] = installationTest('ios', 'static', 'objc')
  249. parallelBuilds["Installation - iOS Obj-C CocoaPods dynamic"] = installationTest('ios', 'cocoapods-dynamic', 'objc')
  250. for (def platform in ["osx", "ios", "watchos"]) {
  251. def platformName = platformNames[platform]
  252. for (def test in ["dynamic", "cocoapods", "carthage"]) {
  253. parallelBuilds["Installation - ${platformName} Swift ${test}"] = installationTest(platform, test, 'swift')
  254. }
  255. }
  256. parallel parallelBuilds
  257. }
  258. }
  259. try {
  260. doBuild()
  261. } catch (e) {
  262. // If there was an exception thrown, the build failed
  263. currentBuild.result = "FAILED"
  264. throw e
  265. }