From 72fba4992dcc4dbe38f43d6328e67c0623d74e17 Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 18 Feb 2025 14:49:09 +0100 Subject: [PATCH] perf: refs #6695 only necessary --- Jenkinsfile | 87 ++++++++++++----------------------------------------- 1 file changed, 20 insertions(+), 67 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 3f999d57f..55b4f6046 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -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) {