Merge branch 'test'
gitea/salix/master This commit looks good Details

This commit is contained in:
Juan Ferrer 2019-12-22 15:12:57 +01:00
commit c8e4615433
4 changed files with 40 additions and 60 deletions

58
Jenkinsfile vendored
View File

@ -8,19 +8,17 @@ pipeline {
environment {
PROJECT_NAME = 'salix'
REGISTRY = 'registry.verdnatura.es'
DOCKER_HOST_1 = 'vch1.verdnatura.es'
DOCKER_HOST_2 = 'vch2.verdnatura.es'
PORT_MASTER_FRONT = '5002'
PORT_MASTER_BACK = '3001-3002'
PORT_MASTER_BACK = '3001'
PORT_TEST_FRONT = '5001'
PORT_TEST_BACK = '4001-4002'
PORT_TEST_BACK = '4001'
TAG = "${env.BRANCH_NAME}"
}
stages {
stage('Checkout') {
steps {
script {
env.COMPOSE_PROJECT_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}"
env.STACK_NAME = "${env.PROJECT_NAME}-${env.BRANCH_NAME}"
if (!env.GIT_COMMITTER_EMAIL) {
env.COMMITTER_EMAIL = sh(
@ -65,21 +63,26 @@ pipeline {
}
}
stage('Test') {
when { not { anyOf {
branch 'test'
branch 'master'
}}}
environment {
NODE_ENV = ""
FIREFOX_BIN = "/opt/firefox/firefox-bin"
}
parallel {
stage('Frontend') {
steps {
nodejs('node-lts') {
sh 'jest --ci --reporters=default --reporters=jest-junit --maxWorkers=1'
}
}
}
stage('Backend') {
steps {
nodejs('node-lts') {
sh 'gulp backTestDockerOnce --junit --random'
}
}
}
}
}
stage('Build') {
when { anyOf {
branch 'test'
@ -103,32 +106,8 @@ pipeline {
branch 'test'
branch 'master'
}}
environment {
DOCKER_TLS_VERIFY = 1
}
parallel {
stage('Host 1') {
environment {
DOCKER_HOST = "tcp://${env.DOCKER_HOST_1}:2376"
}
steps {
withCredentials([dockerCert(credentialsId: 'docker', variable: 'DOCKER_CERT_PATH')]) {
sh 'docker-compose pull'
sh 'docker-compose up -d --scale back=2'
}
}
}
stage('Host 2') {
environment {
DOCKER_HOST = "tcp://${env.DOCKER_HOST_2}:2376"
}
steps {
withCredentials([dockerCert(credentialsId: 'docker', variable: 'DOCKER_CERT_PATH')]) {
sh 'docker-compose pull'
sh 'docker-compose up -d --scale back=2'
}
}
}
sh "docker stack deploy --with-registry-auth --compose-file docker-compose.yml ${env.STACK_NAME}"
}
}
stage('Database') {
@ -147,15 +126,6 @@ pipeline {
sh 'db/import-changes.sh -f $NODE_ENV'
}
}
stage('Cleanup') {
when { anyOf {
branch 'test'
branch 'master'
}}
steps {
sh 'docker logout $REGISTRY'
}
}
}
post {
always {

View File

@ -10,6 +10,8 @@ services:
- ${PORT_FRONT}:80
links:
- back
deploy:
replicas: 3
back:
image: registry.verdnatura.es/salix-back:${TAG}
restart: unless-stopped
@ -19,6 +21,8 @@ services:
environment:
- NODE_ENV
volumes:
- /containers/salix:/etc/salix
- /mnt/storage/containers/salix:/etc/salix
- /mnt/storage/pdfs:/var/lib/salix/pdfs
- /mnt/storage/dms:/var/lib/salix/dms
deploy:
replicas: 6

View File

@ -7,11 +7,7 @@ server {
client_max_body_size 250M;
root /salix/dist;
error_page 404 = @notfound;
location @notfound {
return 302 /;
}
location / {
autoindex on;
}

View File

@ -110,17 +110,27 @@ backTestOnce.description = `Runs the backend tests once, can receive --junit arg
async function backTestDockerOnce() {
let containerId = await docker();
try {
await backTestOnce();
} catch (e) {
throw e;
} finally {
if (argv['random'])
await execP(`docker rm -fv ${containerId}`);
}
}
backTestDockerOnce.description = `Runs backend tests using in site container once`;
async function backTestDocker() {
let containerId = await docker();
try {
await backTest();
} catch (e) {
throw e;
} finally {
if (argv['random'])
await execP(`docker rm -fv ${containerId}`);
}
}
backTestDocker.description = `Runs backend tests restoring fixtures first`;