Files
sql-utilities/.gitea/workflows/sonarqube.yml
T
Thom LambandClaude Opus 4.7 8def714683
SonarQube Analysis / sonarqube (pull_request) Successful in 4m23s
ci(sonar): collect and upload OpenCover coverage from CI scan
The Gitea Actions sonarqube workflow was running `dotnet build` and
sonarscanner begin/end without ever invoking `dotnet test`, so Sonar
was reporting coverage = 0% on the server despite a 1180-test suite
already exercising the code locally. `scan-sonar.ps1` (the local
equivalent) has had the coverage flags + test step the whole time —
this aligns CI with it.

Changes:

- `sonarscanner begin` now passes
  `/d:sonar.cs.opencover.reportsPaths="tests/**/TestResults/**/coverage.opencover.xml"`
  so the scanner picks up the per-project OpenCover reports coverlet
  emits, and
  `/d:sonar.coverage.exclusions="tests/**,**/*.Tests/**"` so the tests
  themselves don't count toward the coverage denominator.
- The dormant step 8 (a disabled `if: false` curl-debug block from an
  earlier auth-troubleshooting session) is replaced with the actual
  test run: `dotnet test ... --no-build --settings
  coverlet.runsettings --collect "XPlat Code Coverage"`.
- Step 9 (`sonarscanner end`) unchanged — it now has coverage data
  available to upload.

Once this lands, the next scan will surface the *real* coverage number
for sql-utilities. Until we see that number we don't know which files
actually need test investment vs. were already covered by the existing
suite.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-27 15:30:47 -05:00

69 lines
2.1 KiB
YAML

name: SonarQube Analysis
on:
push:
branches: [main, master]
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:
jobs:
sonarqube:
runs-on: ubuntu-latest
steps:
- name: 1. Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 2. Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: 3. Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
- name: 4. Install SonarScanner for .NET
run: |
dotnet tool install --global dotnet-sonarscanner
echo "$HOME/.dotnet/tools" >> $GITHUB_PATH
- name: 5. Debug token sanity check
if: false
run: |
curl -s -w "\nHTTP %{http_code}\n" \
-u "${{ secrets.SONAR_TOKEN }}:" \
"${{ secrets.SONAR_HOST_URL }}/api/plugins/installed" | head -5
echo "---"
curl -s -w "\nHTTP %{http_code}\n" \
-u "${{ secrets.SONAR_TOKEN }}:" \
"${{ secrets.SONAR_HOST_URL }}/api/authentication/validate"
- name: 6. SonarScanner Begin
run: |
dotnet sonarscanner begin \
/k:"sql-utilities" \
/d:sonar.host.url="${{ secrets.SONAR_HOST_URL }}" \
/d:sonar.login="${{ secrets.SONAR_TOKEN }}" \
/d:sonar.exclusions="**/bin/**,**/obj/**" \
/d:sonar.coverage.exclusions="tests/**,**/*.Tests/**" \
/d:sonar.cs.opencover.reportsPaths="tests/**/TestResults/**/coverage.opencover.xml" \
/d:sonar.verbose=true
- name: 7. Build
run: dotnet build Strata.SqlTools.QueryBreakdown.sln --configuration Release
- name: 8. Test with coverage
run: |
dotnet test Strata.SqlTools.QueryBreakdown.sln \
--configuration Release --no-build \
--settings coverlet.runsettings \
--collect "XPlat Code Coverage"
- name: 9. SonarScanner End
run: dotnet sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"