[6.1] Fix flaky code coverage job: pin tool versions and harden thread-job handling - #4611
Draft
paulmedynski wants to merge 1 commit into
Draft
[6.1] Fix flaky code coverage job: pin tool versions and harden thread-job handling#4611paulmedynski wants to merge 1 commit into
paulmedynski wants to merge 1 commit into
Conversation
…d-job handling The Publish Code Coverage job started failing when dotnet-coverage 18.10.0 shipped a first-run telemetry notice on stderr. PowerShell turns native stderr into error records, and the PowerShell task defaults to ErrorActionPreference=Stop, so the first Receive-Job that replayed the notice raised a terminating error and killed the step before the netCore merge even started. - Pin dotnet-coverage to 18.9.0 and dotnet-reportgenerator-globaltool to 5.5.11, the versions from the last green run of this job (build 167409). Installs now go through DotNetCoreCLI@2 with NuGet.config copied to a temp working directory, matching the approach on main. - Set DOTNET_COVERAGE_TELEMETRY_OPTOUT so the notice is never emitted. - Redirect tool stderr into stdout and check $LASTEXITCODE explicitly, so informational output can no longer fail the step while a genuine tool failure now does. Previously a failed merge was silently ignored. - Drain thread jobs with -ErrorAction Continue and fail on job state instead of on replayed error records.
Contributor
There was a problem hiding this comment.
Pull request overview
Stabilizes the Windows code-coverage pipeline by preventing telemetry output from failing PowerShell thread jobs and reliably detecting tool failures.
Changes:
- Pins coverage-tool versions and configures repository package feeds.
- Disables
dotnet-coveragetelemetry. - Hardens concurrent merge and report-generation job handling.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
Problem
The
Publish Code Coveragejob has been failing in CI. Example: run 23310, build 168798.No test failed. The
Convert coverage files to xmlstep died with a bare##[error]PowerShell exited with code '1'.Root cause:
dotnet-coverage18.10.0 emits a first-run telemetry notice on stderr:PowerShell converts native-command stderr into
ErrorRecords, which land in each thread job's error stream.PowerShell@2defaults toerrorActionPreference: stop, so the firstReceive-Jobthat replayed the notice raised a terminating error andpwshexited 1.Evidence from the log:
Merging started...appears once — the script died draining the very first netFx job, soMergeFilesfor netCore never ran.Merged into file ...successfully. The coverage data itself was fine.Telemetry, immediately followed by the error.The tool install was unpinned, so 18.10.0 floated in on its own. The last green run of this job (build 167409, 2026-08-16) ran
dotnet-coverage v18.9.0.0with zero occurrences of "Telemetry" across 36,065 log lines.Changes
Pin the tool versions
dotnet-coverage→18.9.0,dotnet-reportgenerator-globaltool→5.5.11. These are exactly the versions from the last green run of this job.dotnet tool installscript toDotNetCoreCLI@2tasks, withNuGet.configcopied to$(Agent.TempDirectory)so tool restores honour the repo's feeds. This matches the pattern already used onmain.Opt out of the telemetry notice
DOTNET_COVERAGE_TELEMETRY_OPTOUT: 1as a job variable so the banner is never emitted, independent of tool version.Harden the thread-job steps
2>&1and capture$LASTEXITCODE, so informational stderr becomes ordinary output and only a genuine non-zero exit throws. Previously a realdotnet-coveragefailure was silently ignored — the job still reportedCompleted.Receive-Job -ErrorAction Continue 2>&1 | Out-String | Write-Hostplus explicitRemove-Job, with job state checked afterWait-Joband an explicit throw naming how many jobs failed.Write-Error+exit 1for the "no .coverage files" case became athrow, so it doesn't abort the whole script from inside the function.StartReportGeneratorhelper using-ArgumentList.Notes on version choice
mainpinsdotnet-coverageto18.3.2, but its coverage job is a different shape — Linux, a singledotnet-coverage mergein a plainscript:step, no ReportGenerator, no thread jobs — so it never exercised this path. Pinning 6.1 to18.3.2would be a six-version downgrade to something this job has never run, hence18.9.0.Validation
pwshscripts pass[Parser]::ParseFilewith no errors.$ErrorActionPreference = 'Stop'with a stub tool: a noisy-but-successful tool no longer fails the step, and a tool exiting non-zero still does.Checklist