ci: refs #6695 Docker & Jenkinsfile fixes/refactor
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Juan Ferrer 2025-02-21 11:18:27 +01:00
parent b45ff6817d
commit 20e767991b
3 changed files with 41 additions and 16 deletions

16
Jenkinsfile vendored
View File

@ -106,23 +106,31 @@ pipeline {
stage('E2E') { stage('E2E') {
environment { environment {
CREDENTIALS = credentials('docker-registry') CREDENTIALS = credentials('docker-registry')
CI = 'true' COMPOSE_PROJECT = "${PROJECT_NAME}-${env.BUILD_ID}"
COMPOSE_PARAMS = """
--project-name ${env.COMPOSE_PROJECT}
--project-directory .
--file test/cypress/docker-compose.yml
""".stripIndent()
TZ = 'Europe/Madrid' TZ = 'Europe/Madrid'
COMPOSE_PROJECT = "${PROJECT_NAME}-${env.BRANCH_NAME}-${env.BUILD_ID}".toLowerCase() CI = 'true'
COMPOSE_PARAMS = "--project-name ${env.COMPOSE_PROJECT} --project-directory . --file test/cypress/docker-compose.yml"
} }
steps { steps {
script { script {
def image = docker.build('lilium-dev', '-f docs/Dockerfile.dev docs') def image = docker.build('lilium-dev', '-f docs/Dockerfile.dev docs')
sh "docker-compose ${env.COMPOSE_PARAMS} up -d" sh "docker-compose ${env.COMPOSE_PARAMS} up -d"
image.inside("--network ${env.COMPOSE_PROJECT}_default -e CI -e TZ") { image.inside("--network ${env.COMPOSE_PROJECT}_default -e CI -e TZ") {
sh 'cypress run --browser chromium --spec test/cypress/integration/claim/claimAction.spec.js' sh 'cypress run --spec test/cypress/integration/claim/claimAction.spec.js'
} }
} }
} }
post { post {
always { always {
sh "docker-compose ${env.COMPOSE_PARAMS} down" sh "docker-compose ${env.COMPOSE_PARAMS} down"
junit(
testResults: 'e2e-junitresults.xml',
allowEmptyResults: true
)
} }
} }
} }

View File

@ -2,11 +2,36 @@ import { defineConfig } from 'cypress';
// https://docs.cypress.io/app/tooling/reporters // https://docs.cypress.io/app/tooling/reporters
// https://docs.cypress.io/app/references/configuration // https://docs.cypress.io/app/references/configuration
// https://www.npmjs.com/package/cypress-mochawesome-reporter // https://www.npmjs.com/package/cypress-mochawesome-reporter
const baseUrl = `http://${process.env.CI ? 'front' : 'localhost'}:9000`;
let urlHost,
browser,
reporter,
reporterOptions;
if (process.env.CI) {
urlHost = 'front';
browser = 'chromium';
reporter = 'junit';
reporterOptions = {
mochaFile: 'e2e-junitresults.xml,toConsole=true',
toConsole: true,
};
} else {
urlHost = 'localhost';
reporter = 'cypress-mochawesome-reporter';
reporterOptions = {
charts: true,
reportPageTitle: 'Cypress Inline Reporter',
reportFilename: '[status]_[datetime]-report',
embeddedScreenshots: true,
reportDir: 'test/cypress/reports',
inlineAssets: true,
};
}
export default defineConfig({ export default defineConfig({
e2e: { e2e: {
baseUrl, baseUrl: `http://${urlHost}:9000`,
experimentalStudio: false, // Desactivado para evitar tiempos de espera innecesarios experimentalStudio: false, // Desactivado para evitar tiempos de espera innecesarios
defaultCommandTimeout: 10000, defaultCommandTimeout: 10000,
trashAssetsBeforeRuns: false, trashAssetsBeforeRuns: false,
@ -22,15 +47,8 @@ export default defineConfig({
specPattern: 'test/cypress/integration/**/*.spec.js', specPattern: 'test/cypress/integration/**/*.spec.js',
experimentalRunAllSpecs: true, experimentalRunAllSpecs: true,
watchForFileChanges: true, watchForFileChanges: true,
reporter: 'cypress-mochawesome-reporter', reporter,
reporterOptions: { reporterOptions,
charts: true,
reportPageTitle: 'Cypress Inline Reporter',
reportFilename: '[status]_[datetime]-report',
embeddedScreenshots: true,
reportDir: 'test/cypress/reports',
inlineAssets: true,
},
component: { component: {
componentFolder: 'src', componentFolder: 'src',
testFiles: '**/*.spec.js', testFiles: '**/*.spec.js',

View File

@ -7,7 +7,6 @@ services:
- ./test/cypress/back/datasources.json:/salix/loopback/server/datasources.json - ./test/cypress/back/datasources.json:/salix/loopback/server/datasources.json
depends_on: depends_on:
- db - db
dns_search: .
front: front:
image: lilium-dev:latest image: lilium-dev:latest
command: pnpm exec quasar dev command: pnpm exec quasar dev