From d57b26c8c8663aa8787d339152cf34b6ef89ee33 Mon Sep 17 00:00:00 2001 From: Andil Date: Sat, 8 Aug 2026 00:24:43 +0000 Subject: [PATCH 1/3] test: generate JUnit reports for Jenkins --- backend/jest.config.js | 29 +++++++++++++--------- backend/package-lock.json | 51 +++++++++++++++++++++++++++++++++++++++ backend/package.json | 1 + 3 files changed, 70 insertions(+), 11 deletions(-) diff --git a/backend/jest.config.js b/backend/jest.config.js index 5296fb1..b803d50 100644 --- a/backend/jest.config.js +++ b/backend/jest.config.js @@ -1,26 +1,33 @@ module.exports = { testEnvironment: "node", - // Dossier des tests testMatch: ["**/tests/**/*.test.js"], - // Nettoyage des mocks entre les tests clearMocks: true, - // Timeout (utile pour Prisma / DB) testTimeout: 10000, - // Affichage des logs de test - verbose: true, + verbose: true, - // Couverture de code (optionnel mais bon pour soutenance) collectCoverage: true, coverageDirectory: "coverage", + coverageReporters: [ + "text", + "lcov", + "html" + ], - // Fichiers à ignorer - testPathIgnorePatterns: ["/node_modules/"], + reporters: [ + "default", + [ + "jest-junit", + { + outputDirectory: "./test-results", + outputName: "junit.xml" + } + ] + ], - // Configuration pour Jest avec Supertest - //setupFilesAfterEnv: ["/tests/setup.js"] -}; \ No newline at end of file + testPathIgnorePatterns: ["/node_modules/"] +}; diff --git a/backend/package-lock.json b/backend/package-lock.json index 40a1584..3d2455a 100644 --- a/backend/package-lock.json +++ b/backend/package-lock.json @@ -25,6 +25,7 @@ "cross-env": "^10.1.0", "dotenv": "^17.4.2", "jest": "^30.4.2", + "jest-junit": "^17.0.0", "nodemon": "^3.1.14", "supertest": "^7.2.2" } @@ -4457,6 +4458,22 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/jest-junit": { + "version": "17.0.0", + "resolved": "https://registry.npmjs.org/jest-junit/-/jest-junit-17.0.0.tgz", + "integrity": "sha512-RYWCkq4j59gUXj5DsgbIE7xFBZzu1gtibPhyjSjMmGaOTLnqlXhg7x9zuGCwgbCuMAyoyvk0Mi8wSrRR5uOeLA==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "mkdirp": "^1.0.4", + "strip-ansi": "^6.0.1", + "uuid": "^14.0.0", + "xml": "^1.0.1" + }, + "engines": { + "node": ">=20.0.0" + } + }, "node_modules/jest-leak-detector": { "version": "30.4.1", "resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-30.4.1.tgz", @@ -5375,6 +5392,19 @@ "node": ">=16 || 14 >=14.17" } }, + "node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "dev": true, + "license": "MIT", + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -6836,6 +6866,20 @@ "browserslist": ">= 4.21.0" } }, + "node_modules/uuid": { + "version": "14.0.1", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-14.0.1.tgz", + "integrity": "sha512-6ZxzVpzDXDa3bJWaHilVayA+BH/1zmxCJoVgvmqJnid/gPoKHxUrS/aC/T6LGQtNHT+XHG9fXPJB4d+IrU30Ew==", + "dev": true, + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist-node/bin/uuid" + } + }, "node_modules/v8-to-istanbul": { "version": "9.3.0", "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.3.0.tgz", @@ -6942,6 +6986,13 @@ "node": "^14.17.0 || ^16.13.0 || >=18.0.0" } }, + "node_modules/xml": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/xml/-/xml-1.0.1.tgz", + "integrity": "sha512-huCv9IH9Tcf95zuYCsQraZtWnJvBtLVE0QHMOs8bWyZAFZNDcYjsPq1nEx8jKA9y+Beo9v+7OBPRisQTjinQMw==", + "dev": true, + "license": "MIT" + }, "node_modules/y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", diff --git a/backend/package.json b/backend/package.json index 5a7af54..7d0fd04 100644 --- a/backend/package.json +++ b/backend/package.json @@ -32,6 +32,7 @@ "cross-env": "^10.1.0", "dotenv": "^17.4.2", "jest": "^30.4.2", + "jest-junit": "^17.0.0", "nodemon": "^3.1.14", "supertest": "^7.2.2" }, From 100b75a05ac01bf9b729287df0e9c4da7a4b108d Mon Sep 17 00:00:00 2001 From: Andil Date: Sat, 8 Aug 2026 01:07:31 +0000 Subject: [PATCH 2/3] ci: publish JUnit and coverage reports --- Jenkinsfile | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index e413def..5c175cf 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -162,7 +162,22 @@ pipeline { " ''' } - } + + post { + always { + junit( + testResults: 'backend/test-results/*.xml', + allowEmptyResults: true + ) + + archiveArtifacts( + artifacts: 'backend/coverage/**', + fingerprint: true, + allowEmptyArchive: true + ) + } + } + } stage('Frontend - Lint et Build') { steps { From b15d8458c8f41673260b6857c365933cbeb488bf Mon Sep 17 00:00:00 2001 From: Andil Date: Mon, 10 Aug 2026 19:23:52 +0000 Subject: [PATCH 3/3] refactor: centralize server IP configuration --- Jenkinsfile | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 5c175cf..d57f215 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,6 +9,7 @@ pipeline { environment { REGISTRY = "localhost:5000" + SERVER_IP = "192.168.1.95" BACKEND_IMAGE = "${REGISTRY}/the-tip-top/backend" FRONTEND_IMAGE = "${REGISTRY}/the-tip-top/frontend" @@ -48,7 +49,7 @@ pipeline { env.COMPOSE_PROJECT = 'tiptop-dev' env.DEPLOY_NETWORK = 'tiptop-dev' - env.FRONTEND_API_URL = 'http://192.168.1.23:5001' + env.FRONTEND_API_URL = "http://${SERVER_IP}:5001" } else if (env.BRANCH_NAME.startsWith('release-')) { env.DEPLOY_ENABLED = 'true' @@ -58,7 +59,7 @@ pipeline { env.COMPOSE_PROJECT = 'tiptop-preprod' env.DEPLOY_NETWORK = 'tiptop-preprod' - env.FRONTEND_API_URL = 'http://192.168.1.23:5002' + env.FRONTEND_API_URL = "http://${SERVER_IP}:5002" } else if (env.BRANCH_NAME == 'main') { env.DEPLOY_ENABLED = 'true' @@ -68,7 +69,7 @@ pipeline { env.COMPOSE_PROJECT = 'tiptop-prod' env.DEPLOY_NETWORK = 'tiptop-prod' - env.FRONTEND_API_URL = 'http://192.168.1.23:5003' + env.FRONTEND_API_URL = "http://${SERVER_IP}:5003" } else { env.DEPLOY_ENABLED = 'false' @@ -84,6 +85,8 @@ pipeline { echo "Tag Docker : ${env.IMAGE_TAG}" echo "Environnement : ${env.DEPLOY_ENV}" echo "Déploiement activé : ${env.DEPLOY_ENABLED}" + echo "Serveur : ${env.SERVER_IP}" + echo "API frontend : ${env.FRONTEND_API_URL}" } } } @@ -163,21 +166,21 @@ pipeline { ''' } - post { - always { - junit( - testResults: 'backend/test-results/*.xml', - allowEmptyResults: true - ) + post { + always { + junit( + testResults: 'backend/test-results/*.xml', + allowEmptyResults: true + ) - archiveArtifacts( - artifacts: 'backend/coverage/**', - fingerprint: true, - allowEmptyArchive: true - ) + archiveArtifacts( + artifacts: 'backend/coverage/**', + fingerprint: true, + allowEmptyArchive: true + ) + } } - } - } + } stage('Frontend - Lint et Build') { steps {