Skip to content

Restore legacy Helix test result attachment behavior - #17304

Merged
mmitche merged 5 commits into
dotnet:mainfrom
mmitche:copilot/attachment-policy-pr
Aug 11, 2026
Merged

mmitche merged 5 commits into
dotnet:mainfrom
mmitche:copilot/attachment-policy-pr

Conversation

@mmitche

@mmitche mmitche commented Aug 11, 2026

Copy link
Copy Markdown
Member

Part of #17280.

Restores the legacy per-test attachment behavior while keeping the monitor behavior configurable:

  • adds Failed, All, and None attachment modes
  • defaults to Failed, matching the pre-monitor reporters
  • applies the policy consistently to xUnit, JUnit, and TRX output
  • keeps the run-level failed-work-items attachment unchanged
  • conditionally forwards the new template option so older pinned monitor tools remain compatible

Validation: full Helix SDK test suite and 54 targeted attachment tests passed.

@premun

Co-authored-by: Copilot <[email protected]>

Copilot-Session: 0d06c6da-2805-4deb-909c-7504e58388ac
Co-authored-by: Copilot <[email protected]>

Copilot-Session: 0d06c6da-2805-4deb-909c-7504e58388ac
Copilot AI lite review requested due to automatic review settings August 11, 2026 00:46
@mmitche
mmitche requested a review from premun August 11, 2026 00:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restores legacy per-test output attachment behavior for Helix result publishing while keeping the Helix Job Monitor behavior configurable and compatible with older pinned tools.

Changes:

  • Introduces TestResultAttachmentMode (Failed, All, None) and defaults behavior to Failed.
  • Applies attachment-mode filtering consistently when parsing xUnit, JUnit, and TRX result files, and threads the setting through the Job Monitor and AzDO publisher parameters.
  • Updates the helix-job-monitor.yml template to conditionally pass the new CLI option only when explicitly set.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/LocalTestResultsReaderTests.cs Adds coverage validating attachment behavior across formats/outcomes and the empty-output case.
src/Microsoft.DotNet.Helix/Sdk.Tests/Microsoft.DotNet.Helix.Sdk.Tests/AzureDevOpsResultPublisherTests.cs Verifies new default attachment mode behavior for publisher parameters and job monitor options.
src/Microsoft.DotNet.Helix/JobMonitor/Services/AzureDevOpsService.cs Forwards the attachment mode into AzDO reporting parameters used by the publisher.
src/Microsoft.DotNet.Helix/JobMonitor/JobMonitorOptions.cs Adds --test-result-attachment-mode option and default config in the Job Monitor.
src/Microsoft.DotNet.Helix/AzureDevOpsTestPublisher/Model/TestResultAttachmentMode.cs Introduces the new attachment mode enum.
src/Microsoft.DotNet.Helix/AzureDevOpsTestPublisher/Model/AzureDevOpsReportingParameters.cs Extends reporting parameters to carry attachment mode to the publisher.
src/Microsoft.DotNet.Helix/AzureDevOpsTestPublisher/LocalTestResultsReader.cs Implements per-test attachment filtering based on mode for xUnit/JUnit/TRX parsing.
src/Microsoft.DotNet.Helix/AzureDevOpsTestPublisher/AzureDevOpsResultPublisher.cs Instantiates the reader with the configured attachment mode.
eng/common/core-templates/job/helix-job-monitor.yml Adds template parameter and conditional forwarding of --test-result-attachment-mode.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

premun
premun previously approved these changes Aug 11, 2026
Copilot AI review requested due to automatic review settings August 11, 2026 08:35

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

src/Microsoft.DotNet.Helix/AzureDevOpsTestPublisher/LocalTestResultsReader.cs:212

  • AddAttachmentIfEnabled silently falls back to false for any unexpected TestResultAttachmentMode value. Throwing an ArgumentOutOfRangeException makes invalid/unsupported values fail fast (useful if the enum is extended or an invalid value is deserialized/cast).
        bool includeAttachment = _attachmentMode switch
        {
            TestResultAttachmentMode.All => true,
            TestResultAttachmentMode.Failed => string.Equals(normalizedOutcome, "Fail", StringComparison.Ordinal),
            TestResultAttachmentMode.None => false,
            _ => false,
        };

Co-authored-by: Přemek Vysoký <[email protected]>
Copilot AI review requested due to automatic review settings August 11, 2026 10:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

src/Microsoft.DotNet.Helix/AzureDevOpsTestPublisher/LocalTestResultsReader.cs:212

  • AddAttachmentIfEnabled silently treats any unknown TestResultAttachmentMode value as false (_ => false). If a new enum value is added later (or an invalid value is deserialized/cast), this will quietly suppress attachments and make the behavior hard to diagnose. Prefer throwing ArgumentOutOfRangeException in the default arm so unexpected values fail fast.
        bool includeAttachment = _attachmentMode switch
        {
            TestResultAttachmentMode.All => true,
            TestResultAttachmentMode.Failed => string.Equals(normalizedOutcome, "Fail", StringComparison.Ordinal),
            TestResultAttachmentMode.None => false,
            _ => false,
        };

Copilot AI review requested due to automatic review settings August 11, 2026 13:51
@mmitche
mmitche merged commit 498a70a into dotnet:main Aug 11, 2026
2 of 9 checks passed

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Suppressed comments (2)

eng/common/core-templates/job/helix-job-monitor.yml:247

  • The template always forwards --test-result-attachment-mode because the parameter defaults to Failed (non-empty). That breaks compatibility with older pinned job monitor tools that don’t recognize the new option, contradicting the intent to forward it conditionally.
      if [ -n "$testResultAttachmentMode" ]; then
        toolArgs+=( --test-result-attachment-mode "$testResultAttachmentMode" )
      fi

src/Microsoft.DotNet.Helix/AzureDevOpsTestPublisher/Model/AzureDevOpsReportingParameters.cs:12

  • Adding a new positional parameter to a public record changes its generated constructor signature and is binary-breaking for callers compiled against the previous version. Consider adding an overload matching the prior constructor signature and chaining to the new one.
public sealed record AzureDevOpsReportingParameters(
    Uri CollectionUri,
    string TeamProject,
    string TestRunId,
    string? AccessToken = null,
    bool UseFullyQualifiedTestName = false,
    TestResultAttachmentMode TestResultAttachmentMode = TestResultAttachmentMode.Failed);

Comment on lines +11 to +16
public sealed class LocalTestResultsReader(
ILogger logger,
TestResultAttachmentMode attachmentMode = TestResultAttachmentMode.Failed)
{
private readonly ILogger _logger = logger;
private readonly TestResultAttachmentMode _attachmentMode = attachmentMode;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants