Skip to content

Commit 9b85763

Browse files
CopilotTravisEz13
andcommitted
Convert file paths to relative paths for GitHub Actions annotations
- GitHub Actions expects paths relative to workspace root, not absolute paths - Added path conversion logic using GITHUB_WORKSPACE environment variable - Normalizes paths to use forward slashes for consistency - Handles both Unix and Windows absolute paths - Relative paths remain unchanged Co-authored-by: TravisEz13 <[email protected]>
1 parent 6605c89 commit 9b85763

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

build.psm1

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1867,14 +1867,27 @@ $stack_trace
18671867
$fileInfo = Get-PesterFailureFileInfo -StackTraceString $stack_trace
18681868

18691869
if ($fileInfo.File) {
1870+
# Convert absolute path to relative path for GitHub Actions
1871+
$filePath = $fileInfo.File
1872+
1873+
# GitHub Actions expects paths relative to the workspace root
1874+
if ($env:GITHUB_WORKSPACE) {
1875+
$workspacePath = $env:GITHUB_WORKSPACE
1876+
if ($filePath.StartsWith($workspacePath)) {
1877+
$filePath = $filePath.Substring($workspacePath.Length).TrimStart('/', '\')
1878+
# Normalize to forward slashes for consistency
1879+
$filePath = $filePath -replace '\\', '/'
1880+
}
1881+
}
1882+
18701883
# Create annotation title
18711884
$annotationTitle = "Test Failure: $description / $name"
18721885

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

18761889
# Build the workflow command
1877-
$workflowCommand = "::error file=$($fileInfo.File)"
1890+
$workflowCommand = "::error file=$filePath"
18781891
if ($fileInfo.Line) {
18791892
$workflowCommand += ",line=$($fileInfo.Line)"
18801893
}

0 commit comments

Comments
 (0)