Skip to content

ci: publish coverage to GitHub Code Quality on PRs#128

Open
mkrueger wants to merge 1 commit into
mainfrom
dev/mkrueger/pr-coverage-upload
Open

ci: publish coverage to GitHub Code Quality on PRs#128
mkrueger wants to merge 1 commit into
mainfrom
dev/mkrueger/pr-coverage-upload

Conversation

@mkrueger

Copy link
Copy Markdown
Contributor

What

Wires up GitHub's new Code coverage on pull requests feature (GitHub Code Quality, public preview) so reviewers see the aggregate coverage percentage and a per-file breakdown directly on the PR instead of digging through the coverage artifact.

Changes (.github/workflows/validate-and-package.yml)

  • Add actions/upload-code-coverage@v1 step that uploads the merged Cobertura report (language: C#, label: code-coverage/dotnet).
  • Grant the build-test-package job code-quality: write and pull-requests: read. The pull-requests: read permission is required because same-repo PRs on main/rel/*/dev/** are served by the push event run (see the existing if: dedupe logic), and on push the action resolves the open PR number via gh pr list.
  • Add Cobertura to the existing ReportGenerator -reporttypes, so the per-project XPlat Code Coverage reports are merged into a single TestResults/coverage/Cobertura.xml for upload.
  • Guard the step for fork PRs (which cannot write to the base repo) and set fail-on-error: false so CI stays green if Code Quality is not yet enabled on the repository.

Notes / prerequisites

  • The coverage comment from github-code-quality[bot] will only appear once GitHub Code Quality is enabled for the repository (admin setting; public preview, currently unbilled).
  • No change to test execution — coverage was already collected via --collect "XPlat Code Coverage"; this only adds the upload + a merged report type.
  • Opened primarily to exercise the workflow change and confirm the upload step runs as expected.

Add the actions/upload-code-coverage step so the aggregate coverage percentage and per-file breakdown show up directly on pull requests (GitHub Code Quality public preview).

- Grant the build-test-package job code-quality:write and pull-requests:read (the latter is needed because same-repo PRs on main/rel/*/dev/** are served by the push event run, where the action resolves the open PR via gh pr list).
- Emit a merged Cobertura.xml from ReportGenerator for the upload action to consume.
- Guard the step against fork PRs and use fail-on-error:false so CI stays green if Code Quality is not yet enabled.

Copilot AI 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.

Pull request overview

Adds GitHub Code Quality (code coverage on pull requests, public preview) integration to the existing CI workflow so PRs display aggregate and per-file coverage directly in the PR UI, using the already-collected XPlat Code Coverage results.

Changes:

  • Grants the build-test-package job the additional permissions needed to upload coverage and resolve PR context when running on push.
  • Extends ReportGenerator output to include a merged Cobertura report.
  • Uploads the merged Cobertura report via actions/upload-code-coverage@v1, with fork-safe gating and non-fatal behavior.

Comment on lines +218 to +221
if: >-
always() &&
(github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository)
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