From f0dce9458de456bca42478a53d4278df0bfb9a16 Mon Sep 17 00:00:00 2001 From: "maxime.rocher" Date: Tue, 4 Feb 2025 10:56:16 +0100 Subject: [PATCH] test CI 12 --- .drone.yml | 69 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 20 deletions(-) diff --git a/.drone.yml b/.drone.yml index fa0f6e8..4eb8bd5 100644 --- a/.drone.yml +++ b/.drone.yml @@ -3,44 +3,75 @@ type: docker name: CI trigger: + branch: + - master event: - push steps: + # 1) Build - name: build image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 commands: - # On se positionne dans le dossier du projet - - cd WF-WebAdmin/WF-WebAdmin - # Restauration des dépendances - - dotnet restore WF-WebAdmin.csproj - # Compilation en mode Release - - dotnet build WF-WebAdmin.csproj -c Release --no-restore - # Publication de l'application dans le dossier build/publish du workspace - - dotnet publish WF-WebAdmin.csproj -c Release --no-restore -o $CI_PROJECT_DIR/build/publish + # Restaurer les dépendances + - dotnet restore WF-WebAdmin.sln + # Compiler en mode Release (sans refaire la restore) + - dotnet build WF-WebAdmin.sln -c Release --no-restore + # 2) Tests - name: tests image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 commands: - - cd WF-WebAdmin/WF-WebAdmin - - dotnet restore WF-WebAdmin.csproj - - dotnet test WF-WebAdmin.csproj --no-restore + - dotnet restore WF-WebAdmin.sln + - dotnet test WF-WebAdmin.sln --no-restore depends_on: [build] - - name: analyze + # 3) Analyse Sonar + Couverture + - name: code-inspection image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dronesonarplugin-dotnet6 + secrets: [ sonar_token ] + environment: + sonar_host: https://codefirst.iut.uca.fr/sonar/ + sonar_token: + from_secret: sonar_token + project_key: wf-webadmin # Clé projet Sonar, adaptez si besoin + coverage_exclusions: 'UnitTesting/**' # Exclusions de couverture, ajustez selon vos besoins commands: - - cd WF-WebAdmin/WF-WebAdmin - - dotnet restore WF-WebAdmin.csproj - - dotnet build WF-WebAdmin.csproj -c Release /p:RunAnalyzers=true - depends_on: [build] + # Restauration + - dotnet restore WF-WebAdmin.sln + + # Début de l'analyse Sonar + - dotnet sonarscanner begin /k:$${project_key} \ + /d:sonar.host.url=$${sonar_host} \ + /d:sonar.coverageReportPaths="coveragereport/SonarQube.xml" \ + /d:sonar.coverage.exclusions=$${coverage_exclusions} \ + /d:sonar.login=$${sonar_token} + + # Compilation + - dotnet build WF-WebAdmin.sln -c Release --no-restore + + # Test avec génération de couverture + - dotnet test WF-WebAdmin.sln --logger trx --no-restore \ + /p:CollectCoverage=true \ + /p:CoverletOutputFormat=cobertura \ + --collect "XPlat Code Coverage" + # Génération du rapport compatible SonarQube + - reportgenerator -reports:"**/coverage.cobertura.xml" -reporttypes:SonarQube -targetdir:"coveragereport" + # Publication (optionnelle) en Release, si besoin pour valider le build final + - dotnet publish WF-WebAdmin.sln -c Release --no-restore -o $CI_PROJECT_DIR/build/release + + # Fin de l'analyse Sonar + - dotnet sonarscanner end /d:sonar.login=$${sonar_token} + depends_on: [build, tests] + + # 4) Construction et push de l'image Docker - name: docker_build image: plugins/docker settings: repo: hub.codefirst.iut.uca.fr/whatthefantasy/wf-webadmin - registry: hub.codefirst.iut.uca.fr + registry: hub.codefirst.iut.uca.fr dockerfile: Docker/Dockerfile tags: - latest @@ -48,6 +79,4 @@ steps: from_secret: docker_username password: from_secret: docker_password - depends_on: [build, tests, analyze] - - + depends_on: [build, tests, code-inspection]