Jenkinsfile 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. def action_test_frontend_ct_build = false
  2. def action_build_deps = false
  3. def action_copy_external_pages = false
  4. def action_build_dev = false
  5. def action_test_acceptance_app_server_pro = false
  6. def action_build_webpack = false
  7. def action_test_acceptance_app_saas = false
  8. def action_build_pug = false
  9. def action_build_production= false
  10. pipeline {
  11. agent {
  12. node {
  13. label 'jenkins-agent-web'
  14. customWorkspace '/workspace'
  15. }
  16. }
  17. options {
  18. timestamps()
  19. parallelsAlwaysFailFast()
  20. timeout(time: 15, unit: 'MINUTES')
  21. }
  22. environment {
  23. IMAGE_NAME = 'web'
  24. PROJECT_NAME = 'web'
  25. IMAGE_REPO = 'us-east1-docker.pkg.dev/overleaf-ops/ol-docker/web'
  26. AR_REPO_LOCATION = 'us-east1'
  27. AR_URL = 'us-east1-docker.pkg.dev/overleaf-ops/ol-docker'
  28. DOCKER_COMPOSE_FLAGS = '-f docker-compose.ci.yml'
  29. BRANCH_NAME = "${GIT_BRANCH.replace('origin/', '')}"
  30. COMMIT_SHA = "${GIT_COMMIT}"
  31. SHORT_SHA = "${GIT_COMMIT.take(7)}"
  32. CDN_STAG = "gs://ol-stag-web-assets-1"
  33. CDN_PROD = "gs://mgcp-1117973-ol-prod-web-assets-1"
  34. }
  35. stages {
  36. stage ('Build, Test and Push') {
  37. parallel {
  38. stage('Copy external pages') {
  39. steps {
  40. dir('services/web') {
  41. sh 'bin/copy_external_pages'
  42. script {
  43. action_copy_external_pages = true
  44. }
  45. }
  46. }
  47. }
  48. stage('Prefetch Tests Images') {
  49. steps {
  50. dir('services/web') {
  51. sh 'docker compose -f docker-compose.ci.yml pull --quiet test_frontend_ct mongo redis ldap saml'
  52. }
  53. }
  54. }
  55. stage('Build Deps') {
  56. steps {
  57. dir('services/web') {
  58. sh 'make build_deps'
  59. }
  60. script {
  61. action_build_deps = true
  62. }
  63. }
  64. }
  65. stage('Push Deps') {
  66. steps {
  67. script {
  68. waitUntil {
  69. return action_build_deps
  70. }
  71. }
  72. dir('services/web') {
  73. sh 'docker push ${AR_URL}/${IMAGE_NAME}:${BRANCH_NAME}-deps'
  74. }
  75. }
  76. }
  77. stage('Build Dev') {
  78. steps {
  79. script {
  80. waitUntil {
  81. return action_build_deps && action_copy_external_pages
  82. }
  83. }
  84. dir('services/web') {
  85. sh 'make build_dev'
  86. }
  87. script {
  88. action_build_dev = true
  89. }
  90. }
  91. }
  92. stage ('Format') {
  93. steps {
  94. script {
  95. waitUntil {
  96. return action_build_dev
  97. }
  98. }
  99. dir('services/web') {
  100. sh 'make format_in_docker'
  101. }
  102. }
  103. }
  104. stage('Lint') {
  105. steps {
  106. script {
  107. waitUntil {
  108. return action_build_dev
  109. }
  110. }
  111. dir('services/web') {
  112. sh 'make lint_in_docker'
  113. }
  114. }
  115. }
  116. stage('Shellcheck') {
  117. steps {
  118. dir('services/web') {
  119. sh 'make shellcheck'
  120. }
  121. }
  122. }
  123. stage('Acceptance SaaS') {
  124. steps {
  125. script {
  126. waitUntil {
  127. return action_build_dev
  128. }
  129. }
  130. dir('services/web') {
  131. sh 'make test_acceptance_app_saas'
  132. }
  133. script {
  134. action_test_acceptance_app_saas = true
  135. }
  136. }
  137. }
  138. stage('Acceptance Server CE') {
  139. steps {
  140. script {
  141. waitUntil {
  142. return action_build_dev
  143. }
  144. }
  145. dir('services/web') {
  146. sh "make test_acceptance_app_server_ce"
  147. }
  148. }
  149. }
  150. stage('Acceptance Server Pro') {
  151. steps {
  152. script {
  153. waitUntil {
  154. return action_build_dev
  155. }
  156. }
  157. dir('services/web') {
  158. sh "make test_acceptance_app_server_pro"
  159. }
  160. script {
  161. action_test_acceptance_app_server_pro = true
  162. }
  163. }
  164. }
  165. stage('test_acceptance_modules_merged_saas_1') {
  166. steps {
  167. script {
  168. waitUntil {
  169. return action_build_dev
  170. }
  171. }
  172. dir('services/web') {
  173. sh "make test_acceptance_modules_merged_saas_1"
  174. }
  175. }
  176. }
  177. stage('test_acceptance_modules_merged_saas_2') {
  178. steps {
  179. script {
  180. waitUntil {
  181. return action_build_dev
  182. }
  183. }
  184. dir('services/web') {
  185. sh "make test_acceptance_modules_merged_saas_2"
  186. }
  187. }
  188. }
  189. stage('test_acceptance_modules_merged_saas_3') {
  190. steps {
  191. script {
  192. waitUntil {
  193. return action_build_dev
  194. }
  195. }
  196. dir('services/web') {
  197. sh "make test_acceptance_modules_merged_saas_3"
  198. }
  199. }
  200. }
  201. stage('test_acceptance_modules_merged_saas_4') {
  202. steps {
  203. script {
  204. waitUntil {
  205. return action_build_dev
  206. }
  207. }
  208. dir('services/web') {
  209. sh "make test_acceptance_modules_merged_saas_4"
  210. }
  211. }
  212. }
  213. stage('test_acceptance_modules_merged_server_ce') {
  214. steps {
  215. script {
  216. waitUntil {
  217. return action_build_dev
  218. }
  219. }
  220. dir('services/web') {
  221. sh "make test_acceptance_modules_merged_server_ce"
  222. }
  223. }
  224. }
  225. stage('test_acceptance_modules_merged_server_pro') {
  226. steps {
  227. script {
  228. waitUntil {
  229. return action_build_dev
  230. }
  231. }
  232. dir('services/web') {
  233. sh "make test_acceptance_modules_merged_server_pro"
  234. }
  235. }
  236. }
  237. stage('test_frontend') {
  238. steps {
  239. script {
  240. waitUntil {
  241. return action_build_dev
  242. }
  243. }
  244. dir('services/web') {
  245. sh "make test_frontend"
  246. }
  247. }
  248. }
  249. stage('test_frontend_ct_build') {
  250. steps {
  251. script {
  252. waitUntil {
  253. return action_build_dev
  254. }
  255. }
  256. dir('services/web') {
  257. sh "make build_test_frontend_ct"
  258. }
  259. script {
  260. action_test_frontend_ct_build = true
  261. }
  262. }
  263. }
  264. stage('test_frontend_ct_core_other') {
  265. environment {
  266. CYPRESS_INTERNAL_BROWSER_CONNECT_TIMEOUT = '120000'
  267. }
  268. steps {
  269. script {
  270. waitUntil {
  271. return action_test_frontend_ct_build
  272. }
  273. }
  274. dir('services/web') {
  275. sh "make test_frontend_ct_core_other"
  276. }
  277. }
  278. }
  279. stage('test_frontend_ct_core_features') {
  280. environment {
  281. CYPRESS_INTERNAL_BROWSER_CONNECT_TIMEOUT = '120000'
  282. }
  283. steps {
  284. script {
  285. waitUntil {
  286. return action_test_frontend_ct_build
  287. }
  288. }
  289. dir('services/web') {
  290. sh "make test_frontend_ct_core_features"
  291. }
  292. }
  293. }
  294. stage('test_frontend_ct_modules') {
  295. environment {
  296. CYPRESS_INTERNAL_BROWSER_CONNECT_TIMEOUT = '120000'
  297. }
  298. steps {
  299. script {
  300. waitUntil {
  301. return action_test_frontend_ct_build
  302. }
  303. }
  304. dir('services/web') {
  305. sh "make test_frontend_ct_modules"
  306. }
  307. }
  308. }
  309. stage('test_frontend_ct_editor_visual') {
  310. steps {
  311. script {
  312. waitUntil {
  313. return action_test_frontend_ct_build
  314. }
  315. }
  316. dir('services/web') {
  317. sh "make test_frontend_ct_editor_visual"
  318. }
  319. }
  320. }
  321. stage('test_frontend_ct_editor_other') {
  322. steps {
  323. script {
  324. waitUntil {
  325. return action_test_frontend_ct_build
  326. }
  327. }
  328. dir('services/web') {
  329. sh "make test_frontend_ct_editor_other"
  330. }
  331. }
  332. }
  333. stage('Test Unit ESM') {
  334. steps {
  335. script {
  336. waitUntil {
  337. return action_build_dev
  338. }
  339. }
  340. dir('services/web') {
  341. sh "make test_unit_esm"
  342. }
  343. }
  344. }
  345. stage('Test Unit Mocha') {
  346. steps {
  347. script {
  348. waitUntil {
  349. return action_build_dev
  350. }
  351. }
  352. dir('services/web') {
  353. sh "make test_unit_mocha"
  354. }
  355. }
  356. }
  357. stage('Build Webpack'){
  358. steps {
  359. script {
  360. waitUntil {
  361. return action_build_dev && action_test_acceptance_app_server_pro
  362. }
  363. }
  364. dir('services/web') {
  365. sh 'make build_webpack'
  366. }
  367. script {
  368. action_build_webpack = true
  369. }
  370. }
  371. }
  372. stage('Build Pug') {
  373. steps {
  374. script {
  375. waitUntil {
  376. return action_build_dev && action_test_acceptance_app_server_pro
  377. }
  378. }
  379. dir('services/web') {
  380. sh 'make build_pug'
  381. }
  382. script {
  383. action_build_pug = true
  384. }
  385. }
  386. }
  387. stage('CDN Upload Image') {
  388. steps {
  389. script {
  390. waitUntil {
  391. return action_build_webpack
  392. }
  393. }
  394. dir('services/web') {
  395. sh 'make tar'
  396. sh 'bin/cdn_upload'
  397. }
  398. }
  399. }
  400. stage('Build Production'){
  401. steps {
  402. script {
  403. waitUntil {
  404. return action_build_webpack && action_build_pug
  405. }
  406. }
  407. dir('services/web') {
  408. sh 'make build'
  409. }
  410. script {
  411. action_build_production = true
  412. }
  413. }
  414. }
  415. stage('Sentry Upload') {
  416. steps {
  417. script {
  418. waitUntil {
  419. return action_build_webpack && action_build_production
  420. }
  421. }
  422. dir('services/web') {
  423. sh 'gcloud secrets versions access latest --secret=web-sentryclirc > .sentryclirc'
  424. sh 'make sentry_upload'
  425. }
  426. }
  427. post {
  428. cleanup {
  429. dir('services/web') {
  430. sh 'rm -f .sentryclirc'
  431. }
  432. }
  433. }
  434. }
  435. }
  436. }
  437. stage('Push Production') {
  438. steps {
  439. dir('services/web') {
  440. sh 'make publish'
  441. }
  442. }
  443. }
  444. }
  445. post {
  446. cleanup {
  447. dir('services/web') {
  448. sh 'make clean'
  449. }
  450. sh 'make clean_jenkins'
  451. }
  452. }
  453. }
  454. // vim: set ft=groovy :