Auto-upload test artifacts and build tags to Azure DevOps#8295
Draft
Evangelink wants to merge 1 commit into
Draft
Auto-upload test artifacts and build tags to Azure DevOps#8295Evangelink wants to merge 1 commit into
Evangelink wants to merge 1 commit into
Conversation
Add opt-in Azure DevOps artifact upload support, help/info updates, and unit coverage for the new reporter behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds an opt-in pipeline-level artifact upload + build-tag feature to Microsoft.Testing.Extensions.AzureDevOpsReport. It introduces four new CLI options that, when running under Azure DevOps (TF_BUILD=true), emit ##vso[artifact.upload …] and ##vso[build.addbuildtag]… logging commands at session end based on consumed FileArtifact/TestNodeUpdateMessage events and a glob filter over the test results directory.
Changes:
- New
AzureDevOpsArtifactUploader(data consumer + session lifetime handler) plus supportingPathComparison/TargetFrameworkMonikerHelperhelpers andAzureDevOpsArtifactUploadModeenum. - New CLI options (
--report-azdo-upload-artifacts,--report-azdo-upload-artifact-{name,include,exclude}) with validator that rejects absolute globs, unknown modes, and artifact options when uploads are off; resx/xlf strings added; pre-existingEanble→Enabletypo fixed. - Help/info acceptance expectations updated and 12 new unit tests covering modes, tag emission, escaping, globbing, missing
TF_BUILD, and validator rejection.
Show a summary per file
| File | Description |
|---|---|
| src/Platform/Microsoft.Testing.Extensions.AzureDevOpsReport/AzureDevOpsArtifactUploader.cs | New uploader implementing the artifact-upload + build-tag logic. |
| src/Platform/Microsoft.Testing.Extensions.AzureDevOpsReport/AzureDevOpsCommandLineOptions.cs | New option/mode constants. |
| src/Platform/Microsoft.Testing.Extensions.AzureDevOpsReport/AzureDevOpsCommandLineProvider.cs | Registers and validates the new options. |
| src/Platform/Microsoft.Testing.Extensions.AzureDevOpsReport/AzureDevOpsExtensions.cs | Registers the uploader as data consumer + session lifetime handler. |
| src/Platform/Microsoft.Testing.Extensions.AzureDevOpsReport/AzureDevOpsReporter.cs | Switched TFM resolution to shared helper. |
| src/Platform/Microsoft.Testing.Extensions.AzureDevOpsReport/PathComparison.cs | OS-aware path string comparer/comparison. |
| src/Platform/Microsoft.Testing.Extensions.AzureDevOpsReport/TargetFrameworkMonikerHelper.cs | Shared TFM resolution helper. |
| src/Platform/Microsoft.Testing.Extensions.AzureDevOpsReport/Microsoft.Testing.Extensions.AzureDevOpsReport.csproj | Adds Microsoft.Extensions.FileSystemGlobbing reference. |
| src/Platform/Microsoft.Testing.Extensions.AzureDevOpsReport/Resources/AzureDevOpsResources.resx | New strings + Eanble→Enable typo fix. |
| src/Platform/Microsoft.Testing.Extensions.AzureDevOpsReport/Resources/xlf/*.xlf | Regenerated translations for all locales. |
| test/UnitTests/Microsoft.Testing.Extensions.UnitTests/AzureDevOpsArtifactUploaderTests.cs | 12 new unit tests for uploader + validator. |
| test/IntegrationTests/Microsoft.Testing.Platform.Acceptance.IntegrationTests/HelpInfoAllExtensionsTests.cs | Adds AzDO extension + new option entries to help/info expectations. |
Copilot's findings
- Files reviewed: 24/24 changed files
- Comments generated: 1
| public sealed class AzureDevOpsArtifactUploaderTests | ||
| { | ||
| private const string ArtifactUploadOptionsRequireUploadArtifactsMessage = "'--report-azdo-upload-artifact-include', '--report-azdo-upload-artifact-exclude', and '--report-azdo-upload-artifact-name' require '--report-azdo-upload-artifacts' to be set to a value other than 'off'."; | ||
| private const string ResultsDirectory = @"Q:\results"; |
This was referenced May 16, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Part 3 of the brainstorm in #5951 — adds opt-in pipeline-level artifact upload + build tags to
Microsoft.Testing.Extensions.AzureDevOpsReport. Pure##vsologging commands — no Azure DevOps authentication required.Why
Today
HangDump,CrashDump,CodeCoverage, and TRX all drop files intoTestResultsDirectory, but nothing teaches Azure DevOps to publish them as build artifacts — users have to add a separatePublishBuildArtifacts@1task. Similarly, build queries can't easily filter "runs that produced a hang/crash dump" without grepping logs.What
Four new opt-in CLI options on
Microsoft.Testing.Extensions.AzureDevOpsReport:--report-azdo-upload-artifacts <mode>off(default) |tags-only|files|all--report-azdo-upload-artifact-name <name>TestResults_<assemblyName>_<tfm>.--report-azdo-upload-artifact-include <glob>TestResultsDirectory) to include. Default:**/*.--report-azdo-upload-artifact-exclude <glob>At session end (when
TF_BUILD=trueand the mode is notoff), the newAzureDevOpsArtifactUploader:##vso[build.addbuildtag]has-crashdumpand/orhas-hangdumpbased on the producer UID of consumedTestNodeFileArtifactevents (CrashDumpProcessLifetimeHandler/HangDumpProcessLifetimeHandler— robust to localization).##vso[build.addbuildtag]has-test-failuresif the session contained any failed test.TestResultsDirectoryviaIFileSystem, applies include/exclude globs (case-sensitive on Linux, case-insensitive on Windows), and emits##vso[artifact.upload containerfolder=…;artifactname=…]<path>for each match — properly escaping;,\r,\nvia the existingAzDoEscaper.All output goes through
IOutputDevice(no directConsole.WriteLine). All env/path/file access goes throughIEnvironment/IConfiguration/IFileSystem. Exception isolation: callbacks never propagate non-cancellation exceptions out of the lifetime handler.Highlights from the expert-reviewer round
The implementation went through one round of
expert-reviewer. Critical/major issues addressed:try/catcheverything exceptOperationCanceledException; warnings logged viaILogger.--report-azdo-upload-artifact-{include,exclude,name}when--report-azdo-upload-artifactsis absent oroff.Interlocked.Exchange+Volatile.Read.PathComparisonhelper (OrdinalIgnoreCaseon Windows,Ordinalelsewhere) applied to glob construction, prefix matching, and sort.DisplayNameor path substring.TestResultsDirectory(e.g. via symlinks) are skipped.TargetFrameworkMonikerHelper(also adopted by the existingAzureDevOpsReporter).Eanble→Enablefixed inResources/AzureDevOpsResources.resx.Tests
test/UnitTests/Microsoft.Testing.Extensions.UnitTests/AzureDevOpsArtifactUploaderTests.cscovering mode wiring (incl.offno-op), tag emission (exactly once, even under concurrent message events), glob include/exclude, escaping, missingTF_BUILD, null/whitespaceTestResultsDirectory, out-of-dir filtering, and validator rejection.HelpInfoAllExtensionsTestsexpectations updated for new options (both--helpand--infoblocks, alphabetical order preserved).Build status (local)
.\.dotnet\dotnet.exe build src\Platform\Microsoft.Testing.Extensions.AzureDevOpsReport\Microsoft.Testing.Extensions.AzureDevOpsReport.csproj -c Debug— 0 warnings, 0 errors..\.dotnet\dotnet.exe test test\UnitTests\Microsoft.Testing.Extensions.UnitTests\Microsoft.Testing.Extensions.UnitTests.csproj— 566/566 passed..\build.cmd -pack— 0 warnings, 0 errors.Out of scope (deliberate)
Both can land as small follow-ups once that PR is merged.
Checklist
/t:UpdateXlf, not hand-edited).\build.cmdgreen (0 warnings, 0 errors)Refs #5951