Jenkinsfile.releasability 8.9 KB

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