Jenkinsfile 12 KB

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