-
Notifications
You must be signed in to change notification settings - Fork 307
Surface exit-code verdict and per-assembly clarity in GitHubActionsReport #9974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Evangelink
merged 7 commits into
main
from
dev/amauryleve/github-report-multiasm-exitcode
Jul 16, 2026
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5d1907b
GitHubActionsReport: surface exit-code verdict and per-assembly clarity
Evangelink 94a9bcf
Address review: scope exit-code docs and add end-to-end acceptance co…
Evangelink 928c35c
Expert review round 1: rename param, tighten PACKAGE.md note, add Unk…
Evangelink c8e9aa1
Address review: add UTF-8 BOM to new files, drop unreachable-abort cl…
Evangelink 23ba0de
Make GITHUB_STEP_SUMMARY append cross-process safe (multi-assembly)
Evangelink 77d4db8
Scope step-summary append retry to handle acquisition only
Evangelink f3a6d62
Silence code-quality nit on ThrowOnWriteStream.Position setter
Evangelink File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
64 changes: 64 additions & 0 deletions
64
src/Platform/Microsoft.Testing.Extensions.GitHubActionsReport/GitHubActionsExitCode.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
|
||
| using Microsoft.Testing.Extensions.GitHubActionsReport.Resources; | ||
| using Microsoft.Testing.Platform.Helpers; | ||
|
|
||
| namespace Microsoft.Testing.Extensions.GitHubActionsReport; | ||
|
|
||
| /// <summary> | ||
| /// Helpers for turning a Microsoft.Testing.Platform process exit code into a GitHub-friendly verdict. | ||
| /// Used by the step-summary and annotation reporters so that non-test-result failures observable once the | ||
| /// test session has finished — e.g. a <c>--minimum-expected-tests</c> violation, a run that discovered zero | ||
| /// tests, a <c>--maximum-failed-tests</c> stop or a test-adapter session failure — are surfaced instead of | ||
| /// silently looking like a passing run. Outcomes that occur outside the end-of-session path (a hard | ||
| /// abort/cancellation, or host failures raised before/after the session) are not reachable here. | ||
| /// See <see href="https://learn.microsoft.com/dotnet/core/testing/microsoft-testing-platform-troubleshooting#exit-codes"/>. | ||
| /// </summary> | ||
| internal static class GitHubActionsExitCode | ||
| { | ||
| /// <summary> | ||
| /// Returns <see langword="true"/> when the exit code is a normal test-result outcome (everything passed, | ||
| /// or at least one test failed). Those outcomes are already reflected by the passed/failed totals and the | ||
| /// per-test failure annotations, so callers do not surface a separate exit-code callout for them. | ||
| /// </summary> | ||
| public static bool IsTestResultOutcome(int exitCode) | ||
| => exitCode is (int)ExitCode.Success or (int)ExitCode.AtLeastOneTestFailed; | ||
|
|
||
| /// <summary> | ||
| /// Returns <see langword="true"/> when the run did not succeed (any non-zero exit code). | ||
| /// </summary> | ||
| public static bool IndicatesFailure(int exitCode) | ||
| => exitCode != (int)ExitCode.Success; | ||
|
|
||
| /// <summary> | ||
| /// Returns the enum name for a known exit code (e.g. <c>MinimumExpectedTestsPolicyViolation</c>) or | ||
| /// <c>Unknown</c> for a value outside the documented set. | ||
| /// </summary> | ||
| public static string GetName(int exitCode) | ||
| => Enum.IsDefined(typeof(ExitCode), exitCode) | ||
| ? ((ExitCode)exitCode).ToString() | ||
| : "Unknown"; | ||
|
|
||
| /// <summary> | ||
| /// Returns a short, human-readable, localized explanation of the exit code. | ||
| /// </summary> | ||
| public static string GetReason(int exitCode) | ||
| => exitCode switch | ||
| { | ||
| (int)ExitCode.Success => GitHubActionsResources.ExitCodeReasonSuccess, | ||
| (int)ExitCode.GenericFailure => GitHubActionsResources.ExitCodeReasonGenericFailure, | ||
| (int)ExitCode.AtLeastOneTestFailed => GitHubActionsResources.ExitCodeReasonAtLeastOneTestFailed, | ||
| (int)ExitCode.TestSessionAborted => GitHubActionsResources.ExitCodeReasonTestSessionAborted, | ||
| (int)ExitCode.InvalidPlatformSetup => GitHubActionsResources.ExitCodeReasonInvalidPlatformSetup, | ||
| (int)ExitCode.InvalidCommandLine => GitHubActionsResources.ExitCodeReasonInvalidCommandLine, | ||
| (int)ExitCode.TestHostProcessExitedNonGracefully => GitHubActionsResources.ExitCodeReasonTestHostProcessExitedNonGracefully, | ||
| (int)ExitCode.ZeroTests => GitHubActionsResources.ExitCodeReasonZeroTests, | ||
| (int)ExitCode.MinimumExpectedTestsPolicyViolation => GitHubActionsResources.ExitCodeReasonMinimumExpectedTestsPolicyViolation, | ||
| (int)ExitCode.TestAdapterTestSessionFailure => GitHubActionsResources.ExitCodeReasonTestAdapterTestSessionFailure, | ||
| (int)ExitCode.DependentProcessExited => GitHubActionsResources.ExitCodeReasonDependentProcessExited, | ||
| (int)ExitCode.IncompatibleProtocolVersion => GitHubActionsResources.ExitCodeReasonIncompatibleProtocolVersion, | ||
| (int)ExitCode.TestExecutionStoppedForMaxFailedTests => GitHubActionsResources.ExitCodeReasonTestExecutionStoppedForMaxFailedTests, | ||
| _ => GitHubActionsResources.ExitCodeReasonUnknown, | ||
| }; | ||
| } |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.