forked from verdnatura/salix-front
ci: refs #6695 refactor Cypress setup in Jenkinsfile and replace local docker-compose with new configuration
This commit is contained in:
parent
29140b821d
commit
06eb1bc8cb
|
@ -93,49 +93,27 @@ pipeline {
|
||||||
NODE_ENV = ""
|
NODE_ENV = ""
|
||||||
CREDENTIALS = credentials('docker-registry')
|
CREDENTIALS = credentials('docker-registry')
|
||||||
}
|
}
|
||||||
stages {
|
steps {
|
||||||
stage('Setup') {
|
script {
|
||||||
steps {
|
def packageJson = readJSON file: 'package.json'
|
||||||
script {
|
env.VERSION = "${packageJson.version}-build${env.BUILD_ID}"
|
||||||
def packageJson = readJSON file: 'package.json'
|
env.NETWORK = "${PROJECT_NAME}-${env.BRANCH_NAME}-${env.BUILD_ID}"
|
||||||
env.VERSION = "${packageJson.version}-build${env.BUILD_ID}"
|
docker.build('cypress-setup:latest', "-f ./test/cypress/Dockerfile .")
|
||||||
env.NETWORK = "${PROJECT_NAME}-${env.BRANCH_NAME}-${env.BUILD_ID}"
|
|
||||||
cleanDockerE2E()
|
|
||||||
// sh "pnpm exec cypress install"
|
|
||||||
// sh "docker build -t cypress-setup:latest -f ./test/cypress/Dockerfile ."
|
|
||||||
docker.build('cypress-setup:latest', "-f ./test/cypress/Dockerfile .")
|
|
||||||
}
|
|
||||||
|
|
||||||
|
sh "docker-compose -p ${env.NETWORK} -f test/cypress/docker-compose.e2e.yml up -d"
|
||||||
|
def networkLowerCase = env.NETWORK.toLowerCase()
|
||||||
|
def image = docker.image('cypress-setup', , "-f ./test/cypress/Dockerfile .")
|
||||||
|
image.inside("""
|
||||||
|
--network ${networkLowerCase}_default \
|
||||||
|
-e TZ=Europe/Madrid \
|
||||||
|
-e DOCKER=true \
|
||||||
|
-e CI=true \
|
||||||
|
-v .:/app \
|
||||||
|
-w /app \
|
||||||
|
""") {
|
||||||
|
sh 'pnpm exec cypress run --browser chromium'
|
||||||
}
|
}
|
||||||
}
|
sh "docker-compose -p ${env.NETWORK} -f test/cypress/docker-compose.e2e.yml down"
|
||||||
stage('Run') {
|
|
||||||
steps {
|
|
||||||
script {
|
|
||||||
sh "docker-compose -p ${env.NETWORK} -f docker-compose.e2e.yml up -d"
|
|
||||||
def networkLowerCase = env.NETWORK.toLowerCase()
|
|
||||||
sh """
|
|
||||||
docker run --rm --name ${env.NETWORK}_cypress \
|
|
||||||
--network ${networkLowerCase}_default \
|
|
||||||
-e TZ=Europe/Madrid \
|
|
||||||
-e DOCKER=true \
|
|
||||||
-e CI=true \
|
|
||||||
-v .:/app \
|
|
||||||
-w /app \
|
|
||||||
cypress-setup \
|
|
||||||
pnpm exec cypress run --browser chromium
|
|
||||||
"""
|
|
||||||
// def containerId = sh(script: "docker ps -q -f name=${env.NETWORK}_cypress", returnStdout: true).trim()
|
|
||||||
|
|
||||||
// echo "Container ID: ${containerId}"
|
|
||||||
|
|
||||||
// checkErrors(containerId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
post {
|
|
||||||
always {
|
|
||||||
cleanDockerE2E()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,22 +153,3 @@ pipeline {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def cleanDockerE2E() {
|
|
||||||
script {
|
|
||||||
sh "docker-compose -p ${env.NETWORK} -f docker-compose.e2e.yml down || true"
|
|
||||||
sh "docker rm -f ${env.NETWORK}_cypress || true"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def checkErrors(String containerId) {
|
|
||||||
echo "Container ID: ${containerId}"
|
|
||||||
def exitCode = sh(script: "docker inspect -f '{{.State.ExitCode}}' ${containerId}", returnStdout: true).trim()
|
|
||||||
echo "Exit code: ${exitCode}"
|
|
||||||
if (exitCode != '0') {
|
|
||||||
def logs = sh(script: "docker logs ${containerId}", returnStdout: true).trim()
|
|
||||||
error("Cypress E2E tests failed with exit code: ${exitCode}\nLogs:\n${logs}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
version: '3.7'
|
|
||||||
services:
|
|
||||||
back:
|
|
||||||
image: registry.verdnatura.es/salix-back:dev
|
|
||||||
volumes:
|
|
||||||
- ./test/cypress/storage:/salix/storage
|
|
||||||
- ./test/cypress/back/datasources.json:/salix/loopback/server/datasources.json
|
|
||||||
depends_on:
|
|
||||||
- vn-database
|
|
||||||
front:
|
|
||||||
image: alexmorenovn/vndev:latest
|
|
||||||
command: quasar dev
|
|
||||||
volumes:
|
|
||||||
- .:/app
|
|
||||||
working_dir: /app
|
|
||||||
environment:
|
|
||||||
- TZ=Europe/Madrid
|
|
||||||
- DOCKER=true
|
|
||||||
e2e:
|
|
||||||
image: cypress-setup:latest
|
|
||||||
command: sh -c "while [ ! -d node_modules/cypress ]; do sleep 1; done && pnpm exec cypress run --browser chromium --spec ${CYPRESS_SPEC:?}"
|
|
||||||
environment:
|
|
||||||
- TZ=Europe/Madrid
|
|
||||||
- DOCKER=true
|
|
||||||
volumes:
|
|
||||||
- .:/app
|
|
||||||
working_dir: /app
|
|
||||||
vn-database:
|
|
||||||
image: registry.verdnatura.es/salix-db:dev
|
|
|
@ -16,14 +16,5 @@ services:
|
||||||
environment:
|
environment:
|
||||||
- TZ=Europe/Madrid
|
- TZ=Europe/Madrid
|
||||||
- DOCKER=true
|
- DOCKER=true
|
||||||
# e2e:
|
|
||||||
# image: cypress-setup:latest
|
|
||||||
# command: sh -c "while [ ! -d node_modules/cypress ]; do sleep 1; done && pnpm exec cypress run --browser chromium"
|
|
||||||
# environment:
|
|
||||||
# - TZ=Europe/Madrid
|
|
||||||
# - DOCKER=true
|
|
||||||
# volumes:
|
|
||||||
# - .:/app
|
|
||||||
# working_dir: /app
|
|
||||||
vn-database:
|
vn-database:
|
||||||
image: registry.verdnatura.es/salix-db:dev
|
image: registry.verdnatura.es/salix-db:dev
|
Loading…
Reference in New Issue