diff --git a/services/chat/.eslintrc b/services/chat/.eslintrc index c7535c57a7..42a4b5cace 100644 --- a/services/chat/.eslintrc +++ b/services/chat/.eslintrc @@ -1,13 +1,16 @@ // 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.1.18 +// Version: 1.3.5 { "extends": [ "standard", "prettier", - "prettier/standard", + "prettier/standard" ], + "parserOptions": { + "ecmaVersion": 2017 + }, "plugins": [ "mocha", "chai-expect", @@ -18,20 +21,45 @@ "mocha": true }, "rules": { - // Add some mocha specific rules - "mocha/handle-done-callback": "error", - "mocha/no-exclusive-tests": "error", - "mocha/no-global-tests": "error", - "mocha/no-identical-title": "error", - "mocha/no-nested-tests": "error", - "mocha/no-pending-tests": "error", - "mocha/no-skipped-tests": "error", - - // Add some chai specific rules - "chai-expect/missing-assertion": "error", - "chai-expect/terminating-properties": "error", // Swap the no-unused-expressions rule with a more chai-friendly one "no-unused-expressions": 0, "chai-friendly/no-unused-expressions": "error" - } + }, + "overrides": [ + { + // Test specific rules + "files": ["test/**/*.js"], + "globals": { + "expect": true + }, + "rules": { + // mocha-specific rules + "mocha/handle-done-callback": "error", + "mocha/no-exclusive-tests": "error", + "mocha/no-global-tests": "error", + "mocha/no-identical-title": "error", + "mocha/no-nested-tests": "error", + "mocha/no-pending-tests": "error", + "mocha/no-skipped-tests": "error", + "mocha/no-mocha-arrows": "error", + + // chai-specific rules + "chai-expect/missing-assertion": "error", + "chai-expect/terminating-properties": "error", + + // prefer-arrow-callback applies to all callbacks, not just ones in mocha tests. + // we don't enforce this at the top-level - just in tests to manage `this` scope + // based on mocha's context mechanism + "mocha/prefer-arrow-callback": "error" + } + }, + { + // Backend specific rules + "files": ["app/**/*.js", "app.js", "index.js"], + "rules": { + // don't allow console.log in backend code + "no-console": "error" + } + } + ] } diff --git a/services/chat/.github/PULL_REQUEST_TEMPLATE.md b/services/chat/.github/PULL_REQUEST_TEMPLATE.md index ed25ee83c1..eccd3ef6e9 100644 --- a/services/chat/.github/PULL_REQUEST_TEMPLATE.md +++ b/services/chat/.github/PULL_REQUEST_TEMPLATE.md @@ -1,3 +1,4 @@ + ### Description diff --git a/services/chat/.prettierrc b/services/chat/.prettierrc index 309199656b..5845b82113 100644 --- a/services/chat/.prettierrc +++ b/services/chat/.prettierrc @@ -1,7 +1,7 @@ # 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.1.18 +# Version: 1.3.5 { "semi": false, "singleQuote": true diff --git a/services/chat/Dockerfile b/services/chat/Dockerfile index a059d4592e..2d8b097e26 100644 --- a/services/chat/Dockerfile +++ b/services/chat/Dockerfile @@ -1,7 +1,14 @@ -FROM node:10.19.0 as app +# 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.3.5 + +FROM node:10.19.0 as base WORKDIR /app +FROM base as app + #wildcard as some files may not be in all repos COPY package*.json npm-shrink*.json /app/ @@ -11,11 +18,9 @@ COPY . /app -FROM node:10.19.0 +FROM base COPY --from=app /app /app - -WORKDIR /app USER node CMD ["node", "--expose-gc", "app.js"] diff --git a/services/chat/Jenkinsfile b/services/chat/Jenkinsfile index d2fdaca8fa..31a427dd08 100644 --- a/services/chat/Jenkinsfile +++ b/services/chat/Jenkinsfile @@ -16,6 +16,7 @@ pipeline { } stages { + stage('Install') { steps { withCredentials([usernamePassword(credentialsId: 'GITHUB_INTEGRATION', usernameVariable: 'GH_AUTH_USERNAME', passwordVariable: 'GH_AUTH_PASSWORD')]) { diff --git a/services/chat/Makefile b/services/chat/Makefile index 6a36e44141..73f84f40e9 100644 --- a/services/chat/Makefile +++ b/services/chat/Makefile @@ -1,7 +1,7 @@ # 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.1.21 +# Version: 1.3.5 BUILD_NUMBER ?= local BRANCH_NAME ?= $(shell git rev-parse --abbrev-ref HEAD) @@ -33,14 +33,20 @@ test_unit: test_acceptance: test_clean test_acceptance_pre_run test_acceptance_run +test_acceptance_debug: test_clean test_acceptance_pre_run test_acceptance_run_debug + test_acceptance_run: @[ ! -d test/acceptance ] && echo "chat has no acceptance tests" || $(DOCKER_COMPOSE) run --rm test_acceptance +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 + test_clean: $(DOCKER_COMPOSE) down -v -t 0 test_acceptance_pre_run: - @[ ! -f test/acceptance/scripts/pre-run ] && echo "chat has no pre acceptance tests task" || $(DOCKER_COMPOSE) run --rm test_acceptance test/acceptance/scripts/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 + build: docker build --pull --tag ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \ --tag gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \ @@ -53,4 +59,5 @@ publish: docker push $(DOCKER_REPO)/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) + .PHONY: clean test test_unit test_acceptance test_clean build publish diff --git a/services/chat/buildscript.txt b/services/chat/buildscript.txt index 74195be757..e329b95239 100644 --- a/services/chat/buildscript.txt +++ b/services/chat/buildscript.txt @@ -1,8 +1,10 @@ chat +--public-repo=False --language=es +--env-add= --node-version=10.19.0 --acceptance-creds=None --dependencies=mongo,redis --docker-repos=gcr.io/overleaf-ops ---build-target=docker ---script-version=1.1.21 +--env-pass-through= +--script-version=1.3.5 diff --git a/services/chat/docker-compose.ci.yml b/services/chat/docker-compose.ci.yml index d2bcca9ec6..b99da9b18e 100644 --- a/services/chat/docker-compose.ci.yml +++ b/services/chat/docker-compose.ci.yml @@ -1,9 +1,9 @@ # 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.1.21 +# Version: 1.3.5 -version: "2" +version: "2.3" services: test_unit: @@ -25,13 +25,14 @@ services: MOCHA_GREP: ${MOCHA_GREP} NODE_ENV: test depends_on: - - mongo - - redis + mongo: + condition: service_healthy + redis: + condition: service_healthy user: node command: npm run test:acceptance:_run - tar: build: . image: ci/$PROJECT_NAME:$BRANCH_NAME-$BUILD_NUMBER @@ -39,9 +40,8 @@ services: - ./:/tmp/build/ command: tar -czf /tmp/build/build.tar.gz --exclude=build.tar.gz --exclude-vcs . user: root - redis: image: redis mongo: - image: mongo:3.4 + image: mongo:3.6 diff --git a/services/chat/docker-compose.yml b/services/chat/docker-compose.yml index 25a9154442..6a1bbb1005 100644 --- a/services/chat/docker-compose.yml +++ b/services/chat/docker-compose.yml @@ -1,9 +1,9 @@ # 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.1.21 +# Version: 1.3.5 -version: "2" +version: "2.3" services: test_unit: @@ -18,7 +18,7 @@ services: user: node test_acceptance: - build: . + image: node:10.19.0 volumes: - .:/app working_dir: /app @@ -32,22 +32,15 @@ services: NODE_ENV: test user: node depends_on: - - mongo - - redis + mongo: + condition: service_healthy + redis: + condition: service_healthy command: npm run test:acceptance - - - tar: - build: . - image: ci/$PROJECT_NAME:$BRANCH_NAME-$BUILD_NUMBER - volumes: - - ./:/tmp/build/ - command: tar -czf /tmp/build/build.tar.gz --exclude=build.tar.gz --exclude-vcs . - user: root - redis: image: redis mongo: - image: mongo:3.4 + image: mongo:3.6 + diff --git a/services/chat/test/acceptance/js/SendingAMessageTests.js b/services/chat/test/acceptance/js/SendingAMessageTests.js index f837a2edd5..4b2a1fe91c 100644 --- a/services/chat/test/acceptance/js/SendingAMessageTests.js +++ b/services/chat/test/acceptance/js/SendingAMessageTests.js @@ -18,7 +18,9 @@ const ChatClient = require('./helpers/ChatClient') const ChatApp = require('./helpers/ChatApp') describe('Sending a message', function() { - before(done => ChatApp.ensureRunning(done)) + before(function(done) { + return ChatApp.ensureRunning(done) + }) describe('globally', function() { before(function(done) { @@ -111,8 +113,8 @@ describe('Sending a message', function() { return (this.thread_id = ObjectId().toString()) }) - describe('with a malformed user_id', () => - it('should return a graceful error', function(done) { + describe('with a malformed user_id', function() { + return it('should return a graceful error', function(done) { return ChatClient.sendMessage( this.project_id, this.thread_id, @@ -124,10 +126,11 @@ describe('Sending a message', function() { return done() } ) - })) + }) + }) - describe('with a malformed project_id', () => - it('should return a graceful error', function(done) { + describe('with a malformed project_id', function() { + return it('should return a graceful error', function(done) { return ChatClient.sendMessage( 'malformed-project', this.thread_id, @@ -139,10 +142,11 @@ describe('Sending a message', function() { return done() } ) - })) + }) + }) - describe('with a malformed thread_id', () => - it('should return a graceful error', function(done) { + describe('with a malformed thread_id', function() { + return it('should return a graceful error', function(done) { return ChatClient.sendMessage( this.project_id, 'malformed-thread-id', @@ -154,10 +158,11 @@ describe('Sending a message', function() { return done() } ) - })) + }) + }) - describe('with no content', () => - it('should return a graceful error', function(done) { + describe('with no content', function() { + return it('should return a graceful error', function(done) { return ChatClient.sendMessage( this.project_id, this.thread_id, @@ -169,10 +174,11 @@ describe('Sending a message', function() { return done() } ) - })) + }) + }) - return describe('with very long content', () => - it('should return a graceful error', function(done) { + return describe('with very long content', function() { + return it('should return a graceful error', function(done) { const content = new Buffer(10240).toString('hex') return ChatClient.sendMessage( this.project_id, @@ -185,6 +191,7 @@ describe('Sending a message', function() { return done() } ) - })) + }) + }) }) })