Skip to content

Commit 2f48f5f

Browse files
Add new logs path related to runner migration (#211)
* Update paths * update logic * Updated logic * Update log Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent 7bff9a2 commit 2f48f5f

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

tests/Node.Tests.ps1

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,30 @@ Describe "Node.js" {
88
function Get-UseNodeLogs {
99
# GitHub Windows images don't have `HOME` variable
1010
$homeDir = $env:HOME ?? $env:HOMEDRIVE
11-
$logsFolderPath = Join-Path -Path $homeDir -ChildPath "runners/*/_diag/pages" -Resolve
12-
13-
$useNodeLogFile = Get-ChildItem -Path $logsFolderPath | Where-Object {
14-
$logContent = Get-Content $_.Fullname -Raw
15-
return $logContent -match "setup-node@v"
16-
} | Select-Object -First 1
17-
return $useNodeLogFile.Fullname
11+
12+
$possiblePaths = @(
13+
Join-Path -Path $homeDir -ChildPath "actions-runner/cached/_diag/pages"
14+
Join-Path -Path $homeDir -ChildPath "runners/*/_diag/pages"
15+
)
16+
17+
$logsFolderPath = $possiblePaths | Where-Object { Test-Path $_ } | Select-Object -First 1
18+
$resolvedPath = Resolve-Path -Path $logsFolderPath -ErrorAction SilentlyContinue
19+
20+
if ($resolvedPath -and -not [string]::IsNullOrEmpty($resolvedPath.Path) -and (Test-Path $resolvedPath.Path)) {
21+
$useNodeLogFile = Get-ChildItem -Path $resolvedPath | Where-Object {
22+
$logContent = Get-Content $_.Fullname -Raw
23+
return $logContent -match "setup-node@v"
24+
} | Select-Object -First 1
25+
26+
# Return the file name if a match is found
27+
if ($useNodeLogFile) {
28+
return $useNodeLogFile.FullName
29+
} else {
30+
Write-Error "No matching log file found in the specified path: $($resolvedPath.Path)"
31+
}
32+
} else {
33+
Write-Error "The provided logs folder path is null, empty, or does not exist: $logsFolderPath"
34+
}
1835
}
1936
}
2037

0 commit comments

Comments
 (0)