mirror of
https://github.com/actions/node-versions.git
synced 2025-04-20 02:43:49 +00:00
Update Node.Tests.ps1
This commit is contained in:
parent
f8eaf50e03
commit
ad4d6a9a31
@ -2,14 +2,28 @@ Import-Module (Join-Path $PSScriptRoot "../helpers/pester-extensions.psm1")
|
|||||||
|
|
||||||
BeforeAll {
|
BeforeAll {
|
||||||
function Get-UseNodeLogs {
|
function Get-UseNodeLogs {
|
||||||
# GitHub Windows images don't have `HOME` variable
|
# Determine if the current environment is Windows or Linux
|
||||||
$homeDir = $env:HOME ?? $env:HOMEDRIVE
|
$isWindows = $PSVersionTable.PSVersion.Platform -eq "Win32NT"
|
||||||
$logsFolderPath = Join-Path -Path $homeDir -ChildPath "runners/*/_diag/pages" -Resolve
|
$isArm64 = $env:PROCESSOR_ARCHITECTURE -eq "ARM64"
|
||||||
|
|
||||||
|
# For Windows, use HOMEDRIVE if HOME is not available
|
||||||
|
# For Linux, use HOME directly
|
||||||
|
$homeDir = if ($isWindows) { $env:HOME ?? $env:HOMEDRIVE } else { $env:HOME }
|
||||||
|
|
||||||
|
# Check if the OS is Windows ARM64 or Linux ARM64 and set the logs folder path accordingly
|
||||||
|
if ($isWindows -and $isArm64) {
|
||||||
|
$logsFolderPath = Join-Path -Path $homeDir -ChildPath "runners/_diag/pages" -Resolve
|
||||||
|
} elseif (-not $isWindows -and $isArm64) {
|
||||||
|
$logsFolderPath = Join-Path -Path $homeDir -ChildPath "runners/_diag/pages" -Resolve
|
||||||
|
} else {
|
||||||
|
throw "Unsupported OS or architecture."
|
||||||
|
}
|
||||||
|
|
||||||
$useNodeLogFile = Get-ChildItem -Path $logsFolderPath | Where-Object {
|
$useNodeLogFile = Get-ChildItem -Path $logsFolderPath | Where-Object {
|
||||||
$logContent = Get-Content $_.Fullname -Raw
|
$logContent = Get-Content $_.Fullname -Raw
|
||||||
return $logContent -match "setup-node@v"
|
return $logContent -match "setup-node@v"
|
||||||
} | Select-Object -First 1
|
} | Select-Object -First 1
|
||||||
|
|
||||||
return $useNodeLogFile.Fullname
|
return $useNodeLogFile.Fullname
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user