Skip to content

Commit 2925b3a

Browse files
[windows] introduce dedicated PowerShell configuration step (actions#8453)
* windows: implement separate step for configuring Powershell * windows: refactor PyPy checksum validation PyPy checksum validation uses PowerHTML module which is now available as a part of powershell profile * reformat * Update images/win/scripts/Installers/Configure-PowerShell.ps1 Co-authored-by: Vasilii Polikarpov <[email protected]> --------- Co-authored-by: Vasilii Polikarpov <[email protected]>
1 parent cbe9acb commit 2925b3a

File tree

5 files changed

+32
-9
lines changed

5 files changed

+32
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
################################################################################
2+
## File: Configure-Powershell.ps1
3+
## Desc: Manage PowerShell configuration
4+
################################################################################
5+
6+
#region System
7+
Write-Host "Setup PowerShellGet"
8+
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
9+
10+
# Specifies the installation policy
11+
Set-PSRepository -InstallationPolicy Trusted -Name PSGallery
12+
#endregion
13+
14+
#region User (current user, image generation only)
15+
if (-not (Test-Path $profile)) {
16+
New-Item $profile -ItemType File -Force
17+
}
18+
19+
@"
20+
if ( -not(Get-Module -ListAvailable -Name PowerHTML)) {
21+
Install-Module PowerHTML -Scope CurrentUser
22+
}
23+
24+
if ( -not(Get-Module -Name PowerHTML)) {
25+
Import-Module PowerHTML
26+
}
27+
"@ | Add-Content -Path $profile -Force
28+
29+
#endregion

images/win/scripts/Installers/Install-PowerShellModules.ps1

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
# Set TLS1.2
22
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor "Tls12"
33

4-
Write-Host "Setup PowerShellGet"
5-
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
6-
7-
# Specifies the installation policy
8-
Set-PSRepository -InstallationPolicy Trusted -Name PSGallery
9-
104
# Install PowerShell modules
115
$modules = (Get-ToolsetContent).powershellModules
126

@@ -29,4 +23,4 @@ foreach($module in $modules)
2923
}
3024

3125
Import-Module Pester
32-
Invoke-PesterTests -TestFile "PowerShellModules" -TestName "PowerShellModules"
26+
Invoke-PesterTests -TestFile "PowerShellModules" -TestName "PowerShellModules"

images/win/scripts/Installers/Install-PyPy.ps1

-2
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ $toolsetVersions = Get-ToolsetContent | Select-Object -ExpandProperty toolcache
8484
$pypyVersions = Invoke-RestMethod https://downloads.python.org/pypy/versions.json
8585

8686
# required for html parsing
87-
Install-Module PowerHTML -Scope CurrentUser
88-
Import-Module PowerHTML
8987
$checksums = (Invoke-RestMethod -Uri 'https://www.pypy.org/checksums.html' | ConvertFrom-HTML).SelectNodes('//*[@id="content"]/article/div/pre')
9088

9189
Write-Host "Starting installation PyPy..."

images/win/windows2019.json

+1
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@
150150
],
151151
"scripts": [
152152
"{{ template_dir }}/scripts/Installers/Configure-Antivirus.ps1",
153+
"{{ template_dir }}/scripts/Installers/Configure-PowerShell.ps1",
153154
"{{ template_dir }}/scripts/Installers/Install-PowerShellModules.ps1",
154155
"{{ template_dir }}/scripts/Installers/Install-WindowsFeatures.ps1",
155156
"{{ template_dir }}/scripts/Installers/Install-Choco.ps1",

images/win/windows2022.json

+1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
],
135135
"scripts": [
136136
"{{ template_dir }}/scripts/Installers/Configure-Antivirus.ps1",
137+
"{{ template_dir }}/scripts/Installers/Configure-PowerShell.ps1",
137138
"{{ template_dir }}/scripts/Installers/Install-PowerShellModules.ps1",
138139
"{{ template_dir }}/scripts/Installers/Install-WindowsFeatures.ps1",
139140
"{{ template_dir }}/scripts/Installers/Install-Choco.ps1",

0 commit comments

Comments
 (0)