Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit aa2e9c9

Browse files
committed
Updated to convert coverage files to sonarqube
1 parent bcac5a2 commit aa2e9c9

4 files changed

Lines changed: 23 additions & 5 deletions

File tree

.github/actions/perform-static-analysis/action.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ runs:
4444
run: |
4545
mkdir -p .sonar/scanner
4646
dotnet tool install dotnet-sonarscanner --tool-path ./.sonar/scanner
47-
dotnet tool install dotnet-coverage --tool-path ./.sonar/scanner
47+
dotnet tool install dotnet-reportgenerator-globaltool --tool-path ./.sonar/scanner
48+
4849
- name: Build and analyze
4950
shell: bash
5051
run: |

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,3 +290,5 @@ __queuestorage__
290290
gitleaks-report.json
291291

292292
coverage/
293+
.sonar/
294+
.sonarqube/

scripts/tests/coverage.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,19 @@ set -euo pipefail
66
: "${SONAR_ORGANISATION_KEY:?SONAR_ORGANISATION_KEY is required}"
77

88
SONAR_SCANNER="./.sonar/scanner/dotnet-sonarscanner"
9-
COVERAGE_FILES=$(find coverage -name '*.coverage.xml' | paste -sd "," -)
9+
REPORT_GENERATOR="./.sonar/scanner/reportgenerator"
1010

11-
$SONAR_SCANNER begin /k:"$SONAR_PROJECT_KEY" /o:"$SONAR_ORGANISATION_KEY" /d:sonar.token="$SONAR_TOKEN" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths="$COVERAGE_FILES"
11+
12+
13+
$SONAR_SCANNER begin /k:"$SONAR_PROJECT_KEY" /o:"$SONAR_ORGANISATION_KEY" /d:sonar.token="$SONAR_TOKEN" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.coverageReportPaths="coverage/converted/SonarQube.xml"
1214

1315
dotnet build src/ServiceLayer.sln
1416

15-
make test-unit
17+
make test-unit ARGS="--no-build"
18+
19+
$REPORT_GENERATOR \
20+
-reports:coverage/**/coverage.cobertura.xml \
21+
-targetdir:coverage/converted \
22+
-reporttypes:SonarQube
1623

1724
$SONAR_SCANNER end /d:sonar.token="$SONAR_TOKEN"

scripts/tests/unit.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
#!/bin/bash
22
set -euo pipefail
33

4+
BUILD_ARGS=""
5+
if [[ "${1:-}" == "--no-build" ]]; then
6+
BUILD_ARGS="--no-build"
7+
fi
8+
49
COVERAGE_DIR="coverage"
510
TEST_PROJECTS=$(find tests -name '*.csproj')
611

@@ -11,5 +16,8 @@ for proj in $TEST_PROJECTS; do
1116
proj_name=$(basename "$proj" .csproj)
1217
out_file="$COVERAGE_DIR/$proj_name.coverage.xml"
1318
echo "🧪 Running coverage for $proj -> $out_file"
14-
dotnet-coverage collect -f xml -o "$out_file" dotnet test "$proj"
19+
dotnet test "$proj" \
20+
$BUILD_ARGS \
21+
--collect:"XPlat Code Coverage" \
22+
--results-directory coverage
1523
done

0 commit comments

Comments
 (0)