Feature/ag 14044 Testing sonar #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: SonarQube Analysis (C#) | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
sonarcloud: | |
name: Analyze with SonarCloud | |
runs-on: ubuntu-latest | |
steps: | |
# 1. Checkout del repositorio | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# 2. Configuración del SDK de .NET | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '6.0' | |
# 3. Instalar SonarScanner para .NET | |
- name: Install SonarScanner for .NET | |
run: dotnet tool install --global dotnet-sonarscanner | |
# 4. Restaurar dependencias | |
- name: Restore dependencies | |
run: dotnet restore | |
# 5. Ejecutar análisis de SonarCloud | |
- name: Run SonarCloud analysis | |
env: | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
run: | | |
dotnet sonarscanner begin \ | |
/k:"autoguru-au_kv-push" \ | |
/o:"your-organization-key" \ | |
/d:sonar.login="${{ secrets.SONAR_TOKEN }}" \ | |
/d:sonar.cs.opencover.reportsPaths="**/coverage.opencover.xml" | |
dotnet build | |
dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}" | |
# 6. Opcional: Ejecutar pruebas y generar cobertura | |
- name: Run tests | |
run: | | |
dotnet test --collect:"XPlat Code Coverage" \ | |
--results-directory ./TestResults |