Repository navigation
OPS-157454: Upload test coverage to Codacy from CI - #35
Conversation
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>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Coverage variation | Report missing for 2bbf6aa1 |
| Diff coverage | ✅ ∅ diff coverage |
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.
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
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
publishjob currently executes regardless of the outcome of thecoveragejob. 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
| retention-days: 7 | ||
|
|
||
| publish: | ||
| needs: build |
There was a problem hiding this comment.
🔴 HIGH RISK
Update the publish job dependencies to include the coverage job to ensure that packages are only published if all unit tests pass.
| needs: build | |
| needs: [build, coverage] |
| --coverage | ||
| --coverage-settings coverage.config | ||
| --coverage-output-format cobertura | ||
| --coverage-output coverage.cobertura.xml |
There was a problem hiding this comment.
🔴 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.
| --coverage-output coverage.cobertura.xml | |
| --coverage-output TeamViewer.Api.Test/bin/Debug/net10.0/TestResults/coverage.cobertura.xml |
| </Attributes> | ||
| <Sources> | ||
| <Exclude> | ||
| <Source>.*\\obj\\.*</Source> |
There was a problem hiding this comment.
🟡 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.
| <Source>.*\\obj\\.*</Source> | |
| <Source>.*/obj/.*</Source> |
What
Adds a
coveragejob toci.ymlthat runs the tests with code coverage and uploads the Cobertura report to Codacy. It runs onpdl-publicbecause the repository is public.--coverage(Microsoft.Testing.Extensions.CodeCoverage), using acoverage.configmodelled on PanoramicData.NugetManagement.codacy/codacy-coverage-reporter-action@v1using theCODACY_PROJECT_TOKENsecret. The upload hascontinue-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