Skip to content

Annotate failing tests and write a short job summary on GitHub Actions - #4826

Merged
Mpdreamz merged 1 commit into
mainfrom
chore/github-test-reporter
Nov 12, 2026
Merged

Mpdreamz merged 1 commit into
mainfrom
chore/github-test-reporter

Conversation

@Mpdreamz

Copy link
Copy Markdown
Member

A failing unit or integration test now gets an annotation on its line and a short job summary, and a green run writes no summary at all.

Affects: Automation

Prompt summary: Investigate which MTP and TUnit reporters give useful GitHub annotations and summaries for the test run, then land the best setup with the environment variable set in the build target.

Why

The test step prints TUnit's console output and TUnit's own step summary: one section per test project, 18 of them, each with a tip line, and no annotations. A failure shows only in the log, and the passing projects bury it.

What

Report extension

Microsoft.Testing.Extensions.GitHubActionsReport 2.5.2, the same version as Microsoft.Testing.Platform, is a package reference in tests/ and tests-integration/. On GitHub Actions it writes a ::error or ::warning annotation with the file and line, and one collapsible log group per test assembly.

Test step flags

When GITHUB_ACTIONS is set, the unit-test, integrate and test targets pass --report-gh --report-gh-step-summary on-failure --report-gh-step-summary-sections test-results. Only a failing project writes a summary section, with the exception, the file:line and a trimmed stack, and the slowest-tests lists are left out. Without GITHUB_ACTIONS the extension does nothing, so local runs are unchanged.

TUnit's reporter off

The target always sets TUNIT_DISABLE_GITHUB_REPORTER=true for dotnet test, so TUnit's own summary does not repeat the results.

Out of scope: two tests that are skipped today (Elastic.Documentation.Build.Tests ApiSitemapParityTests and Elastic.ApiExplorer.Tests OpenApiDocumentExporterTests) now produce a ::warning annotation on every run. The extension turns failed and skipped annotations on or off together.

Risk: the annotation and summary rendering on a real runner is unchecked. Locally I simulated GITHUB_ACTIONS and GITHUB_STEP_SUMMARY. Whether the annotation lands on the PR's Files changed tab, and the Windows and macOS paths, are untested until CI runs.

Verify

# green: exit 0, no summary written
: > /tmp/summary.md
GITHUB_ACTIONS=true GITHUB_STEP_SUMMARY=/tmp/summary.md ./build.sh unit-test --single-target
wc -c /tmp/summary.md

With a test that fails, the same command exits 1 and prints one ::error file=…,line=… line, and the summary holds one section for the failing project.

… summary

The `GitHubActionsReport` extension adds an annotation on the failing test's line and writes a job summary only when a test fails. The test step passes its flags on GitHub Actions and always turns off TUnit's own summary, which would repeat the same results for every project.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@Mpdreamz
Mpdreamz requested a review from a team as a code owner November 11, 2026 19:51
@Mpdreamz
Mpdreamz requested a review from technige November 11, 2026 19:51
@Mpdreamz Mpdreamz added the automation packaging, ci/cd. label Nov 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

@Mpdreamz
Mpdreamz merged commit b381f4a into main Nov 12, 2026
48 checks passed
@Mpdreamz
Mpdreamz deleted the chore/github-test-reporter branch November 12, 2026 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation packaging, ci/cd.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant