Skip to content

Commit 29c01be

Browse files
[Ignore] Refactor build script and default to preview (#1911)
* refactor build script and default to preview * Switch to BUILDID * add yml optimizations from PSES * switch to writealllines for Windows PowerShell
1 parent bf594e0 commit 29c01be

File tree

5 files changed

+107
-55
lines changed

5 files changed

+107
-55
lines changed

.vsts-ci/azure-pipelines-ci.yml

+29-5
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,37 @@
1-
trigger:
2-
- master
3-
- legacy/1.x
1+
name: PR-$(System.PullRequest.PullRequestNumber)-$(Date:yyyyMMdd)$(Rev:.rr)
2+
43
variables:
5-
# Don't download unneeded packages
4+
# Don't download unneeded packages
65
- name: DOTNET_SKIP_FIRST_TIME_EXPERIENCE
76
value: 'true'
8-
# Don't send telemetry
7+
# Improve performance by not sending telemetry
98
- name: DOTNET_CLI_TELEMETRY_OPTOUT
109
value: 'true'
10+
11+
trigger:
12+
batch: true
13+
branches:
14+
include:
15+
- master
16+
- legacy/1.x
17+
paths:
18+
exclude:
19+
- /.dependabot/*
20+
- /.poshchan/*
21+
- /.github/**/*
22+
- /.vscode/**/*
23+
- /.vsts-ci/misc-analysis.yml
24+
- /tools/**/*
25+
- .editorconfig
26+
- .gitattributes
27+
- .gitignore
28+
- /docs/**/*
29+
- /CHANGELOG.md
30+
- /CONTRIBUTING.md
31+
- /README.md
32+
- /LICENSE
33+
- /CODE_OF_CONDUCT.md
34+
1135
jobs:
1236
- job: Windows
1337
pool:

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

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
steps:
22
# Setup
3+
- pwsh: Write-Host "##vso[build.updatebuildnumber]$env:BUILD_SOURCEBRANCHNAME-$env:BUILD_SOURCEVERSION-$((get-date).ToString("yyyyMMddhhmmss"))"
4+
displayName: Set Build Name for Non-PR
5+
condition: ne(variables['Build.Reason'], 'PullRequest')
36
- pwsh: |
47
git clone https://github.com/PowerShell/PowerShellEditorServices.git ../PowerShellEditorServices
58
Install-Module InvokeBuild -Scope CurrentUser -Force

package.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"name": "powershell",
3-
"displayName": "PowerShell",
4-
"version": "2.0.2",
2+
"name": "powershell-preview",
3+
"displayName": "PowerShell Preview",
4+
"version": "2.0.0-preview.3",
55
"preview": true,
66
"publisher": "ms-vscode",
7-
"description": "Develop PowerShell scripts in Visual Studio Code!",
7+
"description": "(Preview) Develop PowerShell scripts in Visual Studio Code!",
88
"engines": {
99
"vscode": "^1.31.0"
1010
},

tools/releaseBuild/Image/build.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ else {
99
}
1010
}
1111
push-location C:/vscode-powershell
12-
Invoke-Build GetExtensionData,Clean,Build,Test,CheckPreview,Package
12+
Invoke-Build Release
1313
Copy-Item -Verbose -Recurse "C:/vscode-powershell/PowerShell-insiders.vsix" "${target}/PowerShell-insiders.vsix"
1414
Copy-Item -Verbose -Recurse "C:/vscode-powershell/scripts/Install-VSCode.ps1" "${target}/Install-VSCode.ps1"

vscode-powershell.build.ps1

+70-45
Original file line numberDiff line numberDiff line change
@@ -9,29 +9,13 @@ param(
99

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

12-
task GetExtensionData -Before Package {
13-
14-
$script:PackageJson = Get-Content -Raw $PSScriptRoot/package.json | ConvertFrom-Json
15-
$updateVersion = $false
16-
$script:ExtensionVersion = `
17-
if ($env:VSTS_BUILD) {
18-
$updateVersion = $true
19-
$env:VSTS_BUILD_VERSION
20-
}
21-
else {
22-
$script:PackageJson.version
23-
}
24-
25-
if ($updateVersion) {
26-
exec { & npm version $script:ExtensionVersion --no-git-tag-version --allow-same-version }
27-
$script:PackageJson.version = $script:ExtensionVersion
28-
}
12+
# Grab package.json data which is used throughout the build.
13+
$script:PackageJson = Get-Content -Raw $PSScriptRoot/package.json | ConvertFrom-Json
14+
Write-Host "`n### Extension Version: $($script:PackageJson.version) Extension Name: $($script:PackageJson.name)`n" -ForegroundColor Green
2915

30-
$script:ExtensionName = $script:PackageJson.name
31-
Write-Host "`n### Extension Version: $script:ExtensionVersion Extension Name: $script:ExtensionName`n" -ForegroundColor Green
32-
}
16+
#region Utility tasks
3317

34-
task ResolveEditorServicesPath -Before CleanEditorServices, BuildEditorServices, Package {
18+
task ResolveEditorServicesPath -Before CleanEditorServices, BuildEditorServices, TestEditorServices, Package {
3519

3620
$script:psesRepoPath = `
3721
if ($EditorServicesRepoPath) {
@@ -43,7 +27,7 @@ task ResolveEditorServicesPath -Before CleanEditorServices, BuildEditorServices,
4327

4428
if (!(Test-Path $script:psesRepoPath)) {
4529
# Clear the path so that it won't be used
46-
Write-Host "`n### WARNING: The PowerShellEditorServices repo cannot be found at path $script:psesRepoPath`n" -ForegroundColor Yellow
30+
Write-Warning "`nThe PowerShellEditorServices repo cannot be found at path $script:psesRepoPath`n"
4731
$script:psesRepoPath = $null
4832
}
4933
else {
@@ -52,7 +36,18 @@ task ResolveEditorServicesPath -Before CleanEditorServices, BuildEditorServices,
5236
}
5337
}
5438

55-
task Restore RestoreNodeModules -Before Build -If { -not (Test-Path "$PSScriptRoot/node_modules") }
39+
task UploadArtifacts {
40+
if ($env:TF_BUILD) {
41+
# SYSTEM_PHASENAME is the Job name.
42+
Copy-Item -Path PowerShell-insiders.vsix `
43+
-Destination "$env:BUILD_ARTIFACTSTAGINGDIRECTORY/$($script:PackageJson.name)-$($script:PackageJson.version)-$env:SYSTEM_PHASENAME.vsix"
44+
}
45+
}
46+
47+
#endregion
48+
#region Restore tasks
49+
50+
task Restore RestoreNodeModules -If { -not (Test-Path "$PSScriptRoot/node_modules") }
5651

5752
task RestoreNodeModules {
5853

@@ -64,6 +59,9 @@ task RestoreNodeModules {
6459
exec { & npm install $logLevelParam }
6560
}
6661

62+
#endregion
63+
#region Clean tasks
64+
6765
task Clean {
6866
Write-Host "`n### Cleaning vscode-powershell`n" -ForegroundColor Green
6967
Remove-Item .\modules\* -Exclude "README.md" -Recurse -Force -ErrorAction Ignore
@@ -80,7 +78,10 @@ task CleanEditorServices {
8078

8179
task CleanAll CleanEditorServices, Clean
8280

83-
task Build {
81+
#endregion
82+
#region Build tasks
83+
84+
task Build Restore, {
8485
Write-Host "`n### Building vscode-powershell" -ForegroundColor Green
8586
exec { & npm run compile }
8687
}
@@ -95,20 +96,34 @@ task BuildEditorServices {
9596

9697
task BuildAll BuildEditorServices, Build
9798

99+
#endregion
100+
#region Test tasks
101+
98102
task Test Build, {
99103
if (!$global:IsLinux) {
100104
Write-Host "`n### Running extension tests" -ForegroundColor Green
101105
exec { & npm run test }
102106
}
103107
else {
104-
Write-Host "`n### Skipping extension tests on Linux platform" -ForegroundColor Yellow
108+
Write-Warning "Skipping extension tests on Linux platform because vscode does not support it."
105109
}
106110
}
107111

108-
task CheckPreview -If { $script:ExtensionName -like "*Preview*" } `
109-
UpdateReadme, UpdatePackageJson
112+
task TestEditorServices {
113+
if ($script:psesBuildScriptPath) {
114+
Write-Host "`n### Testing PowerShellEditorServices`n" -ForegroundColor Green
115+
Invoke-Build Test $script:psesBuildScriptPath
116+
}
117+
}
118+
119+
task TestAll TestEditorServices, Test
110120

111-
task UpdateReadme {
121+
#endregion
122+
123+
#region Package tasks
124+
125+
task UpdateReadme -If { $script:PackageJson.version -like "*preview*" } {
126+
# Add the preview text
112127
$newReadmeTop = '# PowerShell Language Support for Visual Studio Code
113128
114129
> ## ATTENTION: This is the PREVIEW version of the PowerShell extension for VSCode which contains features that are being evaluated for stable. It works with PowerShell 5.1 and up.
@@ -119,20 +134,34 @@ task UpdateReadme {
119134
$readmeContent = Get-Content -Path $readmePath
120135
if (!($readmeContent -match "This is the PREVIEW version of the PowerShell extension")) {
121136
$readmeContent[0] = $newReadmeTop
122-
$readmeContent > $readmePath
137+
$readmeContent | Set-Content $readmePath -Encoding utf8
123138
}
124139
}
125140

126141
task UpdatePackageJson {
127-
$script:PackageJson.name = "powershell-preview"
128-
$script:PackageJson.displayName = "PowerShell Preview"
129-
$script:PackageJson.description = "(Preview) Develop PowerShell scripts in Visual Studio Code!"
130-
$script:PackageJson.preview = $true
131-
$script:ExtensionName = $script:PackageJson.name
132-
Set-Content -Path $PSScriptRoot/package.json ($script:PackageJson | ConvertTo-Json -Depth 100)
142+
if ($script:PackageJson.version -like "*preview*") {
143+
$script:PackageJson.name = "powershell-preview"
144+
$script:PackageJson.displayName = "PowerShell Preview"
145+
$script:PackageJson.description = "(Preview) Develop PowerShell scripts in Visual Studio Code!"
146+
$script:PackageJson.preview = $true
147+
} else {
148+
$script:PackageJson.name = "powershell"
149+
$script:PackageJson.displayName = "PowerShell"
150+
$script:PackageJson.description = "Develop PowerShell scripts in Visual Studio Code!"
151+
$script:PackageJson.preview = $false
152+
}
153+
154+
$revision = if ($env:BUILD_BUILDID) { $env:BUILD_BUILDID } else { 9999 }
155+
$script:PackageJson.version = "$(Get-Date -Format 'yyyy.M').$revision"
156+
157+
$Utf8NoBomEncoding = [System.Text.UTF8Encoding]::new($false)
158+
[System.IO.File]::WriteAllLines(
159+
(Resolve-Path "$PSScriptRoot/package.json").Path,
160+
($script:PackageJson | ConvertTo-Json -Depth 100),
161+
$Utf8NoBomEncoding)
133162
}
134163

135-
task Package {
164+
task Package UpdateReadme, UpdatePackageJson, {
136165

137166
if ($script:psesBuildScriptPath) {
138167
Write-Host "`n### Copying PowerShellEditorServices module files" -ForegroundColor Green
@@ -149,16 +178,12 @@ task Package {
149178
exec { & node ./node_modules/vsce/out/vsce package }
150179

151180
# Change the package to have a static name for automation purposes
152-
Move-Item -Force .\$($script:ExtensionName)-$($script:ExtensionVersion).vsix .\PowerShell-insiders.vsix
181+
Move-Item -Force .\$($script:PackageJson.name)-$($script:PackageJson.version).vsix .\PowerShell-insiders.vsix
153182
}
154183

155-
task UploadArtifacts {
156-
if ($env:TF_BUILD) {
157-
# SYSTEM_PHASENAME is the Job name.
158-
Copy-Item -Path PowerShell-insiders.vsix `
159-
-Destination "$env:BUILD_ARTIFACTSTAGINGDIRECTORY/$script:ExtensionName-$script:ExtensionVersion-$env:SYSTEM_PHASENAME.vsix"
160-
}
161-
}
184+
#endregion
162185

186+
# The set of tasks for a release
187+
task Release Clean, Build, Test, Package
163188
# The default task is to run the entire CI build
164-
task . GetExtensionData, CleanAll, BuildAll, Test, CheckPreview, Package, UploadArtifacts
189+
task . CleanAll, BuildAll, Test, Package, UploadArtifacts

0 commit comments

Comments
 (0)