mirror of
https://github.com/actions/node-versions.git
synced 2026-01-14 12:00:41 +08:00
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>
This commit is contained in:
@@ -6,17 +6,25 @@ Describe "Node.js" {
|
||||
|
||||
BeforeAll {
|
||||
function Get-UseNodeLogs {
|
||||
# GitHub Windows images don't have `HOME` variable
|
||||
$homeDir = $env:HOME ?? $env:HOMEDRIVE
|
||||
|
||||
$possiblePaths = @(
|
||||
Join-Path -Path $homeDir -ChildPath "actions-runner/cached/_diag/pages"
|
||||
Join-Path -Path $homeDir -ChildPath "runners/*/_diag/pages"
|
||||
Join-Path -Path $homeDir -ChildPath "actions-runner/extracted/_diag/pages"
|
||||
)
|
||||
$runnerProc = Get-Process -Name "Runner.Listener" -ErrorAction SilentlyContinue | Select-Object -First 1
|
||||
#Write-Host "`$runnerProc: $($runnerProc | Out-String)"
|
||||
if (-not $runnerProc -or -not $runnerProc.Path) {
|
||||
Write-Error "Runner.Listener process not found."
|
||||
return
|
||||
}
|
||||
# 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 the runner root directory
|
||||
$possiblePaths = Get-ChildItem -Path $runnerRoot -Directory -Recurse -Depth 4 -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
|
||||
$resolvedPath = Resolve-Path -Path $logsFolderPath -ErrorAction SilentlyContinue
|
||||
if ($logsFolderPath) {
|
||||
$resolvedPath = Resolve-Path -Path $logsFolderPath -ErrorAction SilentlyContinue
|
||||
}
|
||||
|
||||
if ($resolvedPath -and -not [string]::IsNullOrEmpty($resolvedPath.Path) -and (Test-Path $resolvedPath.Path)) {
|
||||
$useNodeLogFile = Get-ChildItem -Path $resolvedPath | Where-Object {
|
||||
|
||||
Reference in New Issue
Block a user