Skip to content

Publish code coverage to Codecov (MTP) - #96

Merged
hahn-kev merged 2 commits into
mainfrom
ci/collect-coverage
Aug 7, 2026
Merged

Publish code coverage to Codecov (MTP)#96
hahn-kev merged 2 commits into
mainfrom
ci/collect-coverage

Conversation

@hahn-kev-bot

@hahn-kev-bot hahn-kev-bot commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

AI-generated summary

Reworks the coverage PR for the Microsoft.Testing.Platform migration and publishes coverage as a check (no PR comment), via Codecov.

  • Collect coverage under MTP: adds the Microsoft.Testing.Extensions.CodeCoverage package (pinned 18.3.1 in Directory.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.)
  • Publish as a check: codecov/codecov-action@v5 uploads the cobertura file. Codecov posts codecov/project and codecov/patch status checks on the PR.
  • No comment: codecov.yml sets comment: false; the project/patch statuses are informational: true, so they report coverage without blocking merges.
  • fail_ci_if_error: false so 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:

  1. Sign in at https://codecov.io with GitHub and enable the sillsdev/harmony repository.
  2. Copy the repository upload token from Codecov and add it as an Actions secret named 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_error to true if you want upload failures to gate.

Test plan

  • actionlint passes on the workflow.
  • Verified locally that the MTP coverage command produces coverage-results/coverage.cobertura.xml.

Summary by CodeRabbit

  • Tests

    • Automated tests now generate code coverage reports.
    • Coverage results are uploaded for project and change-level visibility.
    • Existing benchmark execution remains available.
  • Chores

    • Updated continuous integration reporting to provide clearer coverage status information.
    • Pull request coverage comments are disabled to reduce unnecessary notifications.

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>
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The 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.

Changes

Coverage reporting

Layer / File(s) Summary
Coverage package and reporting setup
Directory.Packages.props, src/SIL.Harmony.Tests/SIL.Harmony.Tests.csproj, codecov.yml
The test project adds the coverage package. Central package management pins version 18.3.1. Codecov disables comments and configures informational project and patch checks.
Coverage generation and upload
.github/workflows/test.yaml
The test workflow generates Cobertura coverage and conditionally uploads the report to Codecov. Existing benchmark configuration remains in place.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: rmunn

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: publishing test coverage to Codecov through the Microsoft Testing Platform.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ci/collect-coverage

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@hahn-kev-bot hahn-kev-bot changed the title Collect code coverage in CI Publish code coverage to Codecov (MTP) Aug 7, 2026
@hahn-kev
hahn-kev merged commit 78cb077 into main Aug 7, 2026
6 of 7 checks passed
@hahn-kev
hahn-kev deleted the ci/collect-coverage branch August 7, 2026 09:38

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between d287e0d and 409c873.

📒 Files selected for processing (4)
  • .github/workflows/test.yaml
  • Directory.Packages.props
  • codecov.yml
  • src/SIL.Harmony.Tests/SIL.Harmony.Tests.csproj

Comment on lines +28 to +34
- 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🗄️ 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.yaml

Repository: 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.

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.

2 participants