Jenkinsfile.releasability 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. xcodeVersions = ['10.0', '10.1', '10.2.1', '10.3', '11.1', '11.2']
  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.2'
  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. 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. ./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 'XCMODE=xcpretty ./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 "XCMODE=xcpretty 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. export REALM_XCODE_VERSION=${carthageXcodeVersion}
  98. . ./scripts/swift-version.sh
  99. set_xcode_and_swift_versions
  100. if [ "${platform}" != osx ]; then
  101. ./scripts/reset-simulators.rb
  102. fi
  103. carthage build --no-skip-current --platform ${platform}
  104. carthage archive --output Carthage-${platform}.framework.zip
  105. """
  106. stash includes: "Carthage-${platform}.framework.zip",
  107. name: "${platform}-carthage"
  108. }
  109. }
  110. }
  111. for (def p in platforms) {
  112. def platform = p
  113. def platformName = platformNames[platform]
  114. for (def v in xcodeVersions) {
  115. def xcodeVersion = v
  116. parallelBuilds["${platformName} ${xcodeVersion}"] = {
  117. node('osx') {
  118. deleteDir()
  119. unstash 'source'
  120. sh "XCMODE=xcpretty REALM_XCODE_VERSION=${xcodeVersion} ./build.sh package ${platform}"
  121. dir("build/${platform}") {
  122. stash includes: "realm-framework-${platform}-${xcodeVersion}.zip",
  123. name: "${platform}-${xcodeVersion}"
  124. }
  125. }
  126. }
  127. }
  128. }
  129. parallel parallelBuilds
  130. }
  131. stage('package') {
  132. parallel (
  133. "Obj-C": {
  134. node('osx') {
  135. deleteDir()
  136. for (def platform in platforms) {
  137. unstash "${platform}-${objcXcodeVersion}"
  138. }
  139. // The 10.x builds don't actually have a framework for catalyst, so
  140. // use the 11.0 version instead
  141. unstash 'catalyst-11.1'
  142. sh "mv realm-framework-catalyst-11.1.zip realm-framework-catalyst-${objcXcodeVersion}.zip"
  143. unstash 'ios-static'
  144. unstash 'examples'
  145. unstash 'source'
  146. sh "REALM_XCODE_VERSION=${objcXcodeVersion} ./build.sh package-release objc"
  147. stash include: 'realm-objc-*.zip', name: 'objc-packaged'
  148. archiveArtifacts artifacts: 'realm-objc-*.zip'
  149. }
  150. },
  151. "Swift": {
  152. node('osx') {
  153. deleteDir()
  154. for (def platform in platforms) {
  155. for (def xcodeVersion in xcodeVersions) {
  156. unstash "${platform}-${xcodeVersion}"
  157. }
  158. }
  159. unstash 'examples'
  160. unstash 'source'
  161. sh './build.sh package-release swift'
  162. stash include: 'realm-swift-*.zip', name: 'swift-packaged'
  163. archiveArtifacts artifacts: 'realm-swift-*.zip'
  164. }
  165. },
  166. "Carthage": {
  167. node('osx') {
  168. deleteDir()
  169. for (def platform in carthagePlatforms) {
  170. unstash "${platform}-carthage"
  171. }
  172. sh '''
  173. for zip in Carthage-*.framework.zip; do
  174. ditto -xk $zip merged/
  175. done
  176. ditto -ck merged/ Carthage.framework.zip
  177. '''
  178. archiveArtifacts artifacts: 'Carthage.framework.zip'
  179. }
  180. }
  181. )
  182. }
  183. stage('test') {
  184. def parallelBuilds = [
  185. 'Test Obj-C Examples': {
  186. node('osx') {
  187. deleteDir()
  188. unstash 'objc-packaged'
  189. def sha = params.sha
  190. sh """
  191. curl -O https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/build.sh
  192. mkdir -p scripts
  193. curl https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/scripts/swift-version.sh -o scripts/swift-version.sh
  194. curl https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/scripts/reset-simulators.sh -o scripts/reset-simulators.sh
  195. curl https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/scripts/reset-simulators.rb -o scripts/reset-simulators.rb
  196. chmod +x scripts/reset-simulators.rb
  197. XCMODE=xcpretty sh build.sh package-test-examples-objc
  198. """
  199. }
  200. },
  201. 'Test Swift Examples': {
  202. node('osx') {
  203. deleteDir()
  204. unstash 'swift-packaged'
  205. def sha = params.sha
  206. sh """
  207. curl -O https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/build.sh
  208. mkdir -p scripts
  209. curl https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/scripts/swift-version.sh -o scripts/swift-version.sh
  210. curl https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/scripts/reset-simulators.sh -o scripts/reset-simulators.sh
  211. curl https://raw.githubusercontent.com/realm/realm-cocoa/${sha}/scripts/reset-simulators.rb -o scripts/reset-simulators.rb
  212. chmod +x scripts/reset-simulators.rb
  213. XCMODE=xcpretty sh build.sh package-test-examples-swift
  214. """
  215. }
  216. },
  217. 'Test iOS static': {
  218. node('osx') {
  219. deleteDir()
  220. unstash 'source'
  221. sh './scripts/reset-simulators.rb'
  222. sh 'XCMODE=xcpretty sh build.sh test-ios-static'
  223. }
  224. },
  225. 'Test macOS': {
  226. node('osx') {
  227. deleteDir()
  228. unstash 'source'
  229. sh 'XCMODE=xcpretty sh build.sh test-osx'
  230. }
  231. }
  232. ]
  233. for (def platform in ["osx", "ios", "watchos"]) {
  234. def platformName = platformNames[platform]
  235. for (def test in ["dynamic", "cocoapods", "carthage"]) {
  236. parallelBuilds["Installation - ${platformName} Obj-C ${test}"] = installationTest(platform, test, 'objc')
  237. }
  238. }
  239. parallelBuilds["Installation - iOS Obj-C static"] = installationTest('ios', 'static', 'objc')
  240. parallelBuilds["Installation - iOS Obj-C CocoaPods dynamic"] = installationTest('ios', 'cocoapods-dynamic', 'objc')
  241. for (def platform in ["osx", "ios", "watchos"]) {
  242. def platformName = platformNames[platform]
  243. for (def test in ["cocoapods", "carthage"]) {
  244. parallelBuilds["Installation - ${platformName} Swift ${test}"] = installationTest(platform, test, 'swift')
  245. }
  246. }
  247. parallel parallelBuilds
  248. }
  249. }
  250. try {
  251. doBuild()
  252. } catch (e) {
  253. // If there was an exception thrown, the build failed
  254. currentBuild.result = "FAILED"
  255. throw e
  256. }