Jenkinsfile 12 KB

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