Jenkinsfile.releasability 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. xcodeVersions = ['11.3', '11.4.1', '11.5', '11.6']
  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 = '11.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. unstash 'ios-static'
  147. unstash 'examples'
  148. unstash 'source'
  149. sh "REALM_XCODE_VERSION=${objcXcodeVersion} ./build.sh package-release objc"
  150. stash include: 'realm-objc-*.zip', name: 'objc-packaged'
  151. archiveArtifacts artifacts: 'realm-objc-*.zip'
  152. }
  153. },
  154. "Swift": {
  155. node('osx') {
  156. deleteDir()
  157. for (def platform in platforms) {
  158. for (def xcodeVersion in xcodeVersions) {
  159. unstash "${platform}-${xcodeVersion}"
  160. }
  161. }
  162. unstash 'examples'
  163. unstash 'source'
  164. sh './build.sh package-release swift'
  165. stash include: 'realm-swift-*.zip', name: 'swift-packaged'
  166. archiveArtifacts artifacts: 'realm-swift-*.zip'
  167. }
  168. },
  169. "Carthage": {
  170. node('osx') {
  171. deleteDir()
  172. for (def platform in carthagePlatforms) {
  173. unstash "${platform}-carthage"
  174. }
  175. sh '''
  176. for zip in Carthage-*.framework.zip; do
  177. ditto -xk $zip merged/
  178. done
  179. ditto -ck merged/ Carthage.framework.zip
  180. '''
  181. archiveArtifacts artifacts: 'Carthage.framework.zip'
  182. }
  183. }
  184. )
  185. }
  186. stage('test') {
  187. def parallelBuilds = [
  188. 'Test Obj-C Examples': {
  189. node('osx') {
  190. deleteDir()
  191. unstash 'objc-packaged'
  192. def sha = params.sha
  193. sh """
  194. hostname
  195. curl -O https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/build.sh
  196. mkdir -p scripts
  197. curl https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/scripts/swift-version.sh -o scripts/swift-version.sh
  198. curl https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/scripts/reset-simulators.sh -o scripts/reset-simulators.sh
  199. curl https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/scripts/reset-simulators.rb -o scripts/reset-simulators.rb
  200. chmod +x scripts/reset-simulators.rb
  201. sh build.sh package-test-examples-objc
  202. """
  203. }
  204. },
  205. 'Test Swift Examples': {
  206. node('osx') {
  207. deleteDir()
  208. unstash 'swift-packaged'
  209. def sha = params.sha
  210. sh """
  211. hostname
  212. curl -O https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/build.sh
  213. mkdir -p scripts
  214. curl https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/scripts/swift-version.sh -o scripts/swift-version.sh
  215. curl https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/scripts/reset-simulators.sh -o scripts/reset-simulators.sh
  216. curl https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/scripts/reset-simulators.rb -o scripts/reset-simulators.rb
  217. chmod +x scripts/reset-simulators.rb
  218. sh build.sh package-test-examples-swift
  219. """
  220. }
  221. },
  222. 'Test iOS static': {
  223. node('osx') {
  224. deleteDir()
  225. unstash 'source'
  226. sh './scripts/reset-simulators.rb'
  227. sh 'sh build.sh test-ios-static'
  228. }
  229. },
  230. 'Test macOS': {
  231. node('osx') {
  232. deleteDir()
  233. unstash 'source'
  234. sh 'sh build.sh test-osx'
  235. }
  236. }
  237. ]
  238. for (def platform in ["osx", "ios", "watchos"]) {
  239. def platformName = platformNames[platform]
  240. for (def test in ["dynamic", "cocoapods", "carthage"]) {
  241. parallelBuilds["Installation - ${platformName} Obj-C ${test}"] = installationTest(platform, test, 'objc')
  242. }
  243. }
  244. parallelBuilds["Installation - iOS Obj-C static"] = installationTest('ios', 'static', 'objc')
  245. parallelBuilds["Installation - iOS Obj-C CocoaPods dynamic"] = installationTest('ios', 'cocoapods-dynamic', 'objc')
  246. for (def platform in ["osx", "ios", "watchos"]) {
  247. def platformName = platformNames[platform]
  248. for (def test in ["dynamic", "cocoapods", "carthage"]) {
  249. parallelBuilds["Installation - ${platformName} Swift ${test}"] = installationTest(platform, test, 'swift')
  250. }
  251. }
  252. parallel parallelBuilds
  253. }
  254. }
  255. try {
  256. doBuild()
  257. } catch (e) {
  258. // If there was an exception thrown, the build failed
  259. currentBuild.result = "FAILED"
  260. throw e
  261. }