Skip to content

[release/v7.6] Add GitHub Actions annotations for Pester test failures#26969

Merged
daxian-dbw merged 2 commits intoPowerShell:release/v7.6from
daxian-dbw:backport/release/v7.6/26789-4db414ca3
Mar 9, 2026
Merged

[release/v7.6] Add GitHub Actions annotations for Pester test failures#26969
daxian-dbw merged 2 commits intoPowerShell:release/v7.6from
daxian-dbw:backport/release/v7.6/26789-4db414ca3

Conversation

@daxian-dbw
Copy link
Member

Backport of #26789 to release/v7.6

Triggered by @daxian-dbw on behalf of @app/copilot-swe-agent

Original CL Label: CL-Test

/cc @PowerShell/powershell-maintainers

Impact

REQUIRED: Choose either Tooling Impact or Customer Impact (or both). At least one checkbox must be selected.

Tooling Impact

  • Required tooling change
  • Optional tooling change (include reasoning)

Improves CI/CD test failure reporting by adding GitHub Actions annotations. This makes test failures more visible and easier to debug in PR workflows.

Customer Impact

  • Customer reported
  • Found internally

Regression

REQUIRED: Check exactly one box.

  • Yes
  • No

This is not a regression.

Testing

Successfully backported to v7.4 and v7.5 previously. Verified by running CI workflows with Pester test failures to confirm annotations are generated correctly.

Risk

REQUIRED: Check exactly one box.

  • High
  • Medium
  • Low

Medium risk as it modifies test infrastructure and CI processing scripts. However, changes are isolated to test result processing and have been validated in v7.4 and v7.5 releases. No impact on runtime or production code.

…6789)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: TravisEz13 <10873629+TravisEz13@users.noreply.github.com>
Co-authored-by: Travis Plunk <travis.plunk@microsoft.com>
@daxian-dbw daxian-dbw requested a review from jshigetomi as a code owner March 9, 2026 22:23
Copilot AI review requested due to automatic review settings March 9, 2026 22:23
@daxian-dbw daxian-dbw requested a review from a team as a code owner March 9, 2026 22:23
@daxian-dbw daxian-dbw added the CL-Test Indicates that a PR should be marked as a test change in the Change Log label Mar 9, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Backports GitHub Actions annotations for Pester test failures to release/v7.6, improving CI failure visibility by emitting ::error workflow commands with file/line locations parsed from Pester stack traces.

Changes:

  • Add Get-PesterFailureFileInfo helper in build.psm1 to extract file path and line number from Pester 4/5 stack traces.
  • Update the process-pester-results GitHub Action script to emit ::error file=...,line=... annotations for failed test cases.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
build.psm1 Adds stack-trace parsing helper to locate failing test file/line for annotations.
.github/actions/test/process-pester-results/process-pester-results.ps1 Generates GitHub Actions error annotations for each failed Pester test case.

Comment on lines +72 to +84
# Create annotation title
$annotationTitle = "Test Failure: $description / $testName"

# Build the annotation message
$annotationMessage = $message -replace "`n", "%0A" -replace "`r"

# Build and output the workflow command
$workflowCommand = "::error file=$filePath"
if ($fileInfo.Line) {
$workflowCommand += ",line=$($fileInfo.Line)"
}
$workflowCommand += ",title=$annotationTitle::$annotationMessage"

Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

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

GitHub Actions workflow commands require escaping in both properties (file/title) and the message (at minimum %, \r, \n; and for properties also : and ,). As written, $annotationTitle contains : and $filePath can contain C:\ (also :) when the workspace-relative conversion doesn't happen, which can break parsing and prevent annotations from showing up. Please add a small escaping helper that follows the Actions command escaping rules and apply it to $filePath, $annotationTitle, and $annotationMessage before emitting ::error ....

Copilot uses AI. Check for mistakes.
Comment on lines +62 to +69
# GitHub Actions expects paths relative to the workspace root
if ($env:GITHUB_WORKSPACE) {
$workspacePath = $env:GITHUB_WORKSPACE
if ($filePath.StartsWith($workspacePath)) {
$filePath = $filePath.Substring($workspacePath.Length).TrimStart('/', '\')
# Normalize to forward slashes for consistency
$filePath = $filePath -replace '\\', '/'
}
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

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

The workspace-relative path conversion uses $filePath.StartsWith($workspacePath) with the default string comparison and without ensuring a trailing path separator. On Windows this can fail due to case differences (leaving an absolute C:\... path), and it can also incorrectly match sibling paths that share the same prefix. Consider normalizing both paths (e.g., GetFullPath), ensuring the workspace path ends with a separator, and using an ordinal/ignore-case comparison on Windows before doing the substring.

Copilot uses AI. Check for mistakes.
@daxian-dbw daxian-dbw merged commit a573afa into PowerShell:release/v7.6 Mar 9, 2026
49 of 51 checks passed
@daxian-dbw daxian-dbw deleted the backport/release/v7.6/26789-4db414ca3 branch March 9, 2026 23:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-Test Indicates that a PR should be marked as a test change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants