You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
WF-WebAdmin/.drone.yml

83 lines
2.7 KiB

kind: pipeline
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:
# 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:
- dotnet restore WF-WebAdmin.sln
- dotnet test WF-WebAdmin.sln --no-restore
depends_on: [build]
# 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:
# 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
dockerfile: Docker/Dockerfile
tags:
- latest
username:
from_secret: docker_username
password:
from_secret: docker_password
depends_on: [build, tests, code-inspection]