mirror of
https://github.com/actions/runner-images.git
synced 2025-12-20 06:35:47 +00:00
last comments resolved.
This commit is contained in:
@@ -7,16 +7,16 @@ function Validate-Scripts {
|
|||||||
[Parameter(Mandatory=$true)]
|
[Parameter(Mandatory=$true)]
|
||||||
[string]$ExpectedShebang
|
[string]$ExpectedShebang
|
||||||
)
|
)
|
||||||
$ScriptWithoutShebangLine = @()
|
$ScriptWithoutShebangLine = @()
|
||||||
Get-ChildItem $path -Recurse -File -Filter "*.sh" | ForEach-Object {
|
Get-ChildItem $path -Recurse -File -Filter "*.sh" | ForEach-Object {
|
||||||
$shebangLine = Get-Content -Path $($_.FullName) | Select-Object -First 1
|
$shebangLine = Get-Content -Path $($_.FullName) | Select-Object -First 1
|
||||||
if ($shebangLine -eq $ExpectedShebang) {
|
if ($shebangLine -eq $ExpectedShebang) {
|
||||||
Write-Host "Pattern '$ExpectedShebang' found in '$($_.FullName)'"
|
Write-Host "Pattern '$ExpectedShebang' found in '$($_.FullName)'"
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Write-Host "Pattern '$ExpectedShebang' not found in '$($_.FullName)'"
|
Write-Host "Pattern '$ExpectedShebang' not found in '$($_.FullName)'"
|
||||||
$ScriptWithoutShebangLine += $($_.FullName)
|
$ScriptWithoutShebangLine += $($_.FullName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $ScriptWithoutShebangLine
|
return $ScriptWithoutShebangLine
|
||||||
}
|
}
|
||||||
@@ -24,13 +24,11 @@ function Validate-Scripts {
|
|||||||
$PathUbuntu = "./images/linux/scripts"
|
$PathUbuntu = "./images/linux/scripts"
|
||||||
$PathMacOS = "./images/macos/provision"
|
$PathMacOS = "./images/macos/provision"
|
||||||
$ScriptsWithBrokenShebang = @()
|
$ScriptsWithBrokenShebang = @()
|
||||||
# Check Ubuntu contains required shebang string
|
|
||||||
$ScriptsWithBrokenShebang += Validate-Scripts -Path $PathUbuntu -Pattern "#!/bin/bash -e"
|
$ScriptsWithBrokenShebang += Validate-Scripts -Path $PathUbuntu -Pattern "#!/bin/bash -e"
|
||||||
# Check MacOS contains required shebang string
|
|
||||||
$ScriptsWithBrokenShebang += Validate-Scripts -Path $PathMacOS -Pattern "#!/bin/bash -e -o pipefail"
|
$ScriptsWithBrokenShebang += Validate-Scripts -Path $PathMacOS -Pattern "#!/bin/bash -e -o pipefail"
|
||||||
if ($ScriptsWithBrokenShebang.Length -gt 0) {
|
if ($ScriptsWithBrokenShebang.Length -gt 0) {
|
||||||
$ScriptsWithBrokenShebang | ForEach-Object {
|
$ScriptsWithBrokenShebang | ForEach-Object {
|
||||||
Write-Warning "The following script does not contain shebang: '$_'"
|
Write-Warning "The following script does not contain shebang: '$_'"
|
||||||
}
|
}
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user