[misc] bump the dev-env to 3.3.2

This commit is contained in:
Jakob Ackermann 2020-08-10 17:01:11 +01:00
parent 512cb5df79
commit e992166680
27 changed files with 199 additions and 280 deletions

View file

@ -1,7 +1,6 @@
// this file was auto-generated, do not edit it directly.
// instead run bin/update_build_scripts from
// https://github.com/sharelatex/sharelatex-dev-environment
// Version: 1.4.0
{
"extends": [
"standard",
@ -9,7 +8,7 @@
"prettier/standard"
],
"parserOptions": {
"ecmaVersion": 2017
"ecmaVersion": 2018
},
"plugins": [
"mocha",

17
services/chat/.github/dependabot.yml vendored Normal file
View file

@ -0,0 +1,17 @@
version: 2
updates:
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: "daily"
pull-request-branch-name:
# Separate sections of the branch name with a hyphen
# Docker images use the branch name and do not support slashes in tags
# https://github.com/overleaf/google-ops/issues/822
# https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates#pull-request-branch-nameseparator
separator: "-"
# Block informal upgrades -- security upgrades use a separate queue.
# https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates#open-pull-requests-limit
open-pull-requests-limit: 0

View file

@ -7,3 +7,6 @@ node_modules/
plato/
**/*.map
# managed by dev-environment$ bin/update_build_scripts
.npmrc

View file

@ -1,7 +1,6 @@
# This file was auto-generated, do not edit it directly.
# Instead run bin/update_build_scripts from
# https://github.com/sharelatex/sharelatex-dev-environment
# Version: 1.4.0
{
"semi": false,
"singleQuote": true

View file

@ -1,7 +1,6 @@
# This file was auto-generated, do not edit it directly.
# Instead run bin/update_build_scripts from
# https://github.com/sharelatex/sharelatex-dev-environment
# Version: 1.4.0
FROM node:10.21.0 as base
@ -12,12 +11,10 @@ FROM base as app
#wildcard as some files may not be in all repos
COPY package*.json npm-shrink*.json /app/
RUN npm install --quiet
RUN npm ci --quiet
COPY . /app
FROM base
COPY --from=app /app /app

View file

@ -1,131 +0,0 @@
String cron_string = BRANCH_NAME == "master" ? "@daily" : ""
pipeline {
agent any
environment {
GIT_PROJECT = "chat"
JENKINS_WORKFLOW = "chat-sharelatex"
TARGET_URL = "${env.JENKINS_URL}blue/organizations/jenkins/${JENKINS_WORKFLOW}/detail/$BRANCH_NAME/$BUILD_NUMBER/pipeline"
GIT_API_URL = "https://api.github.com/repos/overleaf/${GIT_PROJECT}/statuses/$GIT_COMMIT"
}
triggers {
pollSCM('* * * * *')
cron(cron_string)
}
stages {
stage('Install') {
steps {
withCredentials([usernamePassword(credentialsId: 'GITHUB_INTEGRATION', usernameVariable: 'GH_AUTH_USERNAME', passwordVariable: 'GH_AUTH_PASSWORD')]) {
sh "curl $GIT_API_URL \
--data '{ \
\"state\" : \"pending\", \
\"target_url\": \"$TARGET_URL\", \
\"description\": \"Your build is underway\", \
\"context\": \"ci/jenkins\" }' \
-u $GH_AUTH_USERNAME:$GH_AUTH_PASSWORD"
}
}
}
stage('Build') {
steps {
sh 'make build'
}
}
stage('Linting') {
steps {
sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make format'
sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make lint'
}
}
stage('Unit Tests') {
steps {
sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make test_unit'
}
}
stage('Acceptance Tests') {
steps {
sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make test_acceptance'
}
}
stage('Package and docker push') {
steps {
sh 'echo ${BUILD_NUMBER} > build_number.txt'
sh 'touch build.tar.gz' // Avoid tar warning about files changing during read
sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make tar'
withCredentials([file(credentialsId: 'gcr.io_overleaf-ops', variable: 'DOCKER_REPO_KEY_PATH')]) {
sh 'docker login -u _json_key --password-stdin https://gcr.io/overleaf-ops < ${DOCKER_REPO_KEY_PATH}'
}
sh 'DOCKER_REPO=gcr.io/overleaf-ops make publish'
sh 'docker logout https://gcr.io/overleaf-ops'
}
}
stage('Publish to s3') {
steps {
sh 'echo ${BRANCH_NAME}-${BUILD_NUMBER} > build_number.txt'
withAWS(credentials:'S3_CI_BUILDS_AWS_KEYS', region:"${S3_REGION_BUILD_ARTEFACTS}") {
s3Upload(file:'build.tar.gz', bucket:"${S3_BUCKET_BUILD_ARTEFACTS}", path:"${JOB_NAME}/${BUILD_NUMBER}.tar.gz")
}
withAWS(credentials:'S3_CI_BUILDS_AWS_KEYS', region:"${S3_REGION_BUILD_ARTEFACTS}") {
// The deployment process uses this file to figure out the latest build
s3Upload(file:'build_number.txt', bucket:"${S3_BUCKET_BUILD_ARTEFACTS}", path:"${JOB_NAME}/latest")
}
}
}
}
post {
always {
sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make test_clean'
sh 'make clean'
}
success {
withCredentials([usernamePassword(credentialsId: 'GITHUB_INTEGRATION', usernameVariable: 'GH_AUTH_USERNAME', passwordVariable: 'GH_AUTH_PASSWORD')]) {
sh "curl $GIT_API_URL \
--data '{ \
\"state\" : \"success\", \
\"target_url\": \"$TARGET_URL\", \
\"description\": \"Your build succeeded!\", \
\"context\": \"ci/jenkins\" }' \
-u $GH_AUTH_USERNAME:$GH_AUTH_PASSWORD"
}
}
failure {
mail(from: "${EMAIL_ALERT_FROM}",
to: "${EMAIL_ALERT_TO}",
subject: "Jenkins build failed: ${JOB_NAME}:${BUILD_NUMBER}",
body: "Build: ${BUILD_URL}")
withCredentials([usernamePassword(credentialsId: 'GITHUB_INTEGRATION', usernameVariable: 'GH_AUTH_USERNAME', passwordVariable: 'GH_AUTH_PASSWORD')]) {
sh "curl $GIT_API_URL \
--data '{ \
\"state\" : \"failure\", \
\"target_url\": \"$TARGET_URL\", \
\"description\": \"Your build failed\", \
\"context\": \"ci/jenkins\" }' \
-u $GH_AUTH_USERNAME:$GH_AUTH_PASSWORD"
}
}
}
// The options directive is for configuration that applies to the whole job.
options {
// we'd like to make sure remove old builds, so we don't fill up our storage!
buildDiscarder(logRotator(numToKeepStr:'50'))
// And we'd really like to be sure that this build doesn't hang forever, so let's time it out after:
timeout(time: 30, unit: 'MINUTES')
}
}

View file

@ -1,11 +1,12 @@
# This file was auto-generated, do not edit it directly.
# Instead run bin/update_build_scripts from
# https://github.com/sharelatex/sharelatex-dev-environment
# Version: 1.4.0
BUILD_NUMBER ?= local
BRANCH_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
PROJECT_NAME = chat
BUILD_DIR_NAME = $(shell pwd | xargs basename | tr -cd '[a-zA-Z0-9_.\-]')
DOCKER_COMPOSE_FLAGS ?= -f docker-compose.yml
DOCKER_COMPOSE := BUILD_NUMBER=$(BUILD_NUMBER) \
BRANCH_NAME=$(BRANCH_NAME) \
@ -13,39 +14,63 @@ DOCKER_COMPOSE := BUILD_NUMBER=$(BUILD_NUMBER) \
MOCHA_GREP=${MOCHA_GREP} \
docker-compose ${DOCKER_COMPOSE_FLAGS}
DOCKER_COMPOSE_TEST_ACCEPTANCE = \
COMPOSE_PROJECT_NAME=test_acceptance_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE)
DOCKER_COMPOSE_TEST_UNIT = \
COMPOSE_PROJECT_NAME=test_unit_$(BUILD_DIR_NAME) $(DOCKER_COMPOSE)
clean:
docker rmi ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER)
docker rmi gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER)
format:
$(DOCKER_COMPOSE) run --rm test_unit npm run format
$(DOCKER_COMPOSE) run --rm test_unit npm run --silent format
format_fix:
$(DOCKER_COMPOSE) run --rm test_unit npm run format:fix
$(DOCKER_COMPOSE) run --rm test_unit npm run --silent format:fix
lint:
$(DOCKER_COMPOSE) run --rm test_unit npm run lint
$(DOCKER_COMPOSE) run --rm test_unit npm run --silent lint
test: format lint test_unit test_acceptance
test_unit:
@[ ! -d test/unit ] && echo "chat has no unit tests" || $(DOCKER_COMPOSE) run --rm test_unit
ifneq (,$(wildcard test/unit))
$(DOCKER_COMPOSE_TEST_UNIT) run --rm test_unit
$(MAKE) test_unit_clean
endif
test_acceptance: test_clean test_acceptance_pre_run test_acceptance_run
test_clean: test_unit_clean
test_unit_clean:
ifneq (,$(wildcard test/unit))
$(DOCKER_COMPOSE_TEST_UNIT) down -v -t 0
endif
test_acceptance_debug: test_clean test_acceptance_pre_run test_acceptance_run_debug
test_acceptance: test_acceptance_clean test_acceptance_pre_run test_acceptance_run
$(MAKE) test_acceptance_clean
test_acceptance_debug: test_acceptance_clean test_acceptance_pre_run test_acceptance_run_debug
$(MAKE) test_acceptance_clean
test_acceptance_run:
@[ ! -d test/acceptance ] && echo "chat has no acceptance tests" || $(DOCKER_COMPOSE) run --rm test_acceptance
ifneq (,$(wildcard test/acceptance))
$(DOCKER_COMPOSE_TEST_ACCEPTANCE) run --rm test_acceptance
endif
test_acceptance_run_debug:
@[ ! -d test/acceptance ] && echo "chat has no acceptance tests" || $(DOCKER_COMPOSE) run -p 127.0.0.9:19999:19999 --rm test_acceptance npm run test:acceptance -- --inspect=0.0.0.0:19999 --inspect-brk
ifneq (,$(wildcard test/acceptance))
$(DOCKER_COMPOSE_TEST_ACCEPTANCE) run -p 127.0.0.9:19999:19999 --rm test_acceptance npm run test:acceptance -- --inspect=0.0.0.0:19999 --inspect-brk
endif
test_clean:
$(DOCKER_COMPOSE) down -v -t 0
test_clean: test_acceptance_clean
test_acceptance_clean:
$(DOCKER_COMPOSE_TEST_ACCEPTANCE) down -v -t 0
test_acceptance_pre_run:
@[ ! -f test/acceptance/js/scripts/pre-run ] && echo "chat has no pre acceptance tests task" || $(DOCKER_COMPOSE) run --rm test_acceptance test/acceptance/js/scripts/pre-run
ifneq (,$(wildcard test/acceptance/js/scripts/pre-run))
$(DOCKER_COMPOSE_TEST_ACCEPTANCE) run --rm test_acceptance test/acceptance/js/scripts/pre-run
endif
build:
docker build --pull --tag ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \

View file

@ -15,12 +15,12 @@ if (!module.parent) {
const port =
__guard__(
settings.internal != null ? settings.internal.chat : undefined,
x => x.port
(x) => x.port
) || 3010
const host =
__guard__(
settings.internal != null ? settings.internal.chat : undefined,
x1 => x1.host
(x1) => x1.host
) || 'localhost'
Server.server.listen(port, host, function (error) {
if (error != null) {

View file

@ -31,7 +31,7 @@ module.exports = MessageFormatter = {
},
formatMessagesForClientSide(messages) {
return Array.from(messages).map(message =>
return Array.from(messages).map((message) =>
this.formatMessageForClientSide(message)
)
},

View file

@ -53,11 +53,14 @@ module.exports = MessageHttpController = {
getAllThreads(req, res, next) {
const { project_id } = req.params
logger.log({ project_id }, 'getting all threads')
return ThreadManager.findAllThreadRooms(project_id, function(error, rooms) {
return ThreadManager.findAllThreadRooms(project_id, function (
error,
rooms
) {
if (error != null) {
return next(error)
}
const room_ids = rooms.map(r => r._id)
const room_ids = rooms.map((r) => r._id)
return MessageManager.findAllMessagesInRooms(room_ids, function (
error,
messages
@ -75,14 +78,17 @@ module.exports = MessageHttpController = {
const { project_id, thread_id } = req.params
const { user_id } = req.body
logger.log({ user_id, project_id, thread_id }, 'marking thread as resolved')
return ThreadManager.resolveThread(project_id, thread_id, user_id, function(
error
) {
return ThreadManager.resolveThread(
project_id,
thread_id,
user_id,
function (error) {
if (error != null) {
return next(error)
}
return res.sendStatus(204)
})
}
)
}, // No content
reopenThread(req, res, next) {

View file

@ -44,10 +44,7 @@ module.exports = MessageManager = {
query.timestamp = { $lt: before }
}
query = this._ensureIdsAreObjectIds(query)
const cursor = db.messages
.find(query)
.sort({ timestamp: -1 })
.limit(limit)
const cursor = db.messages.find(query).sort({ timestamp: -1 }).limit(limit)
return cursor.toArray(callback)
},
@ -135,7 +132,7 @@ module.exports = MessageManager = {
'findAllMessagesInRooms',
'updateMessage',
'deleteMessage'
].map(method =>
].map((method) =>
metrics.timeAsyncMethod(
MessageManager,
method,

View file

@ -155,6 +155,6 @@ module.exports = ThreadManager = {
'resolveThread',
'reopenThread',
'deleteThread'
].map(method =>
].map((method) =>
metrics.timeAsyncMethod(ThreadManager, method, 'mongo.ThreadManager', logger)
)

View file

@ -1,10 +1,8 @@
chat
--acceptance-creds=None
--dependencies=mongo
--docker-repos=gcr.io/overleaf-ops
--env-add=
--env-pass-through=
--language=es
--node-version=10.21.0
--public-repo=False
--script-version=1.4.0
--script-version=3.3.2

View file

@ -8,8 +8,9 @@ module.exports = {
apis: {
web: {
url: `http://${process.env.WEB_HOST || 'localhost'}:${process.env
.WEB_PORT || 3000}`,
url: `http://${process.env.WEB_HOST || 'localhost'}:${
process.env.WEB_PORT || 3000
}`,
user: process.env.WEB_API_USER || 'sharelatex',
pass: process.env.WEB_API_PASSWORD || 'password'
}

View file

@ -1,7 +1,6 @@
# This file was auto-generated, do not edit it directly.
# Instead run bin/update_build_scripts from
# https://github.com/sharelatex/sharelatex-dev-environment
# Version: 1.4.0
version: "2.3"
@ -12,6 +11,7 @@ services:
command: npm run test:unit:_run
environment:
NODE_ENV: test
NODE_OPTIONS: "--unhandled-rejections=strict"
test_acceptance:
@ -24,6 +24,7 @@ services:
POSTGRES_HOST: postgres
MOCHA_GREP: ${MOCHA_GREP}
NODE_ENV: test
NODE_OPTIONS: "--unhandled-rejections=strict"
depends_on:
mongo:
condition: service_healthy
@ -39,4 +40,4 @@ services:
command: tar -czf /tmp/build/build.tar.gz --exclude=build.tar.gz --exclude-vcs .
user: root
mongo:
image: mongo:3.6
image: mongo:4.0

View file

@ -1,7 +1,6 @@
# This file was auto-generated, do not edit it directly.
# Instead run bin/update_build_scripts from
# https://github.com/sharelatex/sharelatex-dev-environment
# Version: 1.4.0
version: "2.3"
@ -14,7 +13,8 @@ services:
environment:
MOCHA_GREP: ${MOCHA_GREP}
NODE_ENV: test
command: npm run test:unit
NODE_OPTIONS: "--unhandled-rejections=strict"
command: npm run --silent test:unit
user: node
test_acceptance:
@ -30,12 +30,13 @@ services:
MOCHA_GREP: ${MOCHA_GREP}
LOG_LEVEL: ERROR
NODE_ENV: test
NODE_OPTIONS: "--unhandled-rejections=strict"
user: node
depends_on:
mongo:
condition: service_healthy
command: npm run test:acceptance
command: npm run --silent test:acceptance
mongo:
image: mongo:3.6
image: mongo:4.0

View file

@ -8,7 +8,6 @@
"execMap": {
"js": "npm run start"
},
"watch": [
"app/js/",
"app.js",

View file

@ -5152,9 +5152,9 @@
"dev": true
},
"prettier": {
"version": "1.19.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz",
"integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==",
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.0.5.tgz",
"integrity": "sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg==",
"dev": true
},
"prettier-eslint": {
@ -5397,6 +5397,12 @@
"mimic-fn": "^1.0.0"
}
},
"prettier": {
"version": "1.19.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-1.19.1.tgz",
"integrity": "sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew==",
"dev": true
},
"restore-cursor": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-2.0.0.tgz",

View file

@ -13,7 +13,7 @@
"nodemon": "nodemon --config nodemon.json",
"test:acceptance:_run": "mocha --recursive --reporter spec --timeout 15000 --exit $@ test/acceptance/js",
"test:unit:_run": "mocha --recursive --reporter spec $@ test/unit/js",
"lint": "node_modules/.bin/eslint .",
"lint": "node_modules/.bin/eslint --max-warnings 0 .",
"format": "node_modules/.bin/prettier-eslint $PWD'/**/*.js' --list-different",
"format:fix": "node_modules/.bin/prettier-eslint $PWD'/**/*.js' --write"
},
@ -46,6 +46,7 @@
"eslint-plugin-standard": "^4.0.1",
"mocha": "^7.1.0",
"nodemon": "^2.0.2",
"prettier": "^2.0.0",
"prettier-eslint-cli": "^5.0.0",
"sandboxed-module": "^2.0.3",
"sinon": "^9.0.0",

View file

@ -32,14 +32,14 @@ describe('Getting messages', function() {
this.project_id = ObjectId().toString()
return async.series(
[
cb =>
(cb) =>
ChatClient.sendGlobalMessage(
this.project_id,
this.user_id1,
this.content1,
cb
),
cb =>
(cb) =>
ChatClient.sendGlobalMessage(
this.project_id,
this.user_id2,
@ -74,7 +74,7 @@ describe('Getting messages', function() {
this.thread_id2 = ObjectId().toString()
return async.series(
[
cb =>
(cb) =>
ChatClient.sendMessage(
this.project_id,
this.thread_id1,
@ -82,7 +82,7 @@ describe('Getting messages', function() {
'one',
cb
),
cb =>
(cb) =>
ChatClient.sendMessage(
this.project_id,
this.thread_id2,
@ -90,7 +90,7 @@ describe('Getting messages', function() {
'two',
cb
),
cb =>
(cb) =>
ChatClient.sendMessage(
this.project_id,
this.thread_id1,
@ -98,7 +98,7 @@ describe('Getting messages', function() {
'three',
cb
),
cb =>
(cb) =>
ChatClient.sendMessage(
this.project_id,
this.thread_id2,

View file

@ -29,7 +29,7 @@ module.exports = {
} else {
this.initing = true
this.callbacks.push(callback)
return app.listen(3010, 'localhost', error => {
return app.listen(3010, 'localhost', (error) => {
if (error != null) {
throw error
}