[monorepo] migrate build scripts to Jenkins (#29019)

* [monorepo] migrate build scripts to Jenkins

* [fraud-dash] fix integration with monorepo

GitOrigin-RevId: 6a30ec5ea68a1eae9b663faf9ccdc741ec7f9cf8
This commit is contained in:
Jakob Ackermann
2025-10-13 08:07:11 +00:00
committed by Copybot
parent 9813bc4b51
commit fd0d21fbbd
142 changed files with 3298 additions and 219 deletions
-3
View File
@@ -1,3 +0,0 @@
{
"require": "test/setup.js"
}
+17 -3
View File
@@ -13,12 +13,26 @@ RUN mkdir /home/node/.config && chown node:node /home/node/.config
FROM base AS app
COPY package.json package-lock.json /overleaf/
COPY services/notifications/package.json /overleaf/services/notifications/
COPY libraries/ /overleaf/libraries/
COPY libraries/fetch-utils/package.json /overleaf/libraries/fetch-utils/package.json
COPY libraries/logger/package.json /overleaf/libraries/logger/package.json
COPY libraries/metrics/package.json /overleaf/libraries/metrics/package.json
COPY libraries/mongo-utils/package.json /overleaf/libraries/mongo-utils/package.json
COPY libraries/o-error/package.json /overleaf/libraries/o-error/package.json
COPY libraries/promise-utils/package.json /overleaf/libraries/promise-utils/package.json
COPY libraries/settings/package.json /overleaf/libraries/settings/package.json
COPY libraries/validation-tools/package.json /overleaf/libraries/validation-tools/package.json
COPY services/notifications/package.json /overleaf/services/notifications/package.json
COPY patches/ /overleaf/patches/
RUN cd /overleaf && npm ci --quiet
COPY libraries/fetch-utils/ /overleaf/libraries/fetch-utils/
COPY libraries/logger/ /overleaf/libraries/logger/
COPY libraries/metrics/ /overleaf/libraries/metrics/
COPY libraries/mongo-utils/ /overleaf/libraries/mongo-utils/
COPY libraries/o-error/ /overleaf/libraries/o-error/
COPY libraries/promise-utils/ /overleaf/libraries/promise-utils/
COPY libraries/settings/ /overleaf/libraries/settings/
COPY libraries/validation-tools/ /overleaf/libraries/validation-tools/
COPY services/notifications/ /overleaf/services/notifications/
FROM app
+125
View File
@@ -0,0 +1,125 @@
// Autogenerated by build scripts. Do not edit.
pipeline {
agent {
node {
label 'jenkins-agent-web'
customWorkspace '/workspace'
}
}
options {
timestamps()
timeout(time: 15, unit: 'MINUTES')
}
environment {
BRANCH_NAME = "${env.CHANGE_BRANCH ? env.CHANGE_BRANCH : env.BRANCH_NAME}"
JENKINS_BUILD_NUMBER = "${BUILD_NUMBER}"
BUILD_NUMBER = "${SHORT_SHA}_${BUILD_NUMBER}"
DOCKER_COMPOSE_FLAGS = '-f docker-compose.ci.yml'
COMMIT_SHA = "${GIT_COMMIT}"
SHORT_SHA = "${GIT_COMMIT.take(7)}"
}
stages {
stage('Stage 1') {
parallel {
stage('Build') {
steps {
dir('services/notifications') {
retry(count: 3) {
sh 'make build'
}
}
}
}
stage('Create reports folder') {
steps {
sh 'mkdir services/notifications/reports'
}
}
}
}
stage('Stage 2') {
parallel {
stage('Push Branch Image') {
steps {
dir('services/notifications') {
sh 'make push_branch'
}
}
}
stage('Shellcheck') {
steps {
dir('services/notifications') {
sh 'make shellcheck'
}
}
}
stage('Lint') {
steps {
dir('services/notifications') {
sh 'make lint_ci'
}
}
post {
always {
recordIssues checksAnnotationScope: 'ALL', enabledForFailure: true, failOnError: true, id: 'notifications-eslint', name: 'notifications eslint', qualityGates: [[integerThreshold: 1, threshold: 1.0, type: 'TOTAL']], sourceCodeRetention: 'LAST_BUILD', tools: [esLint(pattern: 'services/notifications/reports/eslint.json')]
}
}
}
stage('Format') {
steps {
dir('services/notifications') {
sh 'make format_ci'
}
}
}
stage('Typecheck') {
steps {
dir('services/notifications') {
sh 'make typecheck_ci'
}
}
}
stage('Test Unit') {
steps {
dir('services/notifications') {
retry(count: 3) {
sh 'make test_unit'
}
}
}
}
stage('Test Acceptance') {
environment {
COMPOSE_PROJECT_NAME_TEST_ACCEPTANCE = "test_acceptance"
}
steps {
dir('services/notifications') {
retry(count: 3) {
sh 'make test_acceptance'
}
}
}
}
}
}
stage('Push Production') {
steps {
dir('services/notifications') {
sh 'make push'
}
}
}
}
post {
always {
junit checksName: 'notifications test results', testResults: 'services/notifications/reports/junit-*.xml'
}
cleanup {
dir('services/notifications') {
sh 'make clean'
}
sh 'make clean_jenkins -j10'
}
}
}
+9 -6
View File
@@ -27,14 +27,15 @@ clean:
-docker rmi us-east1-docker.pkg.dev/overleaf-ops/ol-docker/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER)
-$(DOCKER_COMPOSE_TEST_UNIT) down --remove-orphans --rmi local --timeout 0 --volumes
-$(DOCKER_COMPOSE_TEST_ACCEPTANCE) down --remove-orphans --rmi local --timeout 0 --volumes
-rm -rf reports/
HERE=$(shell pwd)
MONOREPO=$(shell cd ../../ && pwd)
export MONOREPO ?= $(shell cd ../../ && pwd)
# Run the linting commands in the scope of the monorepo.
# Eslint and prettier (plus some configs) are on the root.
RUN_LINTING = docker run --rm -v $(MONOREPO):$(MONOREPO) -w $(HERE) node:22.18.0 npm run --silent
RUN_LINTING_CI = docker run --rm --volume $(MONOREPO)/.editorconfig:/overleaf/.editorconfig --volume $(MONOREPO)/.eslintignore:/overleaf/.eslintignore --volume $(MONOREPO)/.eslintrc:/overleaf/.eslintrc --volume $(MONOREPO)/.prettierignore:/overleaf/.prettierignore --volume $(MONOREPO)/.prettierrc:/overleaf/.prettierrc --volume $(MONOREPO)/tsconfig.backend.json:/overleaf/tsconfig.backend.json ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) npm run --silent
RUN_LINTING_CI = docker run --rm --volume $(MONOREPO)/.editorconfig:/overleaf/.editorconfig --volume $(MONOREPO)/.eslintignore:/overleaf/.eslintignore --volume $(MONOREPO)/.eslintrc:/overleaf/.eslintrc --volume $(MONOREPO)/.prettierignore:/overleaf/.prettierignore --volume $(MONOREPO)/.prettierrc:/overleaf/.prettierrc --volume $(MONOREPO)/tsconfig.backend.json:/overleaf/tsconfig.backend.json --volume $(MONOREPO)/services/notifications/reports:/overleaf/services/notifications/reports ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) npm run --silent
# Same but from the top of the monorepo
RUN_LINTING_MONOREPO = docker run --rm -v $(MONOREPO):$(MONOREPO) -w $(MONOREPO) node:22.18.0 npm run --silent
@@ -70,7 +71,8 @@ lint:
$(RUN_LINTING) lint
lint_ci:
$(RUN_LINTING_CI) lint
-$(RUN_LINTING_CI) lint -- --format json --output-file reports/eslint.json
sed -i 's_"filePath":"/overleaf_"filePath":"$(MONOREPO)_g' reports/eslint.json
lint_fix:
$(RUN_LINTING) lint:fix
@@ -137,10 +139,11 @@ build:
tar:
$(DOCKER_COMPOSE) up tar
publish:
docker push $(DOCKER_REPO)/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER)
push:
docker push us-east1-docker.pkg.dev/overleaf-ops/ol-docker/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER)
push_branch:
docker push us-east1-docker.pkg.dev/overleaf-ops/ol-docker/$(PROJECT_NAME):$(BRANCH_NAME)
.PHONY: clean \
format format_fix \
@@ -7,11 +7,13 @@ services:
image: ci/$PROJECT_NAME:$BRANCH_NAME-$BUILD_NUMBER
user: node
volumes:
- ./reports:/overleaf/services/notifications/reports
- ../../bin/shared/wait_for_it:/overleaf/bin/shared/wait_for_it
- ../../tsconfig.backend.json:/overleaf/tsconfig.backend.json
entrypoint: /overleaf/bin/shared/wait_for_it mongo:27017 --timeout=60 --
command: npm run test:unit:_run
environment:
CI:
MONGO_CONNECTION_STRING: mongodb://mongo/test-overleaf
NODE_ENV: test
NODE_OPTIONS: "--unhandled-rejections=strict"
@@ -25,6 +27,7 @@ services:
build: .
image: ci/$PROJECT_NAME:$BRANCH_NAME-$BUILD_NUMBER
environment:
CI:
ELASTIC_SEARCH_DSN: es:9200
MONGO_HOST: mongo
POSTGRES_HOST: postgres
@@ -32,6 +35,7 @@ services:
NODE_ENV: test
NODE_OPTIONS: "--unhandled-rejections=strict"
volumes:
- ./reports:/overleaf/services/notifications/reports
- ../../bin/shared/wait_for_it:/overleaf/bin/shared/wait_for_it
- ../../tsconfig.backend.json:/overleaf/tsconfig.backend.json
depends_on:
@@ -1,8 +1,24 @@
const { defineConfig } = require('vitest/config')
let reporterOptions = {}
if (process.env.CI) {
reporterOptions = {
reporters: [
'default',
[
'junit',
{
classnameTemplate: `Acceptance tests.{filename}`,
},
],
],
outputFile: 'reports/junit-vitest-acceptance.xml',
}
}
module.exports = defineConfig({
test: {
include: ['test/acceptance/js/**/*.test.{js,ts}'],
isolate: false,
...reporterOptions,
},
})
@@ -1,9 +1,25 @@
const { defineConfig } = require('vitest/config')
let reporterOptions = {}
if (process.env.CI) {
reporterOptions = {
reporters: [
'default',
[
'junit',
{
classnameTemplate: `Unit tests.{filename}`,
},
],
],
outputFile: 'reports/junit-vitest-unit.xml',
}
}
module.exports = defineConfig({
test: {
include: ['test/unit/js/**/*.test.{js,ts}'],
setupFiles: ['./test/setup.js'],
isolate: false,
...reporterOptions,
},
})