perf: refs #6695 only necessary
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Alex Moreno 2025-02-18 14:49:09 +01:00
parent 1772c31047
commit 72fba4992d
1 changed files with 20 additions and 67 deletions

87
Jenkinsfile vendored
View File

@ -66,25 +66,25 @@ pipeline {
sh 'pnpm install --prefer-offline'
}
}
// stage('Test: Unit') {
// when {
// expression { !PROTECTED_BRANCH }
// }
// environment {
// NODE_ENV = ""
// }
// steps {
// sh 'pnpm run test:unit:ci'
// }
// post {
// always {
// junit(
// testResults: 'junitresults.xml',
// allowEmptyResults: true
// )
// }
// }
// }
stage('Test: Unit') {
when {
expression { !PROTECTED_BRANCH }
}
environment {
NODE_ENV = ""
}
steps {
sh 'pnpm run test:unit:ci'
}
post {
always {
junit(
testResults: 'junitresults.xml',
allowEmptyResults: true
)
}
}
}
stage('Test: E2E') {
when {
expression { !PROTECTED_BRANCH }
@ -102,8 +102,7 @@ pipeline {
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 ."
// sh "docker network create ${env.NETWORK} || true"
// sh "docker build -t cypress-setup:latest -f ./test/cypress/Dockerfile ."
}
}
@ -165,7 +164,6 @@ pipeline {
def cleanDockerE2E() {
script {
def projectBranch = "${PROJECT_NAME}-${env.BRANCH_NAME}".toLowerCase()
// STOP AND REMOVE
sh """
docker ps -a --filter 'name=^${projectBranch}' | awk 'NR>1 {print \"\$1\"}' | xargs -r -I {} sh -c 'docker stop {} && docker rm -v {}' || true
"""
@ -176,51 +174,6 @@ def cleanDockerE2E() {
}
}
// def runTestsInParallel(int numParallelGroups) {
// def folders = sh(script: "ls -d test/cypress/integration/*/ || echo ''", returnStdout: true).trim().split('\n').findAll { it }
// if (folders.isEmpty()) {
// echo "No se encontraron carpetas de pruebas."
// return
// }
// // Divide las carpetas en grupos para paralelizar
// def groupSize = Math.ceil((folders.size() as double) / numParallelGroups).toInteger()
// def groups = folders.collate(groupSize)
// def tasks = [:]
// groups.eachWithIndex { group, index ->
// tasks["parallel_group_${index + 1}"] = {
// stage("Parallel Group ${index + 1}") {
// script {
// group.each { testFolder ->
// def folderName = testFolder.replaceAll('test/cypress/integration/', '').replaceAll('/', '')
// folderName = folderName.replaceAll('[^a-zA-Z0-9_-]', '') // Sanitización de nombres
// stage("Run ${folderName}") {
// try {
// env.CYPRESS_SPEC = "test/cypress/integration/${folderName}/**/*.spec.js"
// sh "docker-compose -p ${env.NETWORK}_${folderName} -f docker-compose.e2e.yml up -d back"
// sh "docker-compose -p ${env.NETWORK}_${folderName} -f docker-compose.e2e.yml up -d front"
// sh "CYPRESS_SPEC=test/cypress/integration/${folderName}/**/*.spec.js docker-compose -p ${env.NETWORK}_${folderName} -f docker-compose.e2e.yml up e2e"
// checkErrors(folderName)
// } catch (Exception e) {
// echo "Error en la ejecución de ${folderName}: ${e.message}"
// currentBuild.result = 'UNSTABLE'
// } finally {
// sh "docker-compose -p ${env.NETWORK}_${folderName} -f docker-compose.e2e.yml down || true"
// }
// }
// }
// }
// }
// }
// }
// parallel tasks
// }
def checkErrors(String folderName){
def containerId = sh(script: "docker-compose -p ${env.NETWORK}_${folderName} -f docker-compose.e2e.yml ps -q e2e", returnStdout: true).trim()
if (containerId) {