From 2f48f5f179e63c6a4fd49759a2c5b52f38d5ce9a Mon Sep 17 00:00:00 2001 From: Haritha <73516759+HarithaVattikuti@users.noreply.github.com> Date: Thu, 10 Jul 2025 21:36:51 -0500 Subject: [PATCH] Add new logs path related to runner migration (#211) * Update paths * update logic * Updated logic * Update log Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- tests/Node.Tests.ps1 | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/tests/Node.Tests.ps1 b/tests/Node.Tests.ps1 index dbc2bea..4f0b01a 100644 --- a/tests/Node.Tests.ps1 +++ b/tests/Node.Tests.ps1 @@ -8,13 +8,30 @@ Describe "Node.js" { function Get-UseNodeLogs { # GitHub Windows images don't have `HOME` variable $homeDir = $env:HOME ?? $env:HOMEDRIVE - $logsFolderPath = Join-Path -Path $homeDir -ChildPath "runners/*/_diag/pages" -Resolve - - $useNodeLogFile = Get-ChildItem -Path $logsFolderPath | Where-Object { - $logContent = Get-Content $_.Fullname -Raw - return $logContent -match "setup-node@v" - } | Select-Object -First 1 - return $useNodeLogFile.Fullname + + $possiblePaths = @( + Join-Path -Path $homeDir -ChildPath "actions-runner/cached/_diag/pages" + Join-Path -Path $homeDir -ChildPath "runners/*/_diag/pages" + ) + + $logsFolderPath = $possiblePaths | Where-Object { Test-Path $_ } | Select-Object -First 1 + $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 { + $logContent = Get-Content $_.Fullname -Raw + return $logContent -match "setup-node@v" + } | Select-Object -First 1 + + # Return the file name if a match is found + if ($useNodeLogFile) { + return $useNodeLogFile.FullName + } else { + Write-Error "No matching log file found in the specified path: $($resolvedPath.Path)" + } + } else { + Write-Error "The provided logs folder path is null, empty, or does not exist: $logsFolderPath" + } } }