From c1bf9632757144d10ab554aef2316a65a4cfc7c8 Mon Sep 17 00:00:00 2001 From: santidev21 Date: Thu, 1 Oct 2026 15:50:55 -0500 Subject: [PATCH] fix(ci): align coverage scope between the gate and SonarCloud The coverlet gate reported 97.4% but ~89% of its denominator was EF Core migration scaffolding (.Designer.cs / ModelSnapshot), which the integration fixture applies verbatim and therefore counts as ~100% covered: the gate was effectively measuring generated code. Exclude that scaffolding (keeping migration Up/Down logic) so the line gate reflects hand-written code (now ~76.5%). SonarCloud only receives backend opencover coverage in this job, yet it analyzed the Angular frontend and repo scripts too, counting every TS/JS line as 0% covered. That diluted the project coverage to 36.9% and would fail the new-code coverage gate on any frontend PR. Add sonar.coverage.exclusions for the languages this job cannot measure plus the same generated scaffolding. The residual difference between the two numbers is documented in the master plan. --- .github/workflows/sonarcloud.yml | 7 +++++++ coverlet.runsettings | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 7b756d7..e86a5d7 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -77,6 +77,13 @@ jobs: "/d:sonar.token=$SONAR_TOKEN" "/d:sonar.cs.opencover.reportsPaths=**/coverage.opencover.xml" "/d:sonar.cs.vstest.reportsPaths=**/TestResults/*.trx" + # Coverage scope must match what this job can actually measure: only + # backend .NET tests run here, so no coverage is supplied for the + # Angular frontend or the repo scripts. Without this, Sonar counts + # every TS/JS line as 0%-covered and any frontend PR fails the + # new-code coverage gate. Generated EF migration scaffolding is + # excluded too (see coverlet.runsettings); migration Up/Down stays. + "/d:sonar.coverage.exclusions=**/*.ts,**/*.js,**/*.mjs,**/*.html,**/*.scss,**/*.css,**/Migrations/*.Designer.cs,**/Migrations/*ModelSnapshot.cs" ) if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then args+=( diff --git a/coverlet.runsettings b/coverlet.runsettings index 81ebdf2..c8545d8 100644 --- a/coverlet.runsettings +++ b/coverlet.runsettings @@ -7,6 +7,15 @@ cobertura,lcov,opencover [*.Tests]*,[SplitIt.Shared]* Obsolete,GeneratedCodeAttribute,CompilerGeneratedAttribute + + **/Migrations/*.Designer.cs,**/Migrations/*ModelSnapshot.cs 70 line total