Skip to content

Commit b845aa0

Browse files
Log retrieval logic update (#232)
* Update log retrieval logic in Node.Tests.ps1 Refactor Get-UseNodeLogs function to find logs in runner root directory instead of home directory. * Update comment to reflect the correct directory Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Modify path retrieval logic --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 4175843 commit b845aa0

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

tests/Node.Tests.ps1

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,25 @@ Describe "Node.js" {
66

77
BeforeAll {
88
function Get-UseNodeLogs {
9-
# GitHub Windows images don't have `HOME` variable
10-
$homeDir = $env:HOME ?? $env:HOMEDRIVE
11-
12-
$possiblePaths = @(
13-
Join-Path -Path $homeDir -ChildPath "actions-runner/cached/_diag/pages"
14-
Join-Path -Path $homeDir -ChildPath "runners/*/_diag/pages"
15-
Join-Path -Path $homeDir -ChildPath "actions-runner/extracted/_diag/pages"
16-
)
9+
$runnerProc = Get-Process -Name "Runner.Listener" -ErrorAction SilentlyContinue | Select-Object -First 1
10+
#Write-Host "`$runnerProc: $($runnerProc | Out-String)"
11+
if (-not $runnerProc -or -not $runnerProc.Path) {
12+
Write-Error "Runner.Listener process not found."
13+
return
14+
}
15+
# Go up two directories to get runner root
16+
$runnerRoot = Split-Path (Split-Path $runnerProc.Path -Parent) -Parent
17+
#Write-Host "`$runnerRoot: $runnerRoot"
18+
# Recursively find all _diag/pages folders under the runner root directory
19+
$possiblePaths = Get-ChildItem -Path $runnerRoot -Directory -Recurse -Depth 4 -ErrorAction SilentlyContinue |
20+
Where-Object { $_.FullName -like "*_diag\pages" -or $_.FullName -like "*_diag/pages" }
21+
Write-Host "LogsPaths:"
22+
$possiblePaths | ForEach-Object { Write-Host $_.FullName }
1723

1824
$logsFolderPath = $possiblePaths | Where-Object { Test-Path $_ } | Select-Object -First 1
19-
$resolvedPath = Resolve-Path -Path $logsFolderPath -ErrorAction SilentlyContinue
25+
if ($logsFolderPath) {
26+
$resolvedPath = Resolve-Path -Path $logsFolderPath -ErrorAction SilentlyContinue
27+
}
2028

2129
if ($resolvedPath -and -not [string]::IsNullOrEmpty($resolvedPath.Path) -and (Test-Path $resolvedPath.Path)) {
2230
$useNodeLogFile = Get-ChildItem -Path $resolvedPath | Where-Object {

0 commit comments

Comments
 (0)