ci: publish coverage to GitHub Code Quality on PRs#128
Open
mkrueger wants to merge 1 commit into
Open
Conversation
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.
Contributor
There was a problem hiding this comment.
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-packagejob the additional permissions needed to upload coverage and resolve PR context when running onpush. - 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)actions/upload-code-coverage@v1step that uploads the merged Cobertura report (language: C#,label: code-coverage/dotnet).build-test-packagejobcode-quality: writeandpull-requests: read. Thepull-requests: readpermission is required because same-repo PRs onmain/rel/*/dev/**are served by thepushevent run (see the existingif:dedupe logic), and onpushthe action resolves the open PR number viagh pr list.Coberturato the existing ReportGenerator-reporttypes, so the per-projectXPlat Code Coveragereports are merged into a singleTestResults/coverage/Cobertura.xmlfor upload.fail-on-error: falseso CI stays green if Code Quality is not yet enabled on the repository.Notes / prerequisites
github-code-quality[bot]will only appear once GitHub Code Quality is enabled for the repository (admin setting; public preview, currently unbilled).--collect "XPlat Code Coverage"; this only adds the upload + a merged report type.