Update log retrieval logic in Node.Tests.ps1

Refactor Get-UseNodeLogs function to find logs in runner root directory instead of home directory.
This commit is contained in:
Haritha
2026-01-13 14:20:24 -06:00
committed by GitHub
parent 4175843c81
commit 0badf909f6

View File

@@ -6,14 +6,20 @@ Describe "Node.js" {
BeforeAll { BeforeAll {
function Get-UseNodeLogs { function Get-UseNodeLogs {
# GitHub Windows images don't have `HOME` variable $runnerProc = Get-Process -Name "Runner.Listener" -ErrorAction SilentlyContinue | Select-Object -First 1
$homeDir = $env:HOME ?? $env:HOMEDRIVE #Write-Host "`$runnerProc: $($runnerProc | Out-String)"
if (-not $runnerProc -or -not $runnerProc.Path) {
$possiblePaths = @( Write-Error "Runner.Listener process not found."
Join-Path -Path $homeDir -ChildPath "actions-runner/cached/_diag/pages" return
Join-Path -Path $homeDir -ChildPath "runners/*/_diag/pages" }
Join-Path -Path $homeDir -ChildPath "actions-runner/extracted/_diag/pages" # Go up two directories to get runner root
) $runnerRoot = Split-Path (Split-Path $runnerProc.Path -Parent) -Parent
#Write-Host "`$runnerRoot: $runnerRoot"
# Recursively find all _diag/pages folders under $homeDir(not homedir-replace with runnerroot)
$possiblePaths = Get-ChildItem -Path $runnerRoot -Directory -Recurse -ErrorAction SilentlyContinue |
Where-Object { $_.FullName -like "*_diag\pages" -or $_.FullName -like "*_diag/pages" }
Write-Host "`LogsPaths:"
$possiblePaths | ForEach-Object { Write-Host $_.FullName }
$logsFolderPath = $possiblePaths | Where-Object { Test-Path $_ } | Select-Object -First 1 $logsFolderPath = $possiblePaths | Where-Object { Test-Path $_ } | Select-Object -First 1
$resolvedPath = Resolve-Path -Path $logsFolderPath -ErrorAction SilentlyContinue $resolvedPath = Resolve-Path -Path $logsFolderPath -ErrorAction SilentlyContinue