Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion .github/workflows/validate-and-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ jobs:
build-test-package:
runs-on: windows-latest

# `code-quality: write` lets the run upload the Cobertura report to
# GitHub Code Quality so coverage shows up on the PR. `pull-requests: read`
# is required because same-repo PRs on `main`/`rel/*`/`dev/**` branches are
# served by the `push` event run (see the `if` below), and on `push` the
# upload action resolves the open PR via `gh pr list`.
permissions:
contents: read
code-quality: write
pull-requests: read

# A push to a branch with an open PR fires both `push` and `pull_request`
# events. Rather than cancelling one of them (a cancelled run reports
# as a failed required check on the PR's head SHA and blocks merge),
Expand Down Expand Up @@ -187,7 +197,7 @@ jobs:
dotnet tool run reportgenerator `
"-reports:$reports" `
"-targetdir:TestResults/coverage" `
"-reporttypes:Html;MarkdownSummaryGithub;TextSummary" `
"-reporttypes:Html;MarkdownSummaryGithub;TextSummary;Cobertura" `
"-title:CosmosDBShell Code Coverage"
if ($LASTEXITCODE -ne 0) {
throw "reportgenerator failed with exit code $LASTEXITCODE."
Expand All @@ -198,6 +208,24 @@ jobs:
Get-Content $markdown | Out-File -FilePath $env:GITHUB_STEP_SUMMARY -Encoding utf8 -Append
}

# Publish coverage to GitHub Code Quality so the aggregate percentage and
# per-file breakdown appear directly on the PR (public preview feature).
# ReportGenerator merges the per-project XPlat reports into a single
# Cobertura.xml that this action uploads. Skipped for fork PRs, which
# cannot write to the base repo; `fail-on-error: false` keeps CI green if
# Code Quality is not yet enabled on the repository.
- name: Upload coverage to GitHub Code Quality
if: >-
always() &&
(github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name == github.repository)
Comment on lines +218 to +221
uses: actions/upload-code-coverage@v1
with:
file: TestResults/coverage/Cobertura.xml
language: C#
label: code-coverage/dotnet
fail-on-error: false

- name: Upload code coverage report
if: always()
uses: actions/upload-artifact@v4
Expand Down
Loading