Skip to content

[release/v7.4] Add GitHub Actions annotations for Pester test failures#26800

Merged
adityapatwardhan merged 2 commits intoPowerShell:release/v7.4from
TravisEz13:backport/release/v7.4/26789-4db414ca3
Feb 20, 2026
Merged

[release/v7.4] Add GitHub Actions annotations for Pester test failures#26800
adityapatwardhan merged 2 commits intoPowerShell:release/v7.4from
TravisEz13:backport/release/v7.4/26789-4db414ca3

Conversation

@TravisEz13
Copy link
Member

Backport of #26789 to release/v7.4

Triggered by @TravisEz13 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)

Adds GitHub Actions workflow annotations for Pester test failures, providing clickable file annotations with direct links to failing test code and workflow logs. This improves debugging experience in CI but is not required for builds to succeed.

Customer Impact

  • Customer reported
  • Found internally

Regression

REQUIRED: Check exactly one box.

  • Yes
  • No

This is not a regression.

Testing

Comprehensive testing performed including Pester 4/5 support, cross-platform path handling, absolute to relative path conversion, and PSScriptAnalyzer compliance. The feature was validated through actual CI execution in the original PR.

Risk

REQUIRED: Check exactly one box.

  • High
  • Medium
  • Low

Medium risk - adds new functionality to CI test result processing without affecting core engine or existing code paths. Changes are well-contained to test infrastructure (build.psm1 and process-pester-results.ps1). The feature is backward compatible and has been validated in the original PR merge.

…6789)

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: TravisEz13 <[email protected]>
Co-authored-by: Travis Plunk <[email protected]>
@TravisEz13 TravisEz13 requested a review from a team as a code owner February 12, 2026 22:57
Copilot AI review requested due to automatic review settings February 12, 2026 22:57
@TravisEz13 TravisEz13 added the CL-Test Indicates that a PR should be marked as a test change in the Change Log label Feb 12, 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

This pull request backports #26789 to the release/v7.4 branch, adding GitHub Actions workflow annotations for Pester test failures. When tests fail in GitHub Actions, the changes automatically generate clickable file annotations with direct links to the failing test code and workflow logs, improving debugging efficiency for CI/CD workflows.

Changes:

  • Adds Get-PesterFailureFileInfo helper function to parse Pester stack traces and extract file paths and line numbers
  • Extends process-pester-results.ps1 to generate GitHub Actions workflow command annotations for test failures
  • Supports both Pester 4 and Pester 5 stack trace formats with cross-platform path handling (Unix and Windows)

Reviewed changes

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

File Description
build.psm1 Adds Get-PesterFailureFileInfo function to parse Pester stack traces and extract file location information using multiple regex patterns for Pester 4/5 compatibility
.github/actions/test/process-pester-results/process-pester-results.ps1 Generates GitHub Actions annotations by parsing test failure XML, extracting file locations, converting absolute paths to relative paths, and outputting workflow commands with clickable links

Comment on lines +73 to +83
$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 Feb 12, 2026

Choose a reason for hiding this comment

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

The annotation title could potentially contain special characters like double colons (::) or commas (,) that have special meaning in GitHub Actions workflow commands. If a test name or description contains these characters, it could break the workflow command parsing.

Consider escaping or sanitizing the annotation title to prevent parsing issues. For example, replace : with a safe character or URL-encode special characters. This is particularly important if test names can contain arbitrary user input.

Copilot uses AI. Check for mistakes.
# GitHub Actions expects paths relative to the workspace root
if ($env:GITHUB_WORKSPACE) {
$workspacePath = $env:GITHUB_WORKSPACE
if ($filePath.StartsWith($workspacePath)) {
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

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

The path comparison using .StartsWith($workspacePath) without specifying a StringComparison parameter is case-sensitive on Unix-like systems. This could cause the path conversion to fail on case-sensitive filesystems if the case doesn't match exactly.

For cross-platform compatibility, use .StartsWith($workspacePath, [System.StringComparison]::OrdinalIgnoreCase) to ensure case-insensitive comparison. This pattern is consistently used elsewhere in the codebase for path comparisons.

Suggested change
if ($filePath.StartsWith($workspacePath)) {
if ($filePath.StartsWith($workspacePath, [System.StringComparison]::OrdinalIgnoreCase)) {

Copilot uses AI. Check for mistakes.
@adityapatwardhan
Copy link
Member

@copilot open a new pull request to apply changes based on the comments in this thread

@adityapatwardhan adityapatwardhan merged commit b827288 into PowerShell:release/v7.4 Feb 20, 2026
39 checks passed
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