Update with build scripts version 1.0.0

This commit is contained in:
James Allen 2018-01-29 12:07:35 +00:00
parent a59dc9e149
commit bd581d069b
7 changed files with 156 additions and 20 deletions

View file

@ -1 +1 @@
4.2.1
4.2.1

View file

@ -1,10 +1,11 @@
pipeline {
String cron_string = BRANCH_NAME == "master" ? "@daily" : ""
pipeline {
agent any
triggers {
pollSCM('* * * * *')
cron('@daily')
cron(cron_string)
}
stages {
@ -17,15 +18,17 @@ pipeline {
}
}
steps {
// we need to disable logallrefupdates, else git clones during the npm install will require git to lookup the user id
// which does not exist in the container's /etc/passwd file, causing the clone to fail.
// we need to disable logallrefupdates, else git clones
// during the npm install will require git to lookup the
// user id which does not exist in the container's
// /etc/passwd file, causing the clone to fail.
sh 'git config --global core.logallrefupdates false'
sh 'rm -fr node_modules'
sh 'rm -rf node_modules'
sh 'npm install && npm rebuild'
sh 'npm install --quiet grunt-cli'
}
}
stage('Compile and Test') {
stage('Compile') {
agent {
docker {
image 'node:4.2.1'
@ -33,28 +36,37 @@ pipeline {
}
}
steps {
sh 'node_modules/.bin/grunt coffee'
sh 'node_modules/.bin/grunt compile:acceptance_tests'
sh 'NODE_ENV=development node_modules/.bin/grunt test:unit'
sh 'npm run compile:all'
}
}
stage('Unit Tests') {
steps {
sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make test_unit'
}
}
stage('Acceptance Tests') {
steps {
sh 'docker pull sharelatex/acceptance-test-runner'
sh 'docker run --rm -v $(pwd):/app sharelatex/acceptance-test-runner'
sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make test_acceptance'
}
}
stage('Package') {
stage('Package and publish build') {
steps {
sh 'echo ${BUILD_NUMBER} > build_number.txt'
sh 'touch build.tar.gz' // Avoid tar warning about files changing during read
sh 'tar -czf build.tar.gz --exclude=build.tar.gz --exclude-vcs .'
}
}
stage('Publish') {
steps {
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")
}
}
}
stage('Publish build number') {
steps {
sh 'echo ${BRANCH_NAME}-${BUILD_NUMBER} > build_number.txt'
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")
}
@ -63,6 +75,10 @@ pipeline {
}
post {
always {
sh 'DOCKER_COMPOSE_FLAGS="-f docker-compose.ci.yml" make test_clean'
}
failure {
mail(from: "${EMAIL_ALERT_FROM}",
to: "${EMAIL_ALERT_TO}",

29
services/chat/Makefile Normal file
View file

@ -0,0 +1,29 @@
# 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.0.0
BUILD_NUMBER ?= local
BRANCH_NAME ?= $(shell git rev-parse --abbrev-ref HEAD)
PROJECT_NAME = chat
DOCKER_COMPOSE_FLAGS ?= -f docker-compose.yml
DOCKER_COMPOSE := docker-compose ${DOCKER_COMPOSE_FLAGS}
clean:
rm -f app.js
rm -rf app/js
rm -rf test/unit/js
rm -rf test/acceptance/js
test: test_unit test_acceptance
test_unit:
@[ -d test/unit ] && $(DOCKER_COMPOSE) run --rm test_unit -- ${MOCHA_ARGS} || echo "chat has no unit tests"
test_acceptance: test_clean # clear the database before each acceptance test run
@[ -d test/acceptance ] && $(DOCKER_COMPOSE) run --rm test_acceptance -- ${MOCHA_ARGS} || echo "chat has no acceptance tests"
test_clean:
$(DOCKER_COMPOSE) down
.PHONY: clean test test_unit test_acceptance test_clean build publish

View file

@ -0,0 +1,33 @@
# 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.0.0
version: "2"
services:
test_unit:
image: node:4.2.1
volumes:
- .:/app
working_dir: /app
entrypoint: npm run test:unit:run
test_acceptance:
image: node:4.2.1
volumes:
- .:/app
working_dir: /app
environment:
REDIS_HOST: redis
MONGO_HOST: mongo
depends_on:
- redis
- mongo
entrypoint: npm run test:acceptance:run
redis:
image: redis
mongo:
image: mongo:3.4

View file

@ -0,0 +1,33 @@
# 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.0.0
version: "2"
services:
test_unit:
image: node:4.2.1
volumes:
- .:/app
working_dir: /app
entrypoint: npm run test:unit
test_acceptance:
image: node:4.2.1
volumes:
- .:/app
environment:
REDIS_HOST: redis
MONGO_HOST: mongo
depends_on:
- redis
- mongo
working_dir: /app
entrypoint: npm run test:acceptance
redis:
image: redis
mongo:
image: mongo:3.4

View file

@ -0,0 +1,15 @@
{
"ignore": [
".git",
"node_modules/"
],
"verbose": true,
"execMap": {
"js": "npm run start"
},
"watch": [
"app/coffee/",
"app.coffee"
],
"ext": "coffee"
}

View file

@ -8,7 +8,15 @@
},
"scripts": {
"compile:app": "coffee -o app/js -c app/coffee && coffee -c app.coffee",
"start": "npm run compile:app && node app.js"
"start": "npm run compile:app && node app.js",
"test:acceptance:run": "mocha --recursive --reporter spec --timeout 15000 --exit $@ test/acceptance/js",
"test:acceptance": "npm run compile:app && npm run compile:acceptance_tests && npm run test:acceptance:run -- $@",
"test:unit:run": "mocha --recursive --reporter spec $@ test/unit/js",
"test:unit": "npm run compile:app && npm run compile:unit_tests && npm run test:unit:run -- $@",
"compile:unit_tests": "[ -e test/unit ] && coffee -o test/unit/js -c test/unit/coffee || echo 'No unit tests to compile'",
"compile:acceptance_tests": "[ -e test/acceptance ] && coffee -o test/acceptance/js -c test/acceptance/coffee || echo 'No acceptance tests to compile'",
"compile:all": "npm run compile:app && npm run compile:unit_tests && npm run compile:acceptance_tests",
"nodemon": "nodemon --config nodemon.json"
},
"dependencies": {
"async": "0.2.9",
@ -37,6 +45,8 @@
"grunt-nodemon": "~0.1.2",
"grunt-notify": "~0.2.16",
"grunt-plato": "~0.2.1",
"mocha": "^4.1.0",
"nodemon": "^1.14.11",
"sandboxed-module": "",
"sinon": "",
"timekeeper": ""