File tree Expand file tree Collapse file tree 1 file changed +22
-6
lines changed Expand file tree Collapse file tree 1 file changed +22
-6
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments