Publish code coverage to Codecov (MTP) - #96
Conversation
CI ran plain `dotnet test` with no coverage collection, so there was no coverage measurement despite coverlet.collector being referenced. Collect XPlat Code Coverage into a results directory and upload the cobertura report as a build artifact for visibility. Validated with actionlint. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
📝 WalkthroughWalkthroughThe test project now includes Microsoft code coverage support. The test workflow generates Cobertura reports and uploads them to Codecov. Codecov checks are informational, and pull request comments are disabled. ChangesCoverage reporting
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
# Conflicts: # .github/workflows/test.yaml
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/test.yaml:
- Around line 28-34: Add an actions/upload-artifact step alongside the Codecov
upload, targeting coverage-results/coverage.cobertura.xml with artifact name
coverage and if-no-files-found set to error. Keep the existing Codecov upload
behavior unchanged unless needed to ensure the required artifact is created and
missing reports fail the workflow.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 547e75df-c368-45fd-976e-15e1721c37f0
📒 Files selected for processing (4)
.github/workflows/test.yamlDirectory.Packages.propscodecov.ymlsrc/SIL.Harmony.Tests/SIL.Harmony.Tests.csproj
| - name: Upload coverage to Codecov | ||
| if: ${{ !cancelled() }} | ||
| uses: codecov/codecov-action@v5 | ||
| with: | ||
| token: ${{ secrets.CODECOV_TOKEN }} | ||
| files: ${{ github.workspace }}/coverage-results/coverage.cobertura.xml | ||
| fail_ci_if_error: false |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n -C 3 \
'codecov-action|upload-artifact|coverage\.cobertura\.xml|name: coverage|if-no-files-found|fail_ci_if_error' \
.github/workflows/test.yamlRepository: sillsdev/harmony
Length of output: 838
Add a required coverage GitHub artifact and fail when the report is missing.
codecov/codecov-action@v5 uploads coverage to Codecov and does not create a coverage GitHub Actions artifact. With fail_ci_if_error: false, the upload also does not fail the workflow when the Cobertura report is missing or invalid. Add an actions/upload-artifact step for ${{ github.workspace }}/coverage-results/coverage.cobertura.xml with name: coverage and if-no-files-found: error, or change the destination as required.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In @.github/workflows/test.yaml around lines 28 - 34, Add an
actions/upload-artifact step alongside the Codecov upload, targeting
coverage-results/coverage.cobertura.xml with artifact name coverage and
if-no-files-found set to error. Keep the existing Codecov upload behavior
unchanged unless needed to ensure the required artifact is created and missing
reports fail the workflow.
AI-generated summary
Reworks the coverage PR for the Microsoft.Testing.Platform migration and publishes coverage as a check (no PR comment), via Codecov.
Microsoft.Testing.Extensions.CodeCoveragepackage (pinned18.3.1inDirectory.Packages.props) and appends MTP coverage args to the test run —-- --coverage --coverage-output-format cobertura --coverage-output coverage.cobertura.xml --results-directory <workspace>/coverage-results. (The previous--collect:"XPlat Code Coverage"approach was a VSTest/coverlet mechanism and no longer applies under MTP.)codecov/codecov-action@v5uploads the cobertura file. Codecov postscodecov/projectandcodecov/patchstatus checks on the PR.codecov.ymlsetscomment: false; the project/patch statuses areinformational: true, so they report coverage without blocking merges.fail_ci_if_error: falseso a Codecov hiccup (or missing token before setup) doesn't fail the build.Net change vs main is four files:
test.yaml,Directory.Packages.props,SIL.Harmony.Tests.csproj,codecov.yml.Required one-time setup (repo admin)
This won't post checks until Codecov is connected:
sillsdev/harmonyrepository.CODECOV_TOKEN(Settings → Secrets and variables → Actions).Until then the upload step no-ops (it won't fail CI). Once flipped, flip
fail_ci_if_errortotrueif you want upload failures to gate.Test plan
actionlintpasses on the workflow.coverage-results/coverage.cobertura.xml.Summary by CodeRabbit
Tests
Chores