Jenkinsfile.releasability 8.6 KB

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