From bd42fe577676f13997cf28c9a91b6da0ae0b111d Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Mon, 1 Apr 2019 09:42:54 +0100 Subject: [PATCH 1/2] increase timeout for long-running acceptance tests --- test/acceptance/coffee/ExampleDocumentTests.coffee | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/acceptance/coffee/ExampleDocumentTests.coffee b/test/acceptance/coffee/ExampleDocumentTests.coffee index 9f96e6d..f8e4a77 100644 --- a/test/acceptance/coffee/ExampleDocumentTests.coffee +++ b/test/acceptance/coffee/ExampleDocumentTests.coffee @@ -15,6 +15,8 @@ try catch err console.log err, fixturePath("tmp"), "unable to create fixture tmp path" +MOCHA_LATEX_TIMEOUT = 60 * 1000 + convertToPng = (pdfPath, pngPath, callback = (error) ->) -> command = "convert #{fixturePath(pdfPath)} #{fixturePath(pngPath)}" console.log "COMMAND" @@ -109,6 +111,7 @@ describe "Example Documents", -> @project_id = Client.randomId() + "_" + example_dir it "should generate the correct pdf", (done) -> + this.timeout(MOCHA_LATEX_TIMEOUT) Client.compileDirectory @project_id, fixturePath("examples"), example_dir, 4242, (error, res, body) => if error || body?.compile?.status is "failure" console.log "DEBUG: error", error, "body", JSON.stringify(body) @@ -116,6 +119,7 @@ describe "Example Documents", -> downloadAndComparePdf(@project_id, example_dir, pdf.url, done) it "should generate the correct pdf on the second run as well", (done) -> + this.timeout(MOCHA_LATEX_TIMEOUT) Client.compileDirectory @project_id, fixturePath("examples"), example_dir, 4242, (error, res, body) => if error || body?.compile?.status is "failure" console.log "DEBUG: error", error, "body", JSON.stringify(body) From d2c2629ef53a62b847bfabdead0c2d8b2b3aaf22 Mon Sep 17 00:00:00 2001 From: Christopher Hoskin Date: Thu, 2 May 2019 15:27:21 +0100 Subject: [PATCH 2/2] Bump buildscripts from 1.1.11 to 1.1.20 --- Jenkinsfile | 10 ++++++++-- Makefile | 10 +++++++--- buildscript.txt | 5 ++--- docker-compose.ci.yml | 15 ++++++++++++++- docker-compose.yml | 16 +++++++++++++++- package.json | 2 +- 6 files changed, 47 insertions(+), 11 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d82360d..e5b9ce6 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -48,8 +48,11 @@ pipeline { } } - stage('Package and publish build') { + 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}' @@ -60,9 +63,12 @@ pipeline { } } - stage('Publish build number') { + 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") diff --git a/Makefile b/Makefile index e7a1e34..ad83231 100644 --- a/Makefile +++ b/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.11 +# Version: 1.1.20 BUILD_NUMBER ?= local BRANCH_NAME ?= $(shell git rev-parse --abbrev-ref HEAD) @@ -13,7 +13,6 @@ DOCKER_COMPOSE := BUILD_NUMBER=$(BUILD_NUMBER) \ MOCHA_GREP=${MOCHA_GREP} \ docker-compose ${DOCKER_COMPOSE_FLAGS} - clean: docker rmi ci/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) docker rmi gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) @@ -27,7 +26,9 @@ test: test_unit test_acceptance test_unit: @[ ! -d test/unit ] && echo "clsi has no unit tests" || $(DOCKER_COMPOSE) run --rm test_unit -test_acceptance: test_clean test_acceptance_pre_run # clear the database before each acceptance test run +test_acceptance: test_clean test_acceptance_pre_run test_acceptance_run + +test_acceptance_run: @[ ! -d test/acceptance ] && echo "clsi has no acceptance tests" || $(DOCKER_COMPOSE) run --rm test_acceptance test_clean: @@ -40,6 +41,9 @@ build: --tag gcr.io/overleaf-ops/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) \ . +tar: + $(DOCKER_COMPOSE) up tar + publish: docker push $(DOCKER_REPO)/$(PROJECT_NAME):$(BRANCH_NAME)-$(BUILD_NUMBER) diff --git a/buildscript.txt b/buildscript.txt index 2ca09a3..085d8cb 100644 --- a/buildscript.txt +++ b/buildscript.txt @@ -1,9 +1,8 @@ ---script-version=1.1.11 clsi +--language=coffeescript --node-version=10.15.0 --acceptance-creds=None ---language=coffeescript --dependencies=mongo,redis --docker-repos=gcr.io/overleaf-ops ---kube=false --build-target=docker +--script-version=1.1.20 diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml index 698c5cb..c6c35db 100644 --- a/docker-compose.ci.yml +++ b/docker-compose.ci.yml @@ -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.11 +# Version: 1.1.20 version: "2" @@ -9,6 +9,8 @@ services: test_unit: image: ci/$PROJECT_NAME:$BRANCH_NAME-$BUILD_NUMBER command: npm run test:unit:_run + environment: + NODE_ENV: test test_acceptance: @@ -23,11 +25,22 @@ services: MONGO_HOST: mongo POSTGRES_HOST: postgres MOCHA_GREP: ${MOCHA_GREP} + NODE_ENV: test depends_on: - mongo - redis command: npm run test:acceptance:_run + + + 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 diff --git a/docker-compose.yml b/docker-compose.yml index 5c3c4c8..3af0f7a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -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.11 +# Version: 1.1.20 version: "2" @@ -13,6 +13,7 @@ services: working_dir: /app environment: MOCHA_GREP: ${MOCHA_GREP} + NODE_ENV: test command: npm run test:unit test_acceptance: @@ -29,14 +30,27 @@ services: MONGO_HOST: mongo POSTGRES_HOST: postgres MOCHA_GREP: ${MOCHA_GREP} + LOG_LEVEL: ERROR + NODE_ENV: test depends_on: - mongo - redis 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 + diff --git a/package.json b/package.json index b2cd671..61df397 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "scripts": { "compile:app": "([ -e app/coffee ] && coffee -m $COFFEE_OPTIONS -o app/js -c app/coffee || echo 'No CoffeeScript folder to compile') && ( [ -e app.coffee ] && coffee -m $COFFEE_OPTIONS -c app.coffee || echo 'No CoffeeScript app to compile')", "start": "npm run compile:app && node $NODE_APP_OPTIONS app.js", - "test:acceptance:_run": "mocha --recursive --reporter spec --timeout 60000 --exit $@ test/acceptance/js", + "test:acceptance:_run": "mocha --recursive --reporter spec --timeout 30000 --exit $@ test/acceptance/js", "test:acceptance": "npm run compile:app && npm run compile:acceptance_tests && npm run test:acceptance:_run -- --grep=$MOCHA_GREP", "test:unit:_run": "mocha --recursive --reporter spec --exit $@ test/unit/js", "test:unit": "npm run compile:app && npm run compile:unit_tests && npm run test:unit:_run -- --grep=$MOCHA_GREP",