Skip to content

Commit a80f796

Browse files
committed
Split build and test CI so PowerShell Core can be used for the former
Since it's required in order to use our version tools.
1 parent eb1540b commit a80f796

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

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

+18-12
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,6 @@ parameters:
77
default: false
88

99
steps:
10-
- task: PowerShell@2
11-
displayName: PowerShell version
12-
inputs:
13-
targetType: inline
14-
script: $PSVersionTable
15-
pwsh: ${{ parameters.pwsh }}
16-
1710
- checkout: self
1811

1912
# NOTE: We either checkout the Git repo for PowerShellEditorServices, or we
@@ -62,19 +55,32 @@ steps:
6255
version: 6.0.x
6356
performMultiLevelLookup: true
6457

58+
# The build script is always run with PowerShell Core
6559
- task: PowerShell@2
66-
displayName: Build and test
60+
displayName: Build and package
6761
inputs:
6862
targetType: inline
6963
script: |
70-
Get-ChildItem env:
71-
Get-Module -ListAvailable Pester
7264
Install-Module InvokeBuild -Scope CurrentUser -Force
7365
Install-Module platyPS -Scope CurrentUser -Force
74-
Invoke-Build -Configuration Release
66+
Invoke-Build -Configuration Release Package
7567
$PackageJson = Get-Content -Raw package.json | ConvertFrom-Json
7668
Write-Host "##vso[task.setvariable variable=vsixPath]$(Resolve-Path powershell-$($PackageJson.version).vsix)"
7769
workingDirectory: $(Build.SourcesDirectory)/vscode-powershell
70+
pwsh: true
71+
72+
# Tests in particular are run with either PowerShell Core or Windows PowerShell
73+
- task: PowerShell@2
74+
displayName: Run unit tests
75+
inputs:
76+
targetType: inline
77+
script: |
78+
$PSVersionTable
79+
Get-ChildItem env:
80+
Get-Module -ListAvailable Pester
81+
Install-Module InvokeBuild -Scope CurrentUser -Force
82+
Invoke-Build -Configuration Release Test
83+
workingDirectory: $(Build.SourcesDirectory)/vscode-powershell
7884
pwsh: ${{ parameters.pwsh }}
7985

8086
- task: PowerShell@2
@@ -87,7 +93,7 @@ steps:
8793
Write-Host '##vso[task.LogIssue type=error;]PowerShell Editor Services bits were not built in release configuration!'
8894
exit 1
8995
}
90-
pwsh: ${{ parameters.pwsh }}
96+
pwsh: true
9197

9298
- publish: $(vsixPath)
9399
artifact: vscode-powershell-vsix-$(System.JobId)

vscode-powershell.build.ps1

+8-9
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,6 @@ param(
99

1010
#Requires -Modules @{ ModuleName = "InvokeBuild"; ModuleVersion = "3.0.0" }
1111

12-
# Sanity check our changelog version versus package.json (which lacks pre-release label)
13-
Import-Module $PSScriptRoot/tools/VersionTools.psm1
14-
$script:Version = Get-Version -RepositoryName vscode-powershell
15-
$script:PackageVersion = Get-MajorMinorPatch -Version $Version
16-
$script:PackageJson = Get-Content -Raw $PSScriptRoot/package.json | ConvertFrom-Json
17-
Assert-Build ($script:PackageJson.version -eq $script:PackageVersion)
18-
Write-Host "`n### Building Extension Version: $script:Version`n" -ForegroundColor Green
19-
2012
function Get-EditorServicesPath {
2113
$psesRepoPath = if ($EditorServicesRepoPath) {
2214
$EditorServicesRepoPath
@@ -133,7 +125,14 @@ task TestEditorServices -If (Get-EditorServicesPath) {
133125
#region Package tasks
134126

135127
task Package Build, {
136-
Write-Host "`n### Packaging powershell-$script:PackageVersion.vsix`n" -ForegroundColor Green
128+
# Sanity check our changelog version versus package.json (which lacks pre-release label)
129+
Import-Module $PSScriptRoot/tools/VersionTools.psm1
130+
$version = Get-Version -RepositoryName vscode-powershell
131+
$packageVersion = Get-MajorMinorPatch -Version $version
132+
$packageJson = Get-Content -Raw $PSScriptRoot/package.json | ConvertFrom-Json
133+
Assert-Build ($packageJson.version -eq $packageVersion)
134+
135+
Write-Host "`n### Packaging powershell-$packageVersion.vsix`n" -ForegroundColor Green
137136
Assert-Build ((Get-Item ./modules).LinkType -ne "SymbolicLink") "Packaging requires a copy of PSES, not a symlink!"
138137
if (Test-IsPreRelease) {
139138
Write-Host "`n### This is a pre-release!`n" -ForegroundColor Green

0 commit comments

Comments
 (0)