mirror of
https://github.com/actions/runner-images.git
synced 2025-12-16 06:40:32 +00:00
added new linter
This commit is contained in:
@@ -9,17 +9,16 @@ function Validate-Scripts {
|
|||||||
)
|
)
|
||||||
$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
|
$relativePath = Resolve-Path $_.FullName -Relative
|
||||||
|
$shebangLine = Get-Content -Path $.FullName | Select-Object -First 1
|
||||||
if ($shebangLine -eq $ExpectedShebang) {
|
if ($shebangLine -eq $ExpectedShebang) {
|
||||||
Write-Host "[+] '$($_.FullName)'"
|
Write-Host "[+] '$relativePath'"
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Write-Host "[-] '$($_.FullName)'"
|
Write-Host "[-] 'relativePath'"
|
||||||
$ScriptWithoutShebangLine += $($_.FullName)
|
$ScriptWithoutShebangLine += $relativePath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $ScriptWithoutShebangLine
|
|
||||||
}
|
|
||||||
|
|
||||||
$PathUbuntu = "./images/linux/scripts"
|
$PathUbuntu = "./images/linux/scripts"
|
||||||
$PathMacOS = "./images/macos/provision"
|
$PathMacOS = "./images/macos/provision"
|
||||||
@@ -29,11 +28,11 @@ $ScriptsWithBrokenShebang = @()
|
|||||||
$ScriptsWithBrokenShebang += Validate-Scripts -Path $PathUbuntu -ExpectedShebang $PatternUbuntu
|
$ScriptsWithBrokenShebang += Validate-Scripts -Path $PathUbuntu -ExpectedShebang $PatternUbuntu
|
||||||
$ScriptsWithBrokenShebang += Validate-Scripts -Path $PathMacOS -ExpectedShebang $PatternMacOS
|
$ScriptsWithBrokenShebang += Validate-Scripts -Path $PathMacOS -ExpectedShebang $PatternMacOS
|
||||||
if ($ScriptsWithBrokenShebang.Length -gt 0) {
|
if ($ScriptsWithBrokenShebang.Length -gt 0) {
|
||||||
Write-Host "The following scripts have incorrect shebang:"
|
Write-Host "`n`n`n##[error] The following scripts have incorrect shebang:"
|
||||||
$ScriptsWithBrokenShebang | ForEach-Object {
|
$ScriptsWithBrokenShebang | ForEach-Object {
|
||||||
Write-Host "##[error] - '$_'"
|
Write-Host "##[error] '$_'"
|
||||||
}
|
}
|
||||||
Write-Host "##[error] Expected shebang for scripts in 'images/linux' folder is '$PatternUbuntu'"
|
Write-Host "`n`n##[error] Expected shebang for scripts in 'images/linux' folder is '$PatternUbuntu'"
|
||||||
Write-Host "##[error] Expected shebang for scripts in 'images/macos' folder is '$PatternMacOS'"
|
Write-Host "##[error] Expected shebang for scripts in 'images/macos' folder is '$PatternMacOS'"
|
||||||
exit 1
|
exit 1
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user