mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 09:09:36 +02:00
[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:
13
services/filestore/.mocharc.cjs
Normal file
13
services/filestore/.mocharc.cjs
Normal file
@@ -0,0 +1,13 @@
|
||||
let reporterOptions = {}
|
||||
if (process.env.CI) {
|
||||
reporterOptions = {
|
||||
reporter: '/overleaf/node_modules/mocha-multi-reporters',
|
||||
'reporter-options': ['configFile=./test/mocha-multi-reporters.cjs'],
|
||||
}
|
||||
}
|
||||
const all = {
|
||||
require: 'test/setup.js',
|
||||
...reporterOptions,
|
||||
}
|
||||
|
||||
module.exports = all
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"require": "test/setup.js"
|
||||
}
|
||||
@@ -15,12 +15,24 @@ RUN mkdir /home/node/.config && chown node:node /home/node/.config
|
||||
FROM base AS app
|
||||
|
||||
COPY package.json package-lock.json /overleaf/
|
||||
COPY services/filestore/package.json /overleaf/services/filestore/
|
||||
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/o-error/package.json /overleaf/libraries/o-error/package.json
|
||||
COPY libraries/object-persistor/package.json /overleaf/libraries/object-persistor/package.json
|
||||
COPY libraries/settings/package.json /overleaf/libraries/settings/package.json
|
||||
COPY libraries/stream-utils/package.json /overleaf/libraries/stream-utils/package.json
|
||||
COPY services/filestore/package.json /overleaf/services/filestore/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/o-error/ /overleaf/libraries/o-error/
|
||||
COPY libraries/object-persistor/ /overleaf/libraries/object-persistor/
|
||||
COPY libraries/settings/ /overleaf/libraries/settings/
|
||||
COPY libraries/stream-utils/ /overleaf/libraries/stream-utils/
|
||||
COPY services/filestore/ /overleaf/services/filestore/
|
||||
|
||||
FROM app
|
||||
|
||||
152
services/filestore/Jenkinsfile
vendored
Normal file
152
services/filestore/Jenkinsfile
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
// 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/filestore') {
|
||||
retry(count: 3) {
|
||||
sh 'make build'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Create reports folder') {
|
||||
steps {
|
||||
sh 'mkdir services/filestore/reports'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Stage 2') {
|
||||
parallel {
|
||||
stage('Push Branch Image') {
|
||||
steps {
|
||||
dir('services/filestore') {
|
||||
sh 'make push_branch'
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Shellcheck') {
|
||||
steps {
|
||||
dir('services/filestore') {
|
||||
sh 'make shellcheck'
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Lint') {
|
||||
steps {
|
||||
dir('services/filestore') {
|
||||
sh 'make lint_ci'
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
recordIssues checksAnnotationScope: 'ALL', enabledForFailure: true, failOnError: true, id: 'filestore-eslint', name: 'filestore eslint', qualityGates: [[integerThreshold: 1, threshold: 1.0, type: 'TOTAL']], sourceCodeRetention: 'LAST_BUILD', tools: [esLint(pattern: 'services/filestore/reports/eslint.json')]
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Format') {
|
||||
steps {
|
||||
dir('services/filestore') {
|
||||
sh 'make format_ci'
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Typecheck') {
|
||||
steps {
|
||||
dir('services/filestore') {
|
||||
sh 'make typecheck_ci'
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Test Unit') {
|
||||
steps {
|
||||
dir('services/filestore') {
|
||||
retry(count: 3) {
|
||||
sh 'make test_unit'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Test Acceptance SHARD_01_') {
|
||||
environment {
|
||||
COMPOSE_PROJECT_NAME_TEST_ACCEPTANCE = "test_acceptance_shard_01_x"
|
||||
MOCHA_GREP = "SHARD_01_"
|
||||
}
|
||||
steps {
|
||||
dir('services/filestore') {
|
||||
retry(count: 3) {
|
||||
sh 'make test_acceptance'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Test Acceptance SHARD_02_') {
|
||||
environment {
|
||||
COMPOSE_PROJECT_NAME_TEST_ACCEPTANCE = "test_acceptance_shard_02_x"
|
||||
MOCHA_GREP = "SHARD_02_"
|
||||
}
|
||||
steps {
|
||||
dir('services/filestore') {
|
||||
retry(count: 3) {
|
||||
sh 'make test_acceptance'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Test Acceptance SHARD_03_') {
|
||||
environment {
|
||||
COMPOSE_PROJECT_NAME_TEST_ACCEPTANCE = "test_acceptance_shard_03_x"
|
||||
MOCHA_GREP = "SHARD_03_"
|
||||
}
|
||||
steps {
|
||||
dir('services/filestore') {
|
||||
retry(count: 3) {
|
||||
sh 'make test_acceptance'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
stage('Push Production') {
|
||||
steps {
|
||||
dir('services/filestore') {
|
||||
sh 'make push'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
junit checksName: 'filestore test results', testResults: 'services/filestore/reports/junit-*.xml'
|
||||
}
|
||||
cleanup {
|
||||
dir('services/filestore') {
|
||||
sh 'make clean'
|
||||
}
|
||||
sh 'make clean_jenkins -j10'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,15 +27,16 @@ 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/
|
||||
-git clean -dfX uploads template_files
|
||||
|
||||
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/filestore/reports:/overleaf/services/filestore/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
|
||||
@@ -71,7 +72,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
|
||||
@@ -138,10 +140,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 \
|
||||
|
||||
@@ -11,6 +11,7 @@ services:
|
||||
user: node
|
||||
command: npm run test:unit:_run
|
||||
environment:
|
||||
CI:
|
||||
MONGO_CONNECTION_STRING: mongodb://mongo/test-overleaf
|
||||
NODE_ENV: test
|
||||
NODE_OPTIONS: "--unhandled-rejections=strict"
|
||||
@@ -20,6 +21,7 @@ services:
|
||||
build: .
|
||||
image: ci/$PROJECT_NAME:$BRANCH_NAME-$BUILD_NUMBER
|
||||
environment:
|
||||
CI:
|
||||
ELASTIC_SEARCH_DSN: es:9200
|
||||
MONGO_HOST: mongo
|
||||
POSTGRES_HOST: postgres
|
||||
@@ -45,6 +47,7 @@ services:
|
||||
GCS_USER_FILES_BUCKET_NAME: fake-gcs-user-files
|
||||
GCS_TEMPLATE_FILES_BUCKET_NAME: fake-gcs-template-files
|
||||
volumes:
|
||||
- ./reports:/overleaf/services/filestore/reports
|
||||
- minio-certs:/certs
|
||||
depends_on:
|
||||
certs:
|
||||
|
||||
@@ -4,17 +4,17 @@
|
||||
"private": true,
|
||||
"main": "app.js",
|
||||
"scripts": {
|
||||
"test:acceptance:run": "mocha --recursive --reporter spec --timeout 15000 $@ test/acceptance/js",
|
||||
"test:acceptance:run": "mocha --recursive --timeout 15000 $@ test/acceptance/js",
|
||||
"test:acceptance": "npm run test:acceptance:_run -- --grep=$MOCHA_GREP",
|
||||
"test:unit:run": "mocha --recursive --reporter spec $@ test/unit/js",
|
||||
"test:unit:run": "mocha --recursive $@ test/unit/js",
|
||||
"test:unit": "npm run test:unit:_run -- --grep=$MOCHA_GREP",
|
||||
"start": "node app.js",
|
||||
"nodemon": "node --watch app.js",
|
||||
"lint": "eslint --max-warnings 0 --format unix .",
|
||||
"format": "prettier --list-different $PWD/'**/{*.*js,*.ts}'",
|
||||
"format:fix": "prettier --write $PWD/'**/{*.*js,*.ts}'",
|
||||
"test:acceptance:_run": "mocha --recursive --reporter spec --timeout 15000 --exit $@ test/acceptance/js",
|
||||
"test:unit:_run": "mocha --recursive --reporter spec --exit $@ test/unit/js",
|
||||
"test:acceptance:_run": "mocha --recursive --timeout 15000 --exit $@ test/acceptance/js",
|
||||
"test:unit:_run": "mocha --recursive --exit $@ test/unit/js",
|
||||
"lint:fix": "eslint --fix .",
|
||||
"types:check": "tsc --noEmit"
|
||||
},
|
||||
@@ -40,6 +40,8 @@
|
||||
"chai": "^4.3.6",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
"mocha": "^11.1.0",
|
||||
"mocha-junit-reporter": "^2.2.1",
|
||||
"mocha-multi-reporters": "^1.5.1",
|
||||
"mongodb": "6.12.0",
|
||||
"sandboxed-module": "2.0.4",
|
||||
"sinon": "9.0.2",
|
||||
|
||||
8
services/filestore/test/mocha-multi-reporters.cjs
Normal file
8
services/filestore/test/mocha-multi-reporters.cjs
Normal file
@@ -0,0 +1,8 @@
|
||||
module.exports = {
|
||||
reporterEnabled: 'spec, mocha-junit-reporter',
|
||||
mochaJunitReporterReporterOptions: {
|
||||
mochaFile: `reports/junit-mocha-${process.env.MOCHA_GREP}.xml`,
|
||||
includePending: true,
|
||||
jenkinsMode: true,
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user