1- name : CareerPath Workflow - (with SonarQube )
1+ name : CareerPath Workflow - (SonarCloud )
22
33on :
44 push :
@@ -21,61 +21,35 @@ jobs:
2121 build :
2222 runs-on : ubuntu-latest
2323
24- services :
25- sonarqube :
26- image : sonarqube:lts
27- ports :
28- - 9000:9000
29- env :
30- SONAR_ES_BOOTSTRAP_CHECKS_DISABLE : " true"
31- options : >-
32- --health-cmd="exit 0"
33- -e SONAR_ES_BOOTSTRAP_CHECKS_DISABLE=true
34- -e ES_JAVA_OPTS="-Xms512m -Xmx512m"
35-
3624 steps :
37-
25+ # Checkout
3826 - uses : actions/checkout@v5
27+ with :
28+ fetch-depth : 0 # SonarCloud needs full history
3929
30+ # Install .NET
4031 - name : Setup .NET
4132 uses : actions/setup-dotnet@v4
4233 with :
4334 dotnet-version : ${{ env.DOTNET_VERSION }}
4435
45- - name : Wait for SonarQube to start
46- run : |
47- for i in {1..30}; do
48- if curl -s http://localhost:9000 >/dev/null; then
49- echo "SonarQube is up !!!"; break;
50- fi
51- echo "Waiting for SonarQube...."; sleep 10
52- done
53-
54- - name : Install SonarScanner
55- uses : sonarsource/sonarqube-scan-action@v2
56-
57- - name : Begin Sonar Analysis
58- env :
59- SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
60- run : |
61- dotnet sonarscanner begin \
62- /k:"CareerPathApp" \
63- /d:sonar.host.url="http://sonarqube:9000" \
64- /d:sonar.login="${{ secrets.SONAR_TOKEN }}" \
65- /d:sonar.cs.opencover.reportsPaths="**/coverage.opencover.xml"
66-
67- - name : Restore dependencies
36+ # Restore
37+ - name : Restore
6838 run : dotnet restore ./CareerPath.sln
6939
40+ # Build
7041 - name : Build
71- run : dotnet build ./API/API.csproj --configuration Release
42+ run : dotnet build ./API/API.csproj --configuration Release --no-restore
7243
73- - name : Test (Generate Coverage)
44+ # Test + Code Coverage
45+ - name : Test
7446 run : dotnet test ./API.Tests/API.Tests.csproj \
7547 --collect:"XPlat Code Coverage" \
76- --results-directory "./TestResults"
48+ --results-directory "./TestResults" \
49+ --no-build
7750
78- - name : Convert Coverage to OpenCover
51+ # Convert Cobertura → OpenCover
52+ - name : Convert Coverage
7953 run : |
8054 report=$(find ./TestResults -name "coverage.cobertura.xml" | head -n 1)
8155 echo "Found report: $report"
@@ -85,26 +59,22 @@ jobs:
8559 -targetdir:coveragereport \
8660 -reporttypes:opencover
8761
88- - name : End Sonar Analysis
89- env :
90- SONAR_TOKEN : ${{ secrets.SONAR_TOKEN }}
91- run : |
92- dotnet sonarscanner end \
93- /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
94-
62+ # Cleanup publish
9563 - name : Clean API publish output
9664 run : rm -rf ${{ env.BUILD_OUTPUT }}
9765
98- - name : Publish
66+ # Publish App
67+ - name : Publish Project
9968 run : dotnet publish ./API/API.csproj -c Release -o ${{ env.BUILD_OUTPUT }} --no-build
10069
101- - name : Upload artifact
70+ # Upload artifacts
71+ - name : Upload Build Artifact
10272 uses : actions/upload-artifact@v4
10373 with :
10474 name : dotnet-app
10575 path : ${{ env.BUILD_OUTPUT }}
10676
107- - name : Upload Coverage Report (optional)
77+ - name : Upload Coverage Report
10878 uses : actions/upload-artifact@v4
10979 with :
11080 name : code-coverage
0 commit comments