mirror of
https://github.com/actions/runner-images.git
synced 2025-12-30 05:49:48 +08:00
added additional logging
This commit is contained in:
@@ -11,10 +11,10 @@ function Validate-Scripts {
|
||||
Get-ChildItem $path -Recurse -File -Filter "*.sh" | ForEach-Object {
|
||||
$shebangLine = Get-Content -Path $($_.FullName)| Select-Object -First 1
|
||||
if ($shebangLine -eq $ExpectedShebang) {
|
||||
Write-Host "Pattern '$ExpectedShebang' found in '$($_.FullName)'"
|
||||
Write-Host "[+] '$($_.FullName)'"
|
||||
}
|
||||
else {
|
||||
Write-Host "Pattern '$ExpectedShebang' not found in '$($_.FullName)'"
|
||||
Write-Host "[-] '$($_.FullName)'"
|
||||
$ScriptWithoutShebangLine += $($_.FullName)
|
||||
}
|
||||
}
|
||||
@@ -23,12 +23,20 @@ function Validate-Scripts {
|
||||
|
||||
$PathUbuntu = "./images/linux/scripts"
|
||||
$PathMacOS = "./images/macos/provision"
|
||||
$PatternUbuntu = "#!/bin/bash -e"
|
||||
$PatternMacOS = "#!/bin/bash -e -o pipefail"
|
||||
$ScriptsWithBrokenShebang = @()
|
||||
$ScriptsWithBrokenShebang += Validate-Scripts -Path $PathUbuntu -ExpectedShebang "#!/bin/bash -e"
|
||||
$ScriptsWithBrokenShebang += Validate-Scripts -Path $PathMacOS -ExpectedShebang "#!/bin/bash -e -o pipefail"
|
||||
$ScriptsWithBrokenShebang += Validate-Scripts -Path $PathUbuntu -ExpectedShebang $PatternUbuntu
|
||||
$ScriptsWithBrokenShebang += Validate-Scripts -Path $PathMacOS -ExpectedShebang $PatternMacOS
|
||||
if ($ScriptsWithBrokenShebang.Length -gt 0) {
|
||||
Write-Host "The following scripts have incorrect shebang:"
|
||||
$ScriptsWithBrokenShebang | ForEach-Object {
|
||||
Write-Warning "The following script does not contain shebang: '$_'"
|
||||
Write-Host "- '$_'"
|
||||
}
|
||||
Write-Host "Expected shebang for scripts in 'images/linux' folder is '$PatternUbuntu'"
|
||||
Write-Host "Expected shebang for scripts in 'images/macos' folder is '$PatternMacOS'"
|
||||
exit 1
|
||||
else {
|
||||
Write-Host "All scripts have correct shebang."
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user