Skip to content

Commit 40c37f4

Browse files
Add new logs path related to runner migration (#117)
* Logs Path change * Updated logic * rename variable * Update logic
1 parent a377a0b commit 40c37f4

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

tests/Go.Tests.ps1

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,29 @@ Describe "Go" {
1010
function Get-UseGoLogs {
1111
# GitHub Windows images don't have `HOME` variable
1212
$homeDir = $env:HOME ?? $env:HOMEDRIVE
13-
$logsFolderPath = Join-Path -Path $homeDir -ChildPath "runners/*/_diag/pages" -Resolve
13+
$possiblePaths = @(
14+
Join-Path -Path $homeDir -ChildPath "actions-runner/cached/_diag/pages"
15+
Join-Path -Path $homeDir -ChildPath "runners/*/_diag/pages"
16+
)
17+
18+
$logsFolderPath = $possiblePaths | Where-Object { Test-Path $_ } | Select-Object -First 1
19+
$resolvedPath = Resolve-Path -Path $logsFolderPath -ErrorAction SilentlyContinue
20+
21+
if ($resolvedPath -and -not [string]::IsNullOrEmpty($resolvedPath.Path) -and (Test-Path $resolvedPath.Path)) {
22+
$useGoLogFile = Get-ChildItem -Path $resolvedPath | Where-Object {
23+
$logContent = Get-Content $_.Fullname -Raw
24+
return $logContent -match "setup-go@v"
25+
} | Select-Object -First 1
1426

15-
$useGoLogFile = Get-ChildItem -Path $logsFolderPath | Where-Object {
16-
$logContent = Get-Content $_.Fullname -Raw
17-
return $logContent -match "setup-go@v"
18-
} | Select-Object -First 1
19-
return $useGoLogFile.Fullname
27+
# Return the file name if a match is found
28+
if ($useGoLogFile) {
29+
return $useGoLogFile.FullName
30+
} else {
31+
Write-Error "No matching log file found in the specified path: $($resolvedPath.Path)"
32+
}
33+
} else {
34+
Write-Error "The provided logs folder path is null, empty, or does not exist: $logsFolderPath"
35+
}
2036
}
2137
}
2238

0 commit comments

Comments
 (0)