build: refs #6695 add unit test
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Alex Moreno 2025-01-31 12:42:54 +01:00
parent e9d4d79da0
commit 8dd2659d9f
1 changed files with 60 additions and 35 deletions

95
Jenkinsfile vendored
View File

@ -66,50 +66,75 @@ pipeline {
sh 'pnpm install --prefer-offline' sh 'pnpm install --prefer-offline'
} }
} }
stage('E2E') { stage('Test') {
when { when {
expression { !PROTECTED_BRANCH } expression { !PROTECTED_BRANCH }
} }
environment { environment {
CREDENTIALS = credentials('docker-registry') NODE_ENV = ""
} }
steps { parallel{
script { stage('Unit') {
def packageJson = readJSON file: 'package.json' steps {
env.VERSION = "${packageJson.version}-build${env.BUILD_ID}" sh 'pnpm run test:unit:ci'
}
post {
always {
junit(
testResults: 'junitresults.xml',
allowEmptyResults: true
)
}
}
} }
// sh "docker network rm e2e_default || true" stage('E2E') {
// sh 'docker network create e2e_default || true' when {
sh 'rm -rf salix' expression { !PROTECTED_BRANCH }
sh 'git clone https://gitea.verdnatura.es/verdnatura/salix.git' }
// Db environment {
sh 'cd salix && pnpm i --prefer-offline @verdnatura/myt && npx myt run -t -d' CREDENTIALS = credentials('docker-registry')
// Backend }
sh 'docker build -f ./salix/back/Dockerfile -t back ./salix' steps {
sh 'docker run -d --name salix_e2e --net=host -v $(pwd)/test/cypress/storage:/salix/storage back' script {
// Frontend def packageJson = readJSON file: 'package.json'
sh 'quasar build' env.VERSION = "${packageJson.version}-build${env.BUILD_ID}"
sh 'docker-compose -f docker-compose.e2e.yml build front' }
sh 'docker-compose -f docker-compose.e2e.yml up -d front' // sh "docker network rm e2e_default || true"
// E2E // sh 'docker network create e2e_default || true'
sh 'docker-compose -f docker-compose.e2e.yml build e2e' sh 'rm -rf salix'
sh 'docker-compose -f docker-compose.e2e.yml up e2e' sh 'git clone https://gitea.verdnatura.es/verdnatura/salix.git'
} // Db
post { sh 'cd salix && pnpm i --prefer-offline @verdnatura/myt && npx myt run -t -d'
failure { // Backend
echo 'Removing containers...' sh 'docker build -f ./salix/back/Dockerfile -t back ./salix'
sh 'docker rm -f vn-database || true' sh 'docker run -d --name salix_e2e --net=host -v $(pwd)/test/cypress/storage:/salix/storage back'
sh 'docker rm -f salix_e2e || true' // Frontend
sh 'docker-compose -f docker-compose.e2e.yml down || true' sh 'quasar build'
} sh 'docker-compose -f docker-compose.e2e.yml build front'
always { sh 'docker-compose -f docker-compose.e2e.yml up -d front'
junit( // E2E
testResults: 'junitresults.xml', sh 'docker-compose -f docker-compose.e2e.yml build e2e'
allowEmptyResults: true sh 'docker-compose -f docker-compose.e2e.yml up e2e'
) }
post {
failure {
echo 'Removing containers...'
sh 'docker rm -f vn-database || true'
sh 'docker rm -f salix_e2e || true'
sh 'docker-compose -f docker-compose.e2e.yml down || true'
}
always {
junit(
testResults: 'junitresults.xml',
allowEmptyResults: true
)
}
}
} }
} }
} }
stage('Build') { stage('Build') {
when { when {
expression { PROTECTED_BRANCH } expression { PROTECTED_BRANCH }