Skip to content

Commit 2aa55e2

Browse files
Prueba
1 parent b7ad2fc commit 2aa55e2

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

.github/workflows/sonarcloud.yml

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
name: SonarCloud Analysis (.NET 8 + KeyVault)
1313

1414
steps:
15-
# --- 1️⃣ Checkout completo ---
15+
# --- 1️⃣ Checkout ---
1616
- uses: actions/checkout@v4
1717
with:
1818
fetch-depth: 0
@@ -23,7 +23,7 @@ jobs:
2323
with:
2424
creds: ${{ secrets.AZURE_CREDENTIALS }}
2525

26-
# --- 3️⃣ Obtener secretos del Key Vault ---
26+
# --- 3️⃣ Obtener secretos de SonarCloud ---
2727
- name: 🔐 Load SonarCloud secrets
2828
id: get-sonar
2929
run: |
@@ -34,7 +34,7 @@ jobs:
3434
echo "project_key=$PROJECT_KEY" >> $GITHUB_OUTPUT
3535
echo "org=$ORG" >> $GITHUB_OUTPUT
3636
37-
# --- 4️⃣ Preparar entorno ---
37+
# --- 4️⃣ Instalar entornos ---
3838
- name: ⚙️ Setup .NET y Java
3939
uses: actions/setup-dotnet@v4
4040
with:
@@ -43,46 +43,43 @@ jobs:
4343
with:
4444
distribution: 'zulu'
4545
java-version: 17
46-
- name: 🧩 Install utilities
47-
run: sudo apt-get update -y && sudo apt-get install -y jq
4846

4947
# --- 5️⃣ Instalar SonarScanner ---
5048
- name: 🧰 Install SonarScanner
5149
run: |
5250
dotnet tool install --global dotnet-sonarscanner --version 5.*
5351
echo "PATH=$PATH:/home/runner/.dotnet/tools" >> $GITHUB_ENV
5452
55-
# --- 6️⃣ Iniciar análisis SonarCloud ---
53+
# --- 6️⃣ Iniciar análisis (mismo directorio que .sln) ---
5654
- name: ☁️ Begin SonarCloud analysis
55+
working-directory: Unidad1_AsegurandoCodigoFuente
5756
env:
5857
SONAR_TOKEN: ${{ steps.get-sonar.outputs.token }}
5958
SONAR_PROJECT_KEY: ${{ steps.get-sonar.outputs.project_key }}
6059
SONAR_ORGANIZATION: ${{ steps.get-sonar.outputs.org }}
6160
run: |
62-
echo "🚀 Starting SonarCloud analysis..."
6361
dotnet sonarscanner begin \
6462
/k:"$SONAR_PROJECT_KEY" \
6563
/o:"$SONAR_ORGANIZATION" \
6664
/d:sonar.token="$SONAR_TOKEN" \
6765
/d:sonar.host.url="https://sonarcloud.io" \
68-
/d:sonar.sources="Unidad1_AsegurandoCodigoFuente" \
69-
/d:sonar.cs.opencover.reportsPaths="Unidad1_AsegurandoCodigoFuente/**/coverage.cobertura.xml" \
66+
/d:sonar.sources="." \
67+
/d:sonar.cs.opencover.reportsPaths="**/coverage.cobertura.xml" \
7068
/d:sonar.coverage.exclusions="**/bin/**,**/obj/**,**/TestResults/**" \
7169
/d:sonar.exclusions="**/bin/**,**/obj/**,**/*.yml,**/node_modules/**,**/Dockerfile" \
7270
/d:sonar.scm.provider=git
7371
74-
# --- 7️⃣ Compilar la solución ---
75-
- name: 🏗️ Build .NET solution
72+
# --- 7️⃣ Compilar (misma carpeta) ---
73+
- name: 🏗️ Build solution
7674
working-directory: Unidad1_AsegurandoCodigoFuente
7775
run: |
7876
dotnet restore AsegurandoCodigo.sln
7977
dotnet build AsegurandoCodigo.sln --configuration Release --no-restore
8078
81-
# --- 8️⃣ Ejecutar pruebas con cobertura ---
79+
# --- 8️⃣ Pruebas unitarias con cobertura ---
8280
- name: 🧪 Run Unit Tests with Coverage
8381
working-directory: Unidad1_AsegurandoCodigoFuente
8482
run: |
85-
echo "🧪 Ejecutando pruebas..."
8683
dotnet test auth-service.Tests/auth-service.Tests.csproj \
8784
--configuration Release --no-build \
8885
/p:CollectCoverage=true \
@@ -95,13 +92,12 @@ jobs:
9592
/p:CoverletOutputFormat=cobertura \
9693
/p:CoverletOutput=TestResults/
9794
98-
echo "📄 Reportes generados:"
99-
find . -name "coverage.cobertura.xml" || true
95+
echo "📁 Archivos de cobertura generados:"
96+
find . -name "coverage.cobertura.xml"
10097
101-
# --- 9️⃣ Finalizar análisis ---
98+
# --- 9️⃣ Finalizar análisis (misma carpeta) ---
10299
- name: 🧾 End SonarCloud analysis
100+
working-directory: Unidad1_AsegurandoCodigoFuente
103101
env:
104102
SONAR_TOKEN: ${{ steps.get-sonar.outputs.token }}
105-
run: |
106-
echo "✅ Finalizando análisis SonarCloud..."
107-
dotnet sonarscanner end /d:sonar.token="$SONAR_TOKEN"
103+
run: dotnet sonarscanner end /d:sonar.token="$SONAR_TOKEN"

0 commit comments

Comments
 (0)