Skip to content

Commit d8678a6

Browse files
committed
Update to use Install-PSResource
1 parent cb3d563 commit d8678a6

8 files changed

+53
-40
lines changed

.github/workflows/ci-test.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,15 @@ jobs:
3232
dotnet-version: |
3333
6.0.x
3434
7.0.x
35-
- name: Run setup and build script
35+
- name: Install PSResources
3636
shell: pwsh
37-
run: tools/azurePipelinesBuild.ps1
37+
run: tools/installPSResources.ps1
38+
- name: Build
39+
shell: pwsh
40+
run: Invoke-Build Build
3841
- name: Run tests
3942
shell: pwsh
40-
run: Invoke-Build Test -Configuration Release
43+
run: Invoke-Build Test
4144
- name: Upload test results
4245
uses: actions/upload-artifact@v3
4346
if: ${{ always() }}

.github/workflows/codeql-analysis.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,13 @@ jobs:
4040
with:
4141
languages: ${{ matrix.language }}
4242

43+
- name: Install PSResources
44+
shell: pwsh
45+
run: tools/installPSResources.ps1
46+
4347
- name: Build
4448
shell: pwsh
45-
run: tools/azurePipelinesBuild.ps1
49+
run: Invoke-Build Build
4650

4751
- name: Perform CodeQL Analysis
4852
uses: github/codeql-action/analyze@v2

.github/workflows/emacs-test.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@ jobs:
2222
- name: Install dotnet
2323
uses: actions/setup-dotnet@v4
2424

25-
- name: Build PSES
25+
- name: Install PSResources
2626
shell: pwsh
27-
run: tools/azurePipelinesBuild.ps1
27+
run: tools/installPSResources.ps1
28+
29+
- name: Build
30+
shell: pwsh
31+
run: Invoke-Build Build
2832

2933
- name: Install Emacs
3034
uses: purcell/setup-emacs@master

.github/workflows/vim-test.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,13 @@ jobs:
2222
- name: Install dotnet
2323
uses: actions/setup-dotnet@v4
2424

25-
- name: Build PSES
25+
- name: Install PSResources
2626
shell: pwsh
27-
run: tools/azurePipelinesBuild.ps1
27+
run: tools/installPSResources.ps1
28+
29+
- name: Build
30+
shell: pwsh
31+
run: Invoke-Build Build
2832

2933
- name: Install Vim
3034
uses: rhysd/action-setup-vim@v1

.vsts-ci/templates/ci-general.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,18 @@ steps:
2020
version: 6.0.x
2121
performMultiLevelLookup: true
2222

23+
- task: PowerShell@2
24+
displayName: Install PSResources
25+
inputs:
26+
pwsh: true
27+
filePath: tools/installPSResources.ps1
28+
2329
- task: PowerShell@2
2430
displayName: Build
2531
inputs:
26-
filePath: tools/azurePipelinesBuild.ps1
32+
targetType: inline
33+
pwsh: true
34+
script: Invoke-Build Build -Configuration Release
2735

2836
- task: PowerShell@2
2937
displayName: Test

PowerShellEditorServices.build.ps1

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -311,13 +311,6 @@ task RestorePsesModules -After Build {
311311
$moduleInfos.Add($name, $body)
312312
}
313313

314-
if ($moduleInfos.Keys.Count -gt 0) {
315-
# `#Requires` doesn't display the version needed in the error message and `using module` doesn't work with InvokeBuild in Windows PowerShell
316-
# so we'll just use Import-Module to check that PowerShellGet 1.6.0 or higher is installed.
317-
# This is needed in order to use the `-AllowPrerelease` parameter
318-
Import-Module -Name PowerShellGet -MinimumVersion 1.6.0 -ErrorAction Stop
319-
}
320-
321314
# Save each module in the modules.json file
322315
foreach ($moduleName in $moduleInfos.Keys) {
323316
if (Test-Path -Path (Join-Path -Path $submodulePath -ChildPath $moduleName)) {
@@ -330,11 +323,15 @@ task RestorePsesModules -After Build {
330323
$splatParameters = @{
331324
Name = $moduleName
332325
RequiredVersion = $moduleInstallDetails.Version
333-
AllowPrerelease = $moduleInstallDetails.AllowPrerelease
334326
Repository = if ($moduleInstallDetails.Repository) { $moduleInstallDetails.Repository } else { $DefaultModuleRepository }
335327
Path = $submodulePath
336328
}
337329

330+
# There's a bug in PowerShell get where this argument isn't correctly translated when it's false.
331+
if ($moduleInstallDetails.AllowPrerelease) {
332+
$splatParameters["AllowPrerelease"] = $moduleInstallDetails.AllowPrerelease
333+
}
334+
338335
Write-Host "`tInstalling module: ${moduleName} with arguments $(ConvertTo-Json $splatParameters)"
339336

340337
Save-Module @splatParameters

tools/azurePipelinesBuild.ps1

Lines changed: 0 additions & 23 deletions
This file was deleted.

tools/installPSResources.ps1

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
3+
4+
$ErrorActionPreference = 'Stop'
5+
6+
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | Out-Null
7+
if ($PSVersionTable.PSVersion.Major -lt 6) {
8+
throw "The build script requires PowerShell 7!"
9+
}
10+
11+
# TODO: Switch to Install-PSResource when CI uses PowerShell 7.4
12+
Install-Module -Name InvokeBuild -Scope CurrentUser
13+
Install-Module -Name platyPS -Scope CurrentUser
14+
15+
# Update help needed for tests.
16+
Update-Help -Module Microsoft.PowerShell*

0 commit comments

Comments
 (0)