From 48c3a310a5606b9505f8f4d0ca76927d0d997505 Mon Sep 17 00:00:00 2001 From: Nikita Bykov Date: Thu, 8 Oct 2020 16:57:24 +0300 Subject: [PATCH 1/9] added pipx and yamllint --- images/win/Windows2016-Azure.json | 8 +++++++- images/win/Windows2019-Azure.json | 8 +++++++- .../scripts/Installers/Install-Pipx-Packages.ps1 | 12 ++++++++++++ images/win/scripts/Installers/Install-Pipx.ps1 | 14 ++++++++++++++ images/win/scripts/Installers/Install-YAMLLint.ps1 | 3 --- .../SoftwareReport/SoftwareReport.Common.psm1 | 4 ++++ .../SoftwareReport/SoftwareReport.Generator.ps1 | 3 ++- images/win/scripts/Tests/PipxPackages.Test.ps1 | 5 +++++ images/win/scripts/Tests/Tools.Tests.ps1 | 12 ++++++------ images/win/toolsets/toolset-2016.json | 8 +++++++- images/win/toolsets/toolset-2019.json | 8 +++++++- 11 files changed, 71 insertions(+), 14 deletions(-) create mode 100644 images/win/scripts/Installers/Install-Pipx-Packages.ps1 create mode 100644 images/win/scripts/Installers/Install-Pipx.ps1 delete mode 100644 images/win/scripts/Installers/Install-YAMLLint.ps1 create mode 100644 images/win/scripts/Tests/PipxPackages.Test.ps1 diff --git a/images/win/Windows2016-Azure.json b/images/win/Windows2016-Azure.json index d6528649..f2389d42 100644 --- a/images/win/Windows2016-Azure.json +++ b/images/win/Windows2016-Azure.json @@ -235,7 +235,6 @@ "{{ template_dir }}/scripts/Installers/Install-PyPy.ps1", "{{ template_dir }}/scripts/Installers/Install-Toolset.ps1", "{{ template_dir }}/scripts/Installers/Configure-Toolset.ps1", - "{{ template_dir }}/scripts/Installers/Install-YAMLLint.ps1", "{{ template_dir }}/scripts/Installers/Update-AndroidSDK.ps1" ] }, @@ -328,6 +327,13 @@ "{{ template_dir }}/scripts/Installers/Install-CodeQLBundle.ps1" ] }, + { + "type": "powershell", + "scripts": [ + "{{ template_dir }}/scripts/Installers/Install-Pipx.ps1", + "{{ template_dir }}/scripts/Installers/Install-Pipx-Packages.ps1" + ] + }, { "type": "powershell", "scripts": [ diff --git a/images/win/Windows2019-Azure.json b/images/win/Windows2019-Azure.json index 6e0ba866..7e082f20 100644 --- a/images/win/Windows2019-Azure.json +++ b/images/win/Windows2019-Azure.json @@ -249,7 +249,6 @@ "{{ template_dir }}/scripts/Installers/Install-PyPy.ps1", "{{ template_dir }}/scripts/Installers/Install-Toolset.ps1", "{{ template_dir }}/scripts/Installers/Configure-Toolset.ps1", - "{{ template_dir }}/scripts/Installers/Install-YAMLLint.ps1", "{{ template_dir }}/scripts/Installers/Update-AndroidSDK.ps1", "{{ template_dir }}/scripts/Installers/Install-AzureModules.ps1" ] @@ -326,6 +325,13 @@ "{{ template_dir }}/scripts/Installers/Install-CodeQLBundle.ps1" ] }, + { + "type": "powershell", + "scripts": [ + "{{ template_dir }}/scripts/Installers/Install-Pipx.ps1", + "{{ template_dir }}/scripts/Installers/Install-Pipx-Packages.ps1" + ] + }, { "type": "powershell", "scripts": [ diff --git a/images/win/scripts/Installers/Install-Pipx-Packages.ps1 b/images/win/scripts/Installers/Install-Pipx-Packages.ps1 new file mode 100644 index 00000000..a5be7b6f --- /dev/null +++ b/images/win/scripts/Installers/Install-Pipx-Packages.ps1 @@ -0,0 +1,12 @@ +$pipxToolset = (Get-ToolsetContent).pipx +foreach($tool in $pipxToolset) { + if ($tool.python) { + $pythonPath = "${env:AGENT_TOOLSDIRECTORY}\Python\${tool.python}*\${env:AGENT_OSARCHITECTURE}\python-${tool.python}*" + Write-Host "Install ${tool.package} into python ${tool.python}" + pipx install $tool.package --python $python_path + } else { + Write-Host "Install ${tool.package} into default python" + pipx install $tool.package + } + Invoke-PesterTests -TestFile "PipxPackages" -TestName $tool.package +} \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-Pipx.ps1 b/images/win/scripts/Installers/Install-Pipx.ps1 new file mode 100644 index 00000000..a78cf456 --- /dev/null +++ b/images/win/scripts/Installers/Install-Pipx.ps1 @@ -0,0 +1,14 @@ +# Set custom directorys for pipx +$env:PIPX_BIN_DIR = "${env:ProgramFiles(x86)}\pipx_bin" +$env:PIPX_HOME = "${env:ProgramFiles(x86)}\pipx" + +# Install pipx +pip install pipx + +# Set environment variables +Add-MachinePathItem "${env:PIPX_BIN_DIR}" +Set-SystemVariable -SystemVariable PIPX_BIN_DIR -Value $env:PIPX_BIN_DIR +Set-SystemVariable -SystemVariable PIPX_HOME -Value $env:PIPX_HOME + +# Test pipx +Invoke-PesterTests -TestFile "Tools" -TestName "Pipx" \ No newline at end of file diff --git a/images/win/scripts/Installers/Install-YAMLLint.ps1 b/images/win/scripts/Installers/Install-YAMLLint.ps1 deleted file mode 100644 index 1ebc09a3..00000000 --- a/images/win/scripts/Installers/Install-YAMLLint.ps1 +++ /dev/null @@ -1,3 +0,0 @@ -pip install yamllint - -Invoke-PesterTests -TestFile "Tools" -TestName "yamllint" \ No newline at end of file diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 b/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 index 05b101aa..12f41061 100644 --- a/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 +++ b/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 @@ -273,4 +273,8 @@ function Get-PacmanVersion { function Get-YAMLLintVersion { yamllint --version +} + +function Get-PipxVersion { + pipx --version } \ No newline at end of file diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 b/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 index f8315774..ef7749e3 100644 --- a/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 +++ b/images/win/scripts/SoftwareReport/SoftwareReport.Generator.ps1 @@ -59,7 +59,8 @@ $markdown += New-MDList -Style Unordered -Lines @( (Get-RubyGemsVersion), (Get-HelmVersion), (Get-ComposerVersion), - (Get-NugetVersion) + (Get-NugetVersion), + (Get-PipxVersion) ) $markdown += New-MDHeader "Project Management" -Level 3 diff --git a/images/win/scripts/Tests/PipxPackages.Test.ps1 b/images/win/scripts/Tests/PipxPackages.Test.ps1 new file mode 100644 index 00000000..3a9ad564 --- /dev/null +++ b/images/win/scripts/Tests/PipxPackages.Test.ps1 @@ -0,0 +1,5 @@ +Describe "yamllint" { + It "yamllint" { + "yamllint --version" | Should -ReturnZeroExitCode + } +} \ No newline at end of file diff --git a/images/win/scripts/Tests/Tools.Tests.ps1 b/images/win/scripts/Tests/Tools.Tests.ps1 index cbb0609a..a0024532 100644 --- a/images/win/scripts/Tests/Tools.Tests.ps1 +++ b/images/win/scripts/Tests/Tools.Tests.ps1 @@ -214,12 +214,6 @@ Describe "ServiceFabricSDK" { } } -Describe "yamllint" { - It "yamllint" { - "yamllint --version" | Should -ReturnZeroExitCode - } -} - Describe "Svn" { It "svn" { "svn --version --quiet" | Should -ReturnZeroExitCode @@ -269,3 +263,9 @@ Describe "Zstd" { "zstd -V" | Should -ReturnZeroExitCode } } + +Describe "Pipx" { + It "Pipx" { + "pipx --version" | Should -ReturnZeroExitCode + } +} diff --git a/images/win/toolsets/toolset-2016.json b/images/win/toolsets/toolset-2016.json index 5e0b23c6..441b34c1 100644 --- a/images/win/toolsets/toolset-2016.json +++ b/images/win/toolsets/toolset-2016.json @@ -236,5 +236,11 @@ "mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2016", "microsoft/aspnetcore-build:1.0-2.0" ] - } + }, + "pipx": [ + { + "package": "yamllint", + "cmd": "yamllint" + } + ] } diff --git a/images/win/toolsets/toolset-2019.json b/images/win/toolsets/toolset-2019.json index bf1d0dff..275e63e5 100644 --- a/images/win/toolsets/toolset-2019.json +++ b/images/win/toolsets/toolset-2019.json @@ -288,5 +288,11 @@ "mcr.microsoft.com/dotnet/framework/runtime:4.8-windowsservercore-ltsc2019", "microsoft/aspnetcore-build:1.0-2.0" ] - } + }, + "pipx": [ + { + "package": "yamllint", + "cmd": "yamllint" + } + ] } From f683996383d8de2298e6f62ed79da331f1034d86 Mon Sep 17 00:00:00 2001 From: Nikita Bykov Date: Fri, 9 Oct 2020 09:37:58 +0300 Subject: [PATCH 2/9] fixed Install-PipxPackages.ps1 and tests --- ...nstall-Pipx-Packages.ps1 => Install-PipxPackages.ps1} | 8 ++++---- images/win/scripts/Tests/PipxPackages.Test.ps1 | 9 ++++++--- images/win/toolsets/toolset-2019.json | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) rename images/win/scripts/Installers/{Install-Pipx-Packages.ps1 => Install-PipxPackages.ps1} (51%) diff --git a/images/win/scripts/Installers/Install-Pipx-Packages.ps1 b/images/win/scripts/Installers/Install-PipxPackages.ps1 similarity index 51% rename from images/win/scripts/Installers/Install-Pipx-Packages.ps1 rename to images/win/scripts/Installers/Install-PipxPackages.ps1 index a5be7b6f..e83f5add 100644 --- a/images/win/scripts/Installers/Install-Pipx-Packages.ps1 +++ b/images/win/scripts/Installers/Install-PipxPackages.ps1 @@ -1,12 +1,12 @@ $pipxToolset = (Get-ToolsetContent).pipx foreach($tool in $pipxToolset) { if ($tool.python) { - $pythonPath = "${env:AGENT_TOOLSDIRECTORY}\Python\${tool.python}*\${env:AGENT_OSARCHITECTURE}\python-${tool.python}*" + $pythonPath = (Get-Item -Path "${env:AGENT_TOOLSDIRECTORY}\Python\${tool.python}.*\x64\python-${tool.python}*").FullName Write-Host "Install ${tool.package} into python ${tool.python}" - pipx install $tool.package --python $python_path + pipx install $tool.package --python $pythonPath } else { Write-Host "Install ${tool.package} into default python" pipx install $tool.package } - Invoke-PesterTests -TestFile "PipxPackages" -TestName $tool.package -} \ No newline at end of file +} +Invoke-PesterTests -TestFile "PipxPackages" \ No newline at end of file diff --git a/images/win/scripts/Tests/PipxPackages.Test.ps1 b/images/win/scripts/Tests/PipxPackages.Test.ps1 index 3a9ad564..fbb4c596 100644 --- a/images/win/scripts/Tests/PipxPackages.Test.ps1 +++ b/images/win/scripts/Tests/PipxPackages.Test.ps1 @@ -1,5 +1,8 @@ -Describe "yamllint" { - It "yamllint" { - "yamllint --version" | Should -ReturnZeroExitCode +Describe "PipxPackages" { + $pipxToolset = (Get-ToolsetContent).pipx + foreach($tool in $pipxToolset) { + It "${tool.package}" { + "${tool.cmd}" | Should -ReturnZeroExitCode + } } } \ No newline at end of file diff --git a/images/win/toolsets/toolset-2019.json b/images/win/toolsets/toolset-2019.json index 275e63e5..5ca23b4e 100644 --- a/images/win/toolsets/toolset-2019.json +++ b/images/win/toolsets/toolset-2019.json @@ -292,7 +292,7 @@ "pipx": [ { "package": "yamllint", - "cmd": "yamllint" + "cmd": "yamllint --version" } ] } From 08f5d6592b9a824d503397af2174f0b1f1d74879 Mon Sep 17 00:00:00 2001 From: Nikita Bykov Date: Fri, 9 Oct 2020 11:31:54 +0300 Subject: [PATCH 3/9] updated tests --- images/win/scripts/Tests/PipxPackages.Test.ps1 | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/images/win/scripts/Tests/PipxPackages.Test.ps1 b/images/win/scripts/Tests/PipxPackages.Test.ps1 index fbb4c596..b41b8f8f 100644 --- a/images/win/scripts/Tests/PipxPackages.Test.ps1 +++ b/images/win/scripts/Tests/PipxPackages.Test.ps1 @@ -1,8 +1,7 @@ Describe "PipxPackages" { $pipxToolset = (Get-ToolsetContent).pipx - foreach($tool in $pipxToolset) { - It "${tool.package}" { - "${tool.cmd}" | Should -ReturnZeroExitCode - } + $testCases = $pipxToolset | ForEach-Object { @{package = $_.package; cmd = $_.cmd} } + It "" -TestCases $testCases { + "$cmd" | Should -ReturnZeroExitCode } } \ No newline at end of file From 2977e6c42cbe552b8b572a6d39663b2a2fbad92b Mon Sep 17 00:00:00 2001 From: Nikita Bykov Date: Fri, 9 Oct 2020 11:33:25 +0300 Subject: [PATCH 4/9] fixed naming --- images/win/windows2016.json | 2 +- images/win/windows2019.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/images/win/windows2016.json b/images/win/windows2016.json index f2389d42..21bcfff4 100644 --- a/images/win/windows2016.json +++ b/images/win/windows2016.json @@ -331,7 +331,7 @@ "type": "powershell", "scripts": [ "{{ template_dir }}/scripts/Installers/Install-Pipx.ps1", - "{{ template_dir }}/scripts/Installers/Install-Pipx-Packages.ps1" + "{{ template_dir }}/scripts/Installers/Install-PipxPackages.ps1" ] }, { diff --git a/images/win/windows2019.json b/images/win/windows2019.json index 7e082f20..62bf1b94 100644 --- a/images/win/windows2019.json +++ b/images/win/windows2019.json @@ -329,7 +329,7 @@ "type": "powershell", "scripts": [ "{{ template_dir }}/scripts/Installers/Install-Pipx.ps1", - "{{ template_dir }}/scripts/Installers/Install-Pipx-Packages.ps1" + "{{ template_dir }}/scripts/Installers/Install-PipxPackages.ps1" ] }, { From 42b6aa68b4e6241bb1e961aa002d92a3ab96c7d3 Mon Sep 17 00:00:00 2001 From: Nikita Bykov Date: Thu, 15 Oct 2020 12:02:07 +0300 Subject: [PATCH 5/9] added TOOLSET_JSON_PATH --- images/win/windows2016.json | 3 +++ images/win/windows2019.json | 3 +++ 2 files changed, 6 insertions(+) diff --git a/images/win/windows2016.json b/images/win/windows2016.json index 21bcfff4..8995569e 100644 --- a/images/win/windows2016.json +++ b/images/win/windows2016.json @@ -329,6 +329,9 @@ }, { "type": "powershell", + "environment_vars": [ + "TOOLSET_JSON_PATH={{user `toolset_json_path`}}" + ], "scripts": [ "{{ template_dir }}/scripts/Installers/Install-Pipx.ps1", "{{ template_dir }}/scripts/Installers/Install-PipxPackages.ps1" diff --git a/images/win/windows2019.json b/images/win/windows2019.json index 62bf1b94..ced90aad 100644 --- a/images/win/windows2019.json +++ b/images/win/windows2019.json @@ -327,6 +327,9 @@ }, { "type": "powershell", + "environment_vars": [ + "TOOLSET_JSON_PATH={{user `toolset_json_path`}}" + ], "scripts": [ "{{ template_dir }}/scripts/Installers/Install-Pipx.ps1", "{{ template_dir }}/scripts/Installers/Install-PipxPackages.ps1" From 723e4ccb877619a062dd718065122450708c33d1 Mon Sep 17 00:00:00 2001 From: Nikita Bykov Date: Fri, 16 Oct 2020 12:36:59 +0300 Subject: [PATCH 6/9] fixed naming --- ...{PipxPackages.Test.ps1 => PipxPackages.Tests.ps1} | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) rename images/win/scripts/Tests/{PipxPackages.Test.ps1 => PipxPackages.Tests.ps1} (97%) diff --git a/images/win/scripts/Tests/PipxPackages.Test.ps1 b/images/win/scripts/Tests/PipxPackages.Tests.ps1 similarity index 97% rename from images/win/scripts/Tests/PipxPackages.Test.ps1 rename to images/win/scripts/Tests/PipxPackages.Tests.ps1 index b41b8f8f..41041078 100644 --- a/images/win/scripts/Tests/PipxPackages.Test.ps1 +++ b/images/win/scripts/Tests/PipxPackages.Tests.ps1 @@ -1,7 +1,7 @@ -Describe "PipxPackages" { - $pipxToolset = (Get-ToolsetContent).pipx - $testCases = $pipxToolset | ForEach-Object { @{package = $_.package; cmd = $_.cmd} } - It "" -TestCases $testCases { - "$cmd" | Should -ReturnZeroExitCode - } +Describe "PipxPackages" { + $pipxToolset = (Get-ToolsetContent).pipx + $testCases = $pipxToolset | ForEach-Object { @{package = $_.package; cmd = $_.cmd} } + It "" -TestCases $testCases { + "$cmd" | Should -ReturnZeroExitCode + } } \ No newline at end of file From 5694fe7952b2f2e733dd669d707e64384e966811 Mon Sep 17 00:00:00 2001 From: Nikita Bykov Date: Sun, 18 Oct 2020 23:10:10 +0300 Subject: [PATCH 7/9] fixed tests for windows 2016 --- images/win/toolsets/toolset-2016.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/images/win/toolsets/toolset-2016.json b/images/win/toolsets/toolset-2016.json index 011366bf..197608e0 100644 --- a/images/win/toolsets/toolset-2016.json +++ b/images/win/toolsets/toolset-2016.json @@ -242,7 +242,7 @@ "pipx": [ { "package": "yamllint", - "cmd": "yamllint" + "cmd": "yamllint --version" } ] } From b19a33bd3e27dce6430c7d7f266651a4c18dfb0a Mon Sep 17 00:00:00 2001 From: Nikita Bykov Date: Wed, 21 Oct 2020 08:44:06 +0300 Subject: [PATCH 8/9] updated json files --- images/win/windows2016.json | 14 +++----------- images/win/windows2019.json | 14 +++----------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/images/win/windows2016.json b/images/win/windows2016.json index 0000e686..120e7ac9 100644 --- a/images/win/windows2016.json +++ b/images/win/windows2016.json @@ -235,7 +235,9 @@ "{{ template_dir }}/scripts/Installers/Install-PyPy.ps1", "{{ template_dir }}/scripts/Installers/Install-Toolset.ps1", "{{ template_dir }}/scripts/Installers/Configure-Toolset.ps1", - "{{ template_dir }}/scripts/Installers/Update-AndroidSDK.ps1" + "{{ template_dir }}/scripts/Installers/Update-AndroidSDK.ps1", + "{{ template_dir }}/scripts/Installers/Install-Pipx.ps1", + "{{ template_dir }}/scripts/Installers/Install-PipxPackages.ps1" ] }, { @@ -327,16 +329,6 @@ "{{ template_dir }}/scripts/Installers/Install-CodeQLBundle.ps1" ] }, - { - "type": "powershell", - "environment_vars": [ - "TOOLSET_JSON_PATH={{user `toolset_json_path`}}" - ], - "scripts": [ - "{{ template_dir }}/scripts/Installers/Install-Pipx.ps1", - "{{ template_dir }}/scripts/Installers/Install-PipxPackages.ps1" - ] - }, { "type": "powershell", "scripts": [ diff --git a/images/win/windows2019.json b/images/win/windows2019.json index fd32abb8..997b1d43 100644 --- a/images/win/windows2019.json +++ b/images/win/windows2019.json @@ -250,7 +250,9 @@ "{{ template_dir }}/scripts/Installers/Install-Toolset.ps1", "{{ template_dir }}/scripts/Installers/Configure-Toolset.ps1", "{{ template_dir }}/scripts/Installers/Update-AndroidSDK.ps1", - "{{ template_dir }}/scripts/Installers/Install-AzureModules.ps1" + "{{ template_dir }}/scripts/Installers/Install-AzureModules.ps1", + "{{ template_dir }}/scripts/Installers/Install-Pipx.ps1", + "{{ template_dir }}/scripts/Installers/Install-PipxPackages.ps1" ] }, { @@ -325,16 +327,6 @@ "{{ template_dir }}/scripts/Installers/Install-CodeQLBundle.ps1" ] }, - { - "type": "powershell", - "environment_vars": [ - "TOOLSET_JSON_PATH={{user `toolset_json_path`}}" - ], - "scripts": [ - "{{ template_dir }}/scripts/Installers/Install-Pipx.ps1", - "{{ template_dir }}/scripts/Installers/Install-PipxPackages.ps1" - ] - }, { "type": "powershell", "scripts": [ From 77274dcb9b3f56947d632401eb612df84825d559 Mon Sep 17 00:00:00 2001 From: Nikita Bykov Date: Fri, 30 Oct 2020 12:36:09 +0300 Subject: [PATCH 9/9] updated Get-PipxVersion --- images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 b/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 index af9141e1..6ee9fd5b 100644 --- a/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 +++ b/images/win/scripts/SoftwareReport/SoftwareReport.Common.psm1 @@ -283,5 +283,6 @@ function Get-YAMLLintVersion { } function Get-PipxVersion { - pipx --version + $pipxVersion = pipx --version + return "Pipx $pipxVersion" } \ No newline at end of file