Skip to content

OPS-157454: Upload test coverage to Codacy from CI - #35

Merged
davidnmbond merged 1 commit into
mainfrom
ci/codacy-coverage
Sep 27, 2026
Merged

davidnmbond merged 1 commit into
mainfrom
ci/codacy-coverage

Conversation

@davidnmbond

Copy link
Copy Markdown
Contributor

What

Adds a coverage job to ci.yml that runs the tests with code coverage and uploads the Cobertura report to Codacy. It runs on pdl-public because the repository is public.

  • Runs the xunit v3 Microsoft.Testing.Platform test executable with --coverage (Microsoft.Testing.Extensions.CodeCoverage), using a coverage.config modelled on PanoramicData.NugetManagement.
  • Uploads with codacy/codacy-coverage-reporter-action@v1 using the CODACY_PROJECT_TOKEN secret. The upload has continue-on-error: true, and the report is also kept as a 7-day artifact.

The test project gains UseMicrosoftTestingPlatformRunner so the test executable accepts --coverage; it already referenced Microsoft.Testing.Extensions.CodeCoverage.

Excluded tests

Everything outside the TeamViewer.Api.Test.UnitTests namespace. The only other tests are in the IntegrationTests namespace (91 tests), and they call the live TeamViewer API with credentials from user secrets. The coverage job uses FullyQualifiedName~UnitTests, the same convention and filter that build.yml already uses. 119 unit tests run.

Coverage

Local line coverage in a clean Linux container (mcr.microsoft.com/dotnet/sdk:10.0.401, no user secrets) is 69.4%.

Jira: https://jira.panoramicdata.com/browse/OPS-157454

🤖 Generated with Claude Code

Adds a coverage job on pdl-public that runs the test executable with
Microsoft.Testing.Extensions.CodeCoverage and uploads the Cobertura report
to Codacy.

The test project gains UseMicrosoftTestingPlatformRunner so the test
executable accepts --coverage; it already referenced
Microsoft.Testing.Extensions.CodeCoverage.

Excluded: Everything outside the TeamViewer.Api.Test.UnitTests namespace.
The only other tests are in the IntegrationTests namespace (91 tests),
and they call the live TeamViewer API with credentials from user secrets.
The coverage job uses FullyQualifiedName~UnitTests, the same convention
and filter that build.yml already uses. 119 unit tests run.
Local line coverage (clean Linux container): 69.4%.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@codacy-production

codacy-production Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Coverage ∅ diff coverage

Metric Results
Coverage variation Report missing for 2bbf6aa1
Diff coverage ✅ ∅ diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (2bbf6aa) Report Missing Report Missing Report Missing
Head commit (62d9e5e) 193 134 69.43%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#35) 0 0 ∅ (not applicable)

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

1 Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@codacy-production codacy-production Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

The PR introduces automated code coverage reporting but contains critical implementation flaws that will cause the CI workflow to fail. While Codacy's top-level analysis indicates the project is 'up to standards', the implementation of the coverage job features a path mismatch between report generation and the subsequent upload steps. Additionally, the publish job is not dependent on the coverage job, meaning packages could be published even if tests fail, bypassing an essential quality gate. Finally, the coverage exclusion regex in coverage.config uses Windows-style backslashes which will not function on the Linux-based runners used in this CI pipeline.

About this PR

  • A fundamental path discrepancy exists in the coverage job. The test runner produces a file in the repository root, but the Codacy and artifact steps expect it in a nested build directory. This will lead to 'file not found' errors.
  • The CI workflow allows for a quality gate bypass: the publish job currently executes regardless of the outcome of the coverage job. This could lead to the publication of NuGet packages from builds with failing tests.

Test suggestions

  • Unit test execution with coverage collection enabled via Microsoft.Testing.Platform
  • Application of module and attribute exclusions specified in coverage.config
  • Upload of Cobertura reports to the Codacy service
  • Persistence of the coverage report as a CI build artifact

TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback

Comment thread .github/workflows/ci.yml
retention-days: 7

publish:
needs: build

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 HIGH RISK

Update the publish job dependencies to include the coverage job to ensure that packages are only published if all unit tests pass.

Suggested change
needs: build
needs: [build, coverage]

Comment thread .github/workflows/ci.yml
--coverage
--coverage-settings coverage.config
--coverage-output-format cobertura
--coverage-output coverage.cobertura.xml

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 HIGH RISK

The coverage output filename specified here ('coverage.cobertura.xml') will cause the file to be created in the repository root. However, the subsequent Codacy upload (line 95) and artifact upload (line 103) steps look for the file at 'TeamViewer.Api.Test/bin/Debug/net10.0/TestResults/coverage.cobertura.xml'. Specify the full target path in the test command to resolve this.

Suggested change
--coverage-output coverage.cobertura.xml
--coverage-output TeamViewer.Api.Test/bin/Debug/net10.0/TestResults/coverage.cobertura.xml

Comment thread coverage.config
</Attributes>
<Sources>
<Exclude>
<Source>.*\\obj\\.*</Source>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 MEDIUM RISK

The exclusion regex for the 'obj' folder uses backslashes, which will not match paths on the Linux runner used in this CI workflow. Update the separators to forward slashes to ensure generated code in the 'obj' directory is correctly excluded from the coverage metrics.

Suggested change
<Source>.*\\obj\\.*</Source>
<Source>.*/obj/.*</Source>

@davidnmbond
davidnmbond merged commit cbdc4a3 into main Sep 27, 2026
7 of 9 checks passed
@davidnmbond
davidnmbond deleted the ci/codacy-coverage branch September 27, 2026 22:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant