From a766bb164b81e837ab566c4993f7ef97bae4128c Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev Date: Tue, 13 Oct 2020 02:45:29 +0700 Subject: [PATCH 01/28] added linter for ubuntu --- images.CI/linux-and-win/lint_ubuntu.ps1 | 34 +++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 images.CI/linux-and-win/lint_ubuntu.ps1 diff --git a/images.CI/linux-and-win/lint_ubuntu.ps1 b/images.CI/linux-and-win/lint_ubuntu.ps1 new file mode 100644 index 000000000..7adcf70b9 --- /dev/null +++ b/images.CI/linux-and-win/lint_ubuntu.ps1 @@ -0,0 +1,34 @@ +param( + [Parameter(Mandatory)] [string] $path, + [Parameter(Mandatory)] [string] $pattern +) + +$ErrorActionPreference = "Stop" + +function Validate-Scripts { + Param ( + [Parameter(Mandatory=$true)] + [string[]]$Path, + [Parameter(Mandatory=$true)] + [string]$Pattern + ) + $WrongScript = New-Object System.Collections.Generic.List[System.Object] + Get-ChildItem $path | ForEach-Object { + if (Select-String -Path $($_.FullName) -Pattern $Pattern -Quiet) { + Write-Host "Pattern '$pattern' found in '$($_.FullName)'" + } + else { + Write-Host "Pattern '$pattern' not found in '$($_.FullName)'" + $WrongScript += $($_.FullName) + } + } + return $WrongScript +} + +$FailedScripts = Validate-Scripts -Path $path -Pattern "#/bin/bash -e" +if ($FailedScripts.Length -gt 0) { + $FailedScripts | ForEach-Object { + Write-Warning "The following script does not contain shebang: '$_'" + } + exit 1 +} \ No newline at end of file From 374bf8e5cddd2e849017fb2d0601ccb47d4a33e2 Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev Date: Tue, 13 Oct 2020 17:10:22 +0700 Subject: [PATCH 02/28] resolve comments --- images.CI/lint-shebang.ps1 | 34 +++++++++++++++++++++++++ images.CI/linux-and-win/lint_ubuntu.ps1 | 34 ------------------------- 2 files changed, 34 insertions(+), 34 deletions(-) create mode 100644 images.CI/lint-shebang.ps1 delete mode 100644 images.CI/linux-and-win/lint_ubuntu.ps1 diff --git a/images.CI/lint-shebang.ps1 b/images.CI/lint-shebang.ps1 new file mode 100644 index 000000000..6a2789f53 --- /dev/null +++ b/images.CI/lint-shebang.ps1 @@ -0,0 +1,34 @@ +param( + [Parameter(Mandatory)] [string] $path, + [Parameter(Mandatory)] [string] $pattern +) + +$ErrorActionPreference = "Stop" + +function Validate-Scripts { + Param ( + [Parameter(Mandatory=$true)] + [string[]]$Path, + [Parameter(Mandatory=$true)] + [string]$Pattern + ) + $ScriptsWithBrokenShebang = @() + Get-ChildItem $path | ForEach-Object { + if (Get-Content -Path $($_.FullName) | Select-Object -First 1 | Select-String -Pattern $Pattern -Quiet) { + Write-Host "Pattern '$Pattern' found in '$($_.FullName)'" + } + else { + Write-Host "Pattern '$Pattern' not found in '$($_.FullName)'" + $ScriptsWithBrokenShebang += $($_.FullName) + } + } + return $ScriptsWithBrokenShebang +} + +$ScriptsWithBrokenShebang = Validate-Scripts -Path $path -Pattern "#!/bin/bash -e" +if ($ScriptsWithBrokenShebang.Length -gt 0) { + $ScriptsWithBrokenShebang | ForEach-Object { + Write-Warning "The following script does not contain shebang: '$_'" + } + exit 1 +} \ No newline at end of file diff --git a/images.CI/linux-and-win/lint_ubuntu.ps1 b/images.CI/linux-and-win/lint_ubuntu.ps1 deleted file mode 100644 index 7adcf70b9..000000000 --- a/images.CI/linux-and-win/lint_ubuntu.ps1 +++ /dev/null @@ -1,34 +0,0 @@ -param( - [Parameter(Mandatory)] [string] $path, - [Parameter(Mandatory)] [string] $pattern -) - -$ErrorActionPreference = "Stop" - -function Validate-Scripts { - Param ( - [Parameter(Mandatory=$true)] - [string[]]$Path, - [Parameter(Mandatory=$true)] - [string]$Pattern - ) - $WrongScript = New-Object System.Collections.Generic.List[System.Object] - Get-ChildItem $path | ForEach-Object { - if (Select-String -Path $($_.FullName) -Pattern $Pattern -Quiet) { - Write-Host "Pattern '$pattern' found in '$($_.FullName)'" - } - else { - Write-Host "Pattern '$pattern' not found in '$($_.FullName)'" - $WrongScript += $($_.FullName) - } - } - return $WrongScript -} - -$FailedScripts = Validate-Scripts -Path $path -Pattern "#/bin/bash -e" -if ($FailedScripts.Length -gt 0) { - $FailedScripts | ForEach-Object { - Write-Warning "The following script does not contain shebang: '$_'" - } - exit 1 -} \ No newline at end of file From fe4def773996201394af79bae3baf605d01402f3 Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev Date: Tue, 13 Oct 2020 17:24:06 +0700 Subject: [PATCH 03/28] resolve comments. --- images.CI/lint-shebang.ps1 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/images.CI/lint-shebang.ps1 b/images.CI/lint-shebang.ps1 index 6a2789f53..ffed13bd6 100644 --- a/images.CI/lint-shebang.ps1 +++ b/images.CI/lint-shebang.ps1 @@ -12,20 +12,22 @@ function Validate-Scripts { [Parameter(Mandatory=$true)] [string]$Pattern ) - $ScriptsWithBrokenShebang = @() + $ScriptWithoutShebangLine = @() Get-ChildItem $path | ForEach-Object { if (Get-Content -Path $($_.FullName) | Select-Object -First 1 | Select-String -Pattern $Pattern -Quiet) { Write-Host "Pattern '$Pattern' found in '$($_.FullName)'" } else { Write-Host "Pattern '$Pattern' not found in '$($_.FullName)'" - $ScriptsWithBrokenShebang += $($_.FullName) + $ScriptWithoutShebangLine += $($_.FullName) } } - return $ScriptsWithBrokenShebang + return $ScriptWithoutShebangLine } -$ScriptsWithBrokenShebang = Validate-Scripts -Path $path -Pattern "#!/bin/bash -e" +$ScriptsWithBrokenShebang = @() +$ScriptsWithBrokenShebang += Validate-Scripts -Path $path1 -Pattern "#!/bin/bash -e" +$ScriptsWithBrokenShebang += Validate-Scripts -Path $path2 -Pattern "#!/bin/bash -e" if ($ScriptsWithBrokenShebang.Length -gt 0) { $ScriptsWithBrokenShebang | ForEach-Object { Write-Warning "The following script does not contain shebang: '$_'" From 4f08343661c445b8a901c7923958f3494f7bcffd Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev Date: Tue, 13 Oct 2020 17:25:30 +0700 Subject: [PATCH 04/28] added comments --- images.CI/lint-shebang.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/images.CI/lint-shebang.ps1 b/images.CI/lint-shebang.ps1 index ffed13bd6..9e38bda22 100644 --- a/images.CI/lint-shebang.ps1 +++ b/images.CI/lint-shebang.ps1 @@ -26,8 +26,10 @@ function Validate-Scripts { } $ScriptsWithBrokenShebang = @() +# Check Ubuntu contains required shebang string $ScriptsWithBrokenShebang += Validate-Scripts -Path $path1 -Pattern "#!/bin/bash -e" -$ScriptsWithBrokenShebang += Validate-Scripts -Path $path2 -Pattern "#!/bin/bash -e" +# Check MacOS contains required shebang string +$ScriptsWithBrokenShebang += Validate-Scripts -Path $path2 -Pattern "#!/bin/bash -e -o pipefail" if ($ScriptsWithBrokenShebang.Length -gt 0) { $ScriptsWithBrokenShebang | ForEach-Object { Write-Warning "The following script does not contain shebang: '$_'" From e88c5b8f09fdfae6d0c8a427d7847c7e2ae1f4c3 Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev Date: Tue, 13 Oct 2020 17:55:00 +0700 Subject: [PATCH 05/28] added all changes. --- images.CI/lint-shebang.ps1 | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/images.CI/lint-shebang.ps1 b/images.CI/lint-shebang.ps1 index 9e38bda22..233ed3344 100644 --- a/images.CI/lint-shebang.ps1 +++ b/images.CI/lint-shebang.ps1 @@ -1,8 +1,3 @@ -param( - [Parameter(Mandatory)] [string] $path, - [Parameter(Mandatory)] [string] $pattern -) - $ErrorActionPreference = "Stop" function Validate-Scripts { @@ -10,29 +5,32 @@ function Validate-Scripts { [Parameter(Mandatory=$true)] [string[]]$Path, [Parameter(Mandatory=$true)] - [string]$Pattern + [string]$ExpectedShebang ) $ScriptWithoutShebangLine = @() - Get-ChildItem $path | ForEach-Object { - if (Get-Content -Path $($_.FullName) | Select-Object -First 1 | Select-String -Pattern $Pattern -Quiet) { - Write-Host "Pattern '$Pattern' found in '$($_.FullName)'" + 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)'" } else { - Write-Host "Pattern '$Pattern' not found in '$($_.FullName)'" - $ScriptWithoutShebangLine += $($_.FullName) + Write-Host "Pattern '$ExpectedShebang' not found in '$($_.FullName)'" + $ScriptWithoutShebangLine += $($_.FullName) } } return $ScriptWithoutShebangLine } +$PathUbuntu = "./images/linux/scripts" +$PathMacOS = "./images/macos/provision" $ScriptsWithBrokenShebang = @() # Check Ubuntu contains required shebang string -$ScriptsWithBrokenShebang += Validate-Scripts -Path $path1 -Pattern "#!/bin/bash -e" +$ScriptsWithBrokenShebang += Validate-Scripts -Path $PathUbuntu -Pattern "#!/bin/bash -e" # Check MacOS contains required shebang string -$ScriptsWithBrokenShebang += Validate-Scripts -Path $path2 -Pattern "#!/bin/bash -e -o pipefail" +$ScriptsWithBrokenShebang += Validate-Scripts -Path $PathMacOS -Pattern "#!/bin/bash -e -o pipefail" if ($ScriptsWithBrokenShebang.Length -gt 0) { $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 } \ No newline at end of file From a191335ab6d7d44c9fba5d9df4557daf3ce6b049 Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev Date: Tue, 13 Oct 2020 18:06:14 +0700 Subject: [PATCH 06/28] last comments resolved. --- .../{lint-shebang.ps1 => shebang-linter.ps1} | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) rename images.CI/{lint-shebang.ps1 => shebang-linter.ps1} (72%) diff --git a/images.CI/lint-shebang.ps1 b/images.CI/shebang-linter.ps1 similarity index 72% rename from images.CI/lint-shebang.ps1 rename to images.CI/shebang-linter.ps1 index 233ed3344..f031f4a64 100644 --- a/images.CI/lint-shebang.ps1 +++ b/images.CI/shebang-linter.ps1 @@ -7,16 +7,16 @@ function Validate-Scripts { [Parameter(Mandatory=$true)] [string]$ExpectedShebang ) - $ScriptWithoutShebangLine = @() - Get-ChildItem $path -Recurse -File -Filter "*.sh" | ForEach-Object { - $shebangLine = Get-Content -Path $($_.FullName) | Select-Object -First 1 - if ($shebangLine -eq $ExpectedShebang) { + $ScriptWithoutShebangLine = @() + 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)'" - } - else { + } + else { Write-Host "Pattern '$ExpectedShebang' not found in '$($_.FullName)'" $ScriptWithoutShebangLine += $($_.FullName) - } + } } return $ScriptWithoutShebangLine } @@ -24,13 +24,11 @@ function Validate-Scripts { $PathUbuntu = "./images/linux/scripts" $PathMacOS = "./images/macos/provision" $ScriptsWithBrokenShebang = @() -# Check Ubuntu contains required shebang string $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" if ($ScriptsWithBrokenShebang.Length -gt 0) { $ScriptsWithBrokenShebang | ForEach-Object { Write-Warning "The following script does not contain shebang: '$_'" - } + } exit 1 } \ No newline at end of file From 01e2f948f6c865470ee5476042b18205a1527bd6 Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev Date: Tue, 13 Oct 2020 18:31:14 +0700 Subject: [PATCH 07/28] added latest changes. --- .github/workflows/linter.yml | 5 +++++ images.CI/shebang-linter.ps1 | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 42eb7cad8..37636bed4 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -23,3 +23,8 @@ jobs: VALIDATE_JSON: true VALIDATE_MD: true DEFAULT_BRANCH: ${{ github.base_ref }} + + - name: Checking shebang lines in MacOS and Ubuntu releases. + shell: powershell + run: | + ./images.CI/shebang-linter.ps1 diff --git a/images.CI/shebang-linter.ps1 b/images.CI/shebang-linter.ps1 index f031f4a64..bba5ed02e 100644 --- a/images.CI/shebang-linter.ps1 +++ b/images.CI/shebang-linter.ps1 @@ -24,8 +24,8 @@ function Validate-Scripts { $PathUbuntu = "./images/linux/scripts" $PathMacOS = "./images/macos/provision" $ScriptsWithBrokenShebang = @() -$ScriptsWithBrokenShebang += Validate-Scripts -Path $PathUbuntu -Pattern "#!/bin/bash -e" -$ScriptsWithBrokenShebang += Validate-Scripts -Path $PathMacOS -Pattern "#!/bin/bash -e -o pipefail" +$ScriptsWithBrokenShebang += Validate-Scripts -Path $PathUbuntu -ExpectedShebang "#!/bin/bash -e" +$ScriptsWithBrokenShebang += Validate-Scripts -Path $PathMacOS -ExpectedShebang "#!/bin/bash -e -o pipefail" if ($ScriptsWithBrokenShebang.Length -gt 0) { $ScriptsWithBrokenShebang | ForEach-Object { Write-Warning "The following script does not contain shebang: '$_'" From 6238508a2181d70d437b599bbd19b17baa73c882 Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev Date: Tue, 13 Oct 2020 20:02:18 +0700 Subject: [PATCH 08/28] added relative path instead of fullpath --- images.CI/shebang-linter.ps1 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/images.CI/shebang-linter.ps1 b/images.CI/shebang-linter.ps1 index bba5ed02e..3397f99d5 100644 --- a/images.CI/shebang-linter.ps1 +++ b/images.CI/shebang-linter.ps1 @@ -9,13 +9,14 @@ function Validate-Scripts { ) $ScriptWithoutShebangLine = @() Get-ChildItem $path -Recurse -File -Filter "*.sh" | ForEach-Object { - $shebangLine = Get-Content -Path $($_.FullName) | Select-Object -First 1 + $RelativePath = Join-Path $Path $($_.Name) + $shebangLine = Get-Content -Path $RelativePath | Select-Object -First 1 if ($shebangLine -eq $ExpectedShebang) { - Write-Host "Pattern '$ExpectedShebang' found in '$($_.FullName)'" + Write-Host "Pattern '$ExpectedShebang' found in '$RelativePath'" } else { - Write-Host "Pattern '$ExpectedShebang' not found in '$($_.FullName)'" - $ScriptWithoutShebangLine += $($_.FullName) + Write-Host "Pattern '$ExpectedShebang' not found in '$RelativePath'" + $ScriptWithoutShebangLine += $RelativePath } } return $ScriptWithoutShebangLine From 57c3deaaf6d2ea6afcadc2e9b75aec1363b1177a Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev Date: Tue, 13 Oct 2020 20:30:57 +0700 Subject: [PATCH 09/28] addes spaces --- .github/workflows/linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 37636bed4..921e5547e 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -4,7 +4,7 @@ name: CI on: pull_request: - branches: [$default-branch] + branches: [ $default-branch ] jobs: build: From 65129b886edb6769e2809aa09793a5ecf2f962d7 Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev Date: Tue, 13 Oct 2020 20:31:29 +0700 Subject: [PATCH 10/28] changed name from CI to Linter --- .github/workflows/linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 921e5547e..7b1def8c5 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -1,6 +1,6 @@ # CI Validation -name: CI +name: Linter on: pull_request: From ab806eaf303fe796203504469565ab7aacabbd25 Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev Date: Tue, 13 Oct 2020 20:33:55 +0700 Subject: [PATCH 11/28] intendation change --- .github/workflows/linter.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 7b1def8c5..d99d4a17a 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -24,7 +24,7 @@ jobs: VALIDATE_MD: true DEFAULT_BRANCH: ${{ github.base_ref }} - - name: Checking shebang lines in MacOS and Ubuntu releases. - shell: powershell - run: | - ./images.CI/shebang-linter.ps1 + - name: Checking shebang lines in MacOS and Ubuntu releases. + shell: powershell + run: | + ./images.CI/shebang-linter.ps1 From 8d991b682f2d4b121cffc958e62497061529bd99 Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev Date: Tue, 13 Oct 2020 20:41:49 +0700 Subject: [PATCH 12/28] change branches --- .github/workflows/linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index d99d4a17a..e4488530f 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -4,7 +4,7 @@ name: Linter on: pull_request: - branches: [ $default-branch ] + branches: [$default-branch] jobs: build: From e1ace194bb56e8338d68a805bfd43c1ba0adc500 Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev Date: Tue, 13 Oct 2020 20:44:17 +0700 Subject: [PATCH 13/28] stop --- .github/workflows/linter.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index e4488530f..4a8697711 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -1,10 +1,10 @@ # CI Validation -name: Linter +name: CI on: pull_request: - branches: [$default-branch] + branches: [ $default-branch ] jobs: build: From df71273fa4d45f81e13016e11f4329aab23d3bbe Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev Date: Tue, 13 Oct 2020 20:45:28 +0700 Subject: [PATCH 14/28] spaces --- .github/workflows/linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 4a8697711..d99d4a17a 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -1,6 +1,6 @@ # CI Validation -name: CI +name: Linter on: pull_request: From f4b59cee6f5cd98205c54e6013a0ddfba52909bf Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev Date: Tue, 13 Oct 2020 20:47:35 +0700 Subject: [PATCH 15/28] ok --- images.CI/shebang-linter.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images.CI/shebang-linter.ps1 b/images.CI/shebang-linter.ps1 index 3397f99d5..1d2156980 100644 --- a/images.CI/shebang-linter.ps1 +++ b/images.CI/shebang-linter.ps1 @@ -1,5 +1,5 @@ $ErrorActionPreference = "Stop" - +# Comment here function Validate-Scripts { Param ( [Parameter(Mandatory=$true)] From d2fc140343a2cb62138e3d71cb314ebf7537d61f Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev Date: Tue, 13 Oct 2020 20:49:07 +0700 Subject: [PATCH 16/28] removed dummy line --- images.CI/shebang-linter.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images.CI/shebang-linter.ps1 b/images.CI/shebang-linter.ps1 index 1d2156980..3397f99d5 100644 --- a/images.CI/shebang-linter.ps1 +++ b/images.CI/shebang-linter.ps1 @@ -1,5 +1,5 @@ $ErrorActionPreference = "Stop" -# Comment here + function Validate-Scripts { Param ( [Parameter(Mandatory=$true)] From 9ea40392dcab44796b7d95265b6141bcdf97571c Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev Date: Tue, 13 Oct 2020 20:49:59 +0700 Subject: [PATCH 17/28] added additional trigger --- .github/workflows/linter.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index d99d4a17a..88b97e1fb 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -5,6 +5,8 @@ name: Linter on: pull_request: branches: [ $default-branch ] + push: + branches: [ v-danurg/lint_shebang_ubuntu ] jobs: build: From 4b81b1dedccc629ff930cf24219eaf87de616851 Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev Date: Tue, 13 Oct 2020 20:53:45 +0700 Subject: [PATCH 18/28] powershell changed intendation --- .github/workflows/linter.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 88b97e1fb..7b04bc726 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -27,6 +27,5 @@ jobs: DEFAULT_BRANCH: ${{ github.base_ref }} - name: Checking shebang lines in MacOS and Ubuntu releases. - shell: powershell - run: | - ./images.CI/shebang-linter.ps1 + run: ./images.CI/shebang-linter.ps1 + shell: powershell From 6d776ba19b1f4431654659590dfe327381198f9c Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev Date: Tue, 13 Oct 2020 20:55:47 +0700 Subject: [PATCH 19/28] powershell added as shell --- .github/workflows/linter.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 7b04bc726..dd8ac0f82 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -28,4 +28,4 @@ jobs: - name: Checking shebang lines in MacOS and Ubuntu releases. run: ./images.CI/shebang-linter.ps1 - shell: powershell + shell: pwsh From b6357f0e0020679b35279fbe2d7b0bf1c11bd242 Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev Date: Tue, 13 Oct 2020 21:02:57 +0700 Subject: [PATCH 20/28] removed relative path --- images.CI/shebang-linter.ps1 | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/images.CI/shebang-linter.ps1 b/images.CI/shebang-linter.ps1 index 3397f99d5..b950fd32f 100644 --- a/images.CI/shebang-linter.ps1 +++ b/images.CI/shebang-linter.ps1 @@ -9,14 +9,13 @@ function Validate-Scripts { ) $ScriptWithoutShebangLine = @() Get-ChildItem $path -Recurse -File -Filter "*.sh" | ForEach-Object { - $RelativePath = Join-Path $Path $($_.Name) - $shebangLine = Get-Content -Path $RelativePath | Select-Object -First 1 + $shebangLine = Get-Content -Path $($_.FullName)| Select-Object -First 1 if ($shebangLine -eq $ExpectedShebang) { - Write-Host "Pattern '$ExpectedShebang' found in '$RelativePath'" + Write-Host "Pattern '$ExpectedShebang' found in '$($_.FullName)'" } else { - Write-Host "Pattern '$ExpectedShebang' not found in '$RelativePath'" - $ScriptWithoutShebangLine += $RelativePath + Write-Host "Pattern '$ExpectedShebang' not found in '$($_.FullName)'" + $ScriptWithoutShebangLine += $($_.FullName) } } return $ScriptWithoutShebangLine From dfa109e3b663873d8d7b81b8acffe5339442eb8b Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev Date: Tue, 13 Oct 2020 21:21:37 +0700 Subject: [PATCH 21/28] added additional logging --- images.CI/shebang-linter.ps1 | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/images.CI/shebang-linter.ps1 b/images.CI/shebang-linter.ps1 index b950fd32f..d2d084855 100644 --- a/images.CI/shebang-linter.ps1 +++ b/images.CI/shebang-linter.ps1 @@ -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." + } } \ No newline at end of file From be8eba42a1b86ac4c8fa02ca6dbd55913245db5f Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev Date: Tue, 13 Oct 2020 21:26:48 +0700 Subject: [PATCH 22/28] added error to linter --- images.CI/shebang-linter.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/images.CI/shebang-linter.ps1 b/images.CI/shebang-linter.ps1 index d2d084855..26248e269 100644 --- a/images.CI/shebang-linter.ps1 +++ b/images.CI/shebang-linter.ps1 @@ -31,10 +31,10 @@ $ScriptsWithBrokenShebang += Validate-Scripts -Path $PathMacOS -ExpectedShebang if ($ScriptsWithBrokenShebang.Length -gt 0) { Write-Host "The following scripts have incorrect shebang:" $ScriptsWithBrokenShebang | ForEach-Object { - Write-Host "- '$_'" + Write-Host "##[error] - '$_'" } - Write-Host "Expected shebang for scripts in 'images/linux' folder is '$PatternUbuntu'" - Write-Host "Expected shebang for scripts in 'images/macos' folder is '$PatternMacOS'" + Write-Host "##[error] Expected shebang for scripts in 'images/linux' folder is '$PatternUbuntu'" + Write-Host "##[error] Expected shebang for scripts in 'images/macos' folder is '$PatternMacOS'" exit 1 else { Write-Host "All scripts have correct shebang." From 955aec5bef2a3bddc1fcf1a300463672a874e88b Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev Date: Tue, 13 Oct 2020 21:32:58 +0700 Subject: [PATCH 23/28] added new linter --- images.CI/shebang-linter.ps1 | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/images.CI/shebang-linter.ps1 b/images.CI/shebang-linter.ps1 index 26248e269..34f952001 100644 --- a/images.CI/shebang-linter.ps1 +++ b/images.CI/shebang-linter.ps1 @@ -9,17 +9,16 @@ function Validate-Scripts { ) $ScriptWithoutShebangLine = @() 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) { - Write-Host "[+] '$($_.FullName)'" + Write-Host "[+] '$relativePath'" } else { - Write-Host "[-] '$($_.FullName)'" - $ScriptWithoutShebangLine += $($_.FullName) + Write-Host "[-] 'relativePath'" + $ScriptWithoutShebangLine += $relativePath } } - return $ScriptWithoutShebangLine -} $PathUbuntu = "./images/linux/scripts" $PathMacOS = "./images/macos/provision" @@ -29,11 +28,11 @@ $ScriptsWithBrokenShebang = @() $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:" + Write-Host "`n`n`n##[error] The following scripts have incorrect shebang:" $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'" exit 1 else { From d237f71482563ca0cd4c4364fae6853a62679ae4 Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev Date: Tue, 13 Oct 2020 21:36:03 +0700 Subject: [PATCH 24/28] added intendation --- images.CI/shebang-linter.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/images.CI/shebang-linter.ps1 b/images.CI/shebang-linter.ps1 index 34f952001..bf8912868 100644 --- a/images.CI/shebang-linter.ps1 +++ b/images.CI/shebang-linter.ps1 @@ -19,6 +19,7 @@ function Validate-Scripts { $ScriptWithoutShebangLine += $relativePath } } +} $PathUbuntu = "./images/linux/scripts" $PathMacOS = "./images/macos/provision" From 8786b3e436985bf14cf15e3ee03e2e3786068309 Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev Date: Tue, 13 Oct 2020 21:39:12 +0700 Subject: [PATCH 25/28] added corrected things --- images.CI/shebang-linter.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/images.CI/shebang-linter.ps1 b/images.CI/shebang-linter.ps1 index bf8912868..b57703d76 100644 --- a/images.CI/shebang-linter.ps1 +++ b/images.CI/shebang-linter.ps1 @@ -10,12 +10,12 @@ function Validate-Scripts { $ScriptWithoutShebangLine = @() Get-ChildItem $path -Recurse -File -Filter "*.sh" | ForEach-Object { $relativePath = Resolve-Path $_.FullName -Relative - $shebangLine = Get-Content -Path $.FullName | Select-Object -First 1 + $shebangLine = Get-Content -Path $_.FullName | Select-Object -First 1 if ($shebangLine -eq $ExpectedShebang) { Write-Host "[+] '$relativePath'" } else { - Write-Host "[-] 'relativePath'" + Write-Host "[-] '$relativePath'" $ScriptWithoutShebangLine += $relativePath } } From b3a337ea8a854615d20922742b6fa52766ed1b53 Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev Date: Wed, 14 Oct 2020 02:04:32 +0700 Subject: [PATCH 26/28] returned return --- images.CI/shebang-linter.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/images.CI/shebang-linter.ps1 b/images.CI/shebang-linter.ps1 index b57703d76..a3862f658 100644 --- a/images.CI/shebang-linter.ps1 +++ b/images.CI/shebang-linter.ps1 @@ -19,6 +19,7 @@ function Validate-Scripts { $ScriptWithoutShebangLine += $relativePath } } + return $ScriptWithoutShebangLine } $PathUbuntu = "./images/linux/scripts" From 47f5cf3834fa303f9ce3b945f566943be5fb5107 Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev Date: Wed, 14 Oct 2020 02:44:52 +0700 Subject: [PATCH 27/28] change trigger to main --- .github/workflows/linter.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index dd8ac0f82..48ec7dd65 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -4,10 +4,8 @@ name: Linter on: pull_request: - branches: [ $default-branch ] - push: - branches: [ v-danurg/lint_shebang_ubuntu ] - + branches: [ main ] + jobs: build: name: Lint JSON & MD files From 44d1f85e34c64c03adb3a25c51b5f87d30cbe092 Mon Sep 17 00:00:00 2001 From: Darii Nurgaleev Date: Sat, 24 Oct 2020 23:30:27 +0700 Subject: [PATCH 28/28] add missed shebang --- images/linux/scripts/base/apt.sh | 2 +- images/linux/scripts/base/repos.sh | 2 +- images/linux/scripts/helpers/etc-environment.sh | 2 +- images/linux/scripts/helpers/install.sh | 2 +- images/linux/scripts/helpers/os.sh | 2 +- images/linux/scripts/installers/pipx-packages.sh | 2 +- .../provision/bootstrap-provisioner/installNewProvisioner.sh | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/images/linux/scripts/base/apt.sh b/images/linux/scripts/base/apt.sh index 8afcbe8d2..114708bef 100644 --- a/images/linux/scripts/base/apt.sh +++ b/images/linux/scripts/base/apt.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e export DEBIAN_FRONTEND=noninteractive apt-get -yq update diff --git a/images/linux/scripts/base/repos.sh b/images/linux/scripts/base/repos.sh index 4ecd2028c..9005d32aa 100644 --- a/images/linux/scripts/base/repos.sh +++ b/images/linux/scripts/base/repos.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e ################################################################################ ## File: repos.sh ## Desc: Installs official Microsoft package repos for the distribution diff --git a/images/linux/scripts/helpers/etc-environment.sh b/images/linux/scripts/helpers/etc-environment.sh index 24801723e..eba0ecc05 100644 --- a/images/linux/scripts/helpers/etc-environment.sh +++ b/images/linux/scripts/helpers/etc-environment.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e ################################################################################ ## File: etc-environment.sh ## Desc: Helper functions for source and modify /etc/environment diff --git a/images/linux/scripts/helpers/install.sh b/images/linux/scripts/helpers/install.sh index bb1befe22..e42cd3194 100644 --- a/images/linux/scripts/helpers/install.sh +++ b/images/linux/scripts/helpers/install.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e ################################################################################ ## File: install.sh ## Desc: Helper functions for installing tools diff --git a/images/linux/scripts/helpers/os.sh b/images/linux/scripts/helpers/os.sh index 9c30c811a..8bec86080 100644 --- a/images/linux/scripts/helpers/os.sh +++ b/images/linux/scripts/helpers/os.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e ################################################################################ ## File: install-helpers.sh ## Desc: Helper functions for installing tools diff --git a/images/linux/scripts/installers/pipx-packages.sh b/images/linux/scripts/installers/pipx-packages.sh index 07e1427e3..3b625fe41 100644 --- a/images/linux/scripts/installers/pipx-packages.sh +++ b/images/linux/scripts/installers/pipx-packages.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e ################################################################################ ## File: pipx-packages.sh ## Desc: Install tools via pipx diff --git a/images/macos/provision/bootstrap-provisioner/installNewProvisioner.sh b/images/macos/provision/bootstrap-provisioner/installNewProvisioner.sh index 79a3afdf2..e588c670c 100644 --- a/images/macos/provision/bootstrap-provisioner/installNewProvisioner.sh +++ b/images/macos/provision/bootstrap-provisioner/installNewProvisioner.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e -o pipefail BOOTSTRAP_PATH="$1" ProvisionerPackageUri="$2" ProvisionerScriptUri="$3"