Repository navigation
Description
Summary
Propose a new MTP extension Microsoft.Testing.Extensions.GitHubReport that publishes test results back to GitHub when the test session runs in GitHub Actions. Mirrors the design and CLI shape of the existing Microsoft.Testing.Extensions.AzureDevOpsReport extension.
Motivation
Today, users running MTP-powered test projects on GitHub Actions get test results in two places:
- The raw stdout of the workflow step.
- A separate, post-process Action (
dorny/test-reporter,EnricoMi/publish-unit-test-result-action,ctrf-io/github-test-reporter, …) that parses TRX or JUnit after the test step finishes.
The post-process path works but:
- It runs after the fact (no live progress, no real-time annotations).
- File/line annotations are best-effort regex over TRX/JUnit, not authoritative test-node metadata.
- It requires every consumer to wire up a separate job step.
We already have Microsoft.Testing.Extensions.AzureDevOpsReport, which integrates natively with Azure DevOps (live publishing, build summary, annotations, progress, artifact upload). The GitHub equivalent is a natural symmetry to add.
Proposed design
Detection
Mirror the AzDO extension''s TF_BUILD=true gating:
GITHUB_ACTIONS=trueenables the extension.GITHUB_TOKEN,GITHUB_REPOSITORY,GITHUB_REF,GITHUB_SHA,GITHUB_RUN_ID,GITHUB_STEP_SUMMARYconsumed as needed (each tier degrades gracefully if its required vars are missing, with a trace log).- All CLI options no-op outside GitHub Actions and emit a warning if explicitly set (same pattern as
--report-azdo*).
Three tiers (adoptable incrementally)
| Tier | Feature | Auth | GitHub API |
|---|---|---|---|
| 1 | Job summary + workflow logging commands — write a Markdown summary to $GITHUB_STEP_SUMMARY; emit ::error file=…,line=…,title=…::message for failures, ::warning file=… for skipped, ::notice for retries. |
None | Built-in (file + stdout) |
| 2 | Check Run with annotations — create a Check Run, attach per-failure annotations pinned to file:line using TestFileLocationProperty from the TestNode. |
GITHUB_TOKEN |
POST/PATCH /repos/{owner}/{repo}/check-runs |
| 3 | Sticky PR comment — post/update a single comment on the PR with the summary table (find-or-create by marker). | GITHUB_TOKEN + pull_request event |
POST/PATCH /repos/.../issues/{n}/comments |
CLI options (mirroring --report-azdo*)
--report-github— master switch (default on whenGITHUB_ACTIONS=true).--report-github-summary— Tier 1 Markdown summary.--report-github-progress— Tier 1 progress via step summary updates.--report-github-annotations— Tier 1::errorworkflow commands (and Tier 2 Check Run annotations if a token is available).--report-github-comment— Tier 3 sticky PR comment.
Implementation outline
File layout mirrors src/Platform/Microsoft.Testing.Extensions.AzureDevOpsReport/:
GitHubExtensions.cs— publicAddGitHubProvider(this ITestApplicationBuilder)entry point.GitHubCommandLineProvider.cs/GitHubCommandLineOptions.cs— CLI surface.GitHubReporter.cs— env detection, master switch.GitHubSummaryReporter.cs— Tier 1 summary writer.GitHubAnnotationEmitter.cs— Tier 1 workflow command emitter.GitHubCheckRunClient.cs/GitHubCheckRunPublisher.cs— Tier 2 Check Runs API.GitHubPullRequestCommentClient.cs/GitHubPullRequestCommentPublisher.cs— Tier 3 sticky comment.TestingPlatformBuilderHook.cs— auto-registration hook.PACKAGE.md,BannedSymbols.txt, csproj.
Why an MTP extension instead of a separate Action?
| Aspect | MTP extension | Post-process Action |
|---|---|---|
| Setup | Reference one NuGet + flag | Add a separate workflow step |
| Live progress | ✅ Check Run updates | ❌ After test step exits |
| File/line annotation fidelity | ✅ Direct from TestNode metadata |
Best-effort regex over TRX |
| Works for fork PRs | ✅ GITHUB_TOKEN |
✅ |
| Maintenance | We own it | Third-party |
Trade-offs / open questions
- Doesn''t help the
microsoft/testfxrepo''s own CI — testfx runs on AzDO, not GitHub Actions, so this extension wouldn''t haveGITHUB_TOKENavailable in our own pipelines. This is primarily useful for users of MTP running on GitHub Actions. - HTTP from the test host — Tier 2/3 introduce REST calls during/after the test session. AzDO extension already does the same; design
GitHubCheckRunClientafterAzureDevOpsTestResultsClient. - Permission scoping — Tier 2 needs
checks: write; Tier 3 needspull-requests: write. Document requiredpermissions:block inPACKAGE.md. - Authentication beyond
GITHUB_TOKEN— should we also accept a PAT or GitHub App token via env var (e.g. for self-hosted/Jenkins-running-against-GitHub-PR scenarios)? Recommend yes, viaGITHUBREPORTER_TOKENfallback. - Annotation aggregation limits — GitHub caps Check Run annotations at 50 per request; need batching for large failure counts (mirroring how
AzureDevOpsArtifactUploaderbatches). - xUnit/NUnit/TUnit — should work via MTP for any test framework that emits
TestFileLocationProperty; verify and document gaps.
Out of scope
- Auto-creating a PR with fix suggestions.
- Coverage publishing (separate concern; can be a sibling extension or layered on top once the GitHub plumbing exists).
- Trend/history (the AzDO extension''s
AzureDevOpsHistoryServiceis AzDO-API-specific; GitHub equivalent would need workflow-run-history APIs and is a follow-up).
Acceptance criteria
- New extension project under
src/Platform/Microsoft.Testing.Extensions.GitHubReport/builds and packs asMicrosoft.Testing.Extensions.GitHubReport. - Tier 1 works in any GitHub Actions workflow with zero additional configuration.
- Tier 2/3 work when
permissions:grantschecks: write/pull-requests: write. - Acceptance tests under
test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/exercise each tier with a fake/stub GitHub server. PACKAGE.mddocuments required workflowpermissions:blocks and the CLI surface.
🤖 RFC drafted with the assistance of GitHub Copilot CLI.
Activity
Evangelink commentedon Jul 13, 2026
Where this landed, and what's next
I went back through the code before answering. The RFC is partially delivered: the token-free tier shipped (and then some), the token-based tiers did not. More importantly, re-examining the token tiers surfaced a feasibility blocker the original write-up under-weighted. Details below.
✅ Shipped as
Microsoft.Testing.Extensions.GitHubActionsReportThe RFC's Tier 1 (and more) is in
src/Platform/Microsoft.Testing.Extensions.GitHubActionsReport/, gated onGITHUB_ACTIONS=true+ the--report-ghmaster switch, unit-tested:--report-gh-annotations—::error file=,line=,col=,title=per failure (source location resolved from the exception stack trace, repo-root-relative) + title-only::warningfor skips. These already surface in the PR "Files changed" gutter and the Annotations tab.--report-gh-step-summary— Markdown summary table to$GITHUB_STEP_SUMMARY.--report-gh-groups—::group::/::endgroup::per assembly (beyond the RFC).--report-gh-slow-test-notices+--report-gh-slow-test-threshold(beyond the RFC).All of this needs no token and no HTTP, works on any workflow with zero config, and — notably — already delivers the RFC's headline "authoritative
file:lineannotations" selling point.❌ Not built: Tier 2 (Check Run) and Tier 3 (sticky PR comment)
No
GITHUB_TOKEN,HttpClient, Check Run, or PR-comment code exists.The blocker that reframes the decision
On a
pull_requestrun from a fork, the defaultGITHUB_TOKENis read-only — it can'tchecks: write(Tier 2) orpull-requests: write(Tier 3). So both token tiers would silently no-op in the exact OSS-on-Actions scenario that motivates them.pull_request_targetworks but is a security footgun we shouldn't nudge users toward. The RFC's compatibility table optimistically marked forks ✅; in practice they're the weakest case for the token tiers.Cost/benefit per remaining tier
Recommendation
permissions:block, model the client onAzureDevOpsTestResultsClient, add theGITHUBREPORTER_TOKENfallback for non-GHA hosts (Jenkins-against-GitHub), and batch annotations at 50/request.--report-gh-*, not the RFC's--report-github-*— reconcile docs; (b) note thatfile:linecomes from the exception stack trace, notTestFileLocationProperty, so cross-framework (xUnit/NUnit/TUnit) behavior should be verified and documented; (c) confirmPACKAGE.mddocuments the CLI surface (permissions only become relevant if the token tiers ever ship).TL;DR: the practical value shipped. I'd close this RFC as "Tier 1 done" and let the token tiers be pulled by real user demand rather than pushed.
🤖 Reviewed against the current codebase with the assistance of GitHub Copilot CLI.
Evangelink commentedon Jul 13, 2026
Correction on the CLI naming point
Follow-up to housekeeping item (a) in my previous comment — I want to reverse it. The shipped
--report-gh-*naming is correct; it's the RFC's proposed--report-github-*that's out of step with the established convention.The AzDO sibling sets the precedent, and it deliberately splits the two surfaces:
AzureDevOps*(spelled out)GitHubActions*(spelled out)--report-azdo,--report-azdo-*--report-gh,--report-gh-*The CLI token is intentionally the short informal handle, not the product's full name: AzDO abbreviates
azure-devops->azdo, so GitHub abbreviatinggithub->ghis the exact analogue.ghis also the name of the official GitHub CLI, so it's the idiomatic short form users already recognize — not an invented contraction. Spelling it out as--report-github-*would actually be the inconsistent choice.So: no code change needed —
--report-gh-*stays. The only thing to reconcile is the RFC text, which should be updated from--report-github-*to--report-gh-*.🤖 Reviewed with the assistance of GitHub Copilot CLI.
Ramstad commentedon Jul 15, 2026
I just tested this and it works really nice!
Could this also include the totals across assemblies output when running
dotnet test? This one:Evangelink commentedon Jul 15, 2026
Thanks for testing out the extension Stian Ramstad (@Ramstad)! We will look at improving it for multi-asm behavior (
dotnet test).Ramstad commentedon Jul 15, 2026
Another suggestion.
It would be nice if it could output some indication of failure when options like
--minimum-expected-testscause failure.Like general handling of the different MTP known exit codes scenarios.