Skip to content

Backport build script refactor to date-based versions legacy #1938

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 29 additions & 5 deletions .vsts-ci/azure-pipelines-ci.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,37 @@
trigger:
- master
- legacy/1.x
name: PR-$(System.PullRequest.PullRequestNumber)-$(Date:yyyyMMdd)$(Rev:.rr)

variables:
# Don't download unneeded packages
# Don't download unneeded packages
- name: DOTNET_SKIP_FIRST_TIME_EXPERIENCE
value: 'true'
# Don't send telemetry
# Improve performance by not sending telemetry
- name: DOTNET_CLI_TELEMETRY_OPTOUT
value: 'true'

trigger:
batch: true
branches:
include:
- master
- legacy/1.x
paths:
exclude:
- /.dependabot/*
- /.poshchan/*
- /.github/**/*
- /.vscode/**/*
- /.vsts-ci/misc-analysis.yml
- /tools/**/*
- .editorconfig
- .gitattributes
- .gitignore
- /docs/**/*
- /CHANGELOG.md
- /CONTRIBUTING.md
- /README.md
- /LICENSE
- /CODE_OF_CONDUCT.md

jobs:
- job: Windows
pool:
Expand Down
3 changes: 3 additions & 0 deletions .vsts-ci/templates/ci-general.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
steps:
# Setup
- pwsh: Write-Host "##vso[build.updatebuildnumber]$env:BUILD_SOURCEBRANCHNAME-$env:BUILD_SOURCEVERSION-$((get-date).ToString("yyyyMMddhhmmss"))"
displayName: Set Build Name for Non-PR
condition: ne(variables['Build.Reason'], 'PullRequest')
- pwsh: |
git clone https://github.com/PowerShell/PowerShellEditorServices.git ../PowerShellEditorServices
Install-Module InvokeBuild -Scope CurrentUser -Force
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "powershell",
"displayName": "PowerShell",
"version": "1.12.1",
"preview": false,
"publisher": "ms-vscode",
"description": "Develop PowerShell scripts in Visual Studio Code!",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion tools/releaseBuild/Image/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ else {
}
}
push-location C:/vscode-powershell
Invoke-Build GetExtensionVersion,Clean,Build,Test,Package
Invoke-Build Release
Copy-Item -Verbose -Recurse "C:/vscode-powershell/PowerShell-insiders.vsix" "${target}/PowerShell-insiders.vsix"
116 changes: 83 additions & 33 deletions vscode-powershell.build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,12 @@ param(

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

task GetExtensionVersion -Before Package {
# Grab package.json data which is used throughout the build.
$script:PackageJson = Get-Content -Raw $PSScriptRoot/package.json | ConvertFrom-Json
Write-Host "`n### Extension Version: $($script:PackageJson.version) Extension Name: $($script:PackageJson.name)`n" -ForegroundColor Green

$updateVersion = $false
$script:ExtensionVersion = `
if ($env:VSTS_BUILD) {
$updateVersion = $true
$env:VSTS_BUILD_VERSION
}
else {
exec { & npm version | ConvertFrom-Json | ForEach-Object { $_.PowerShell } }
}

Write-Host "`n### Extension Version: $script:ExtensionVersion`n" -ForegroundColor Green

if ($updateVersion) {
exec { & npm version $script:ExtensionVersion --no-git-tag-version --allow-same-version }
}
}

task ResolveEditorServicesPath -Before CleanEditorServices, BuildEditorServices {
#region Utility tasks
task ResolveEditorServicesPath -Before CleanEditorServices, TestEditorServices, BuildEditorServices {

$script:psesRepoPath = `
if ($EditorServicesRepoPath) {
Expand All @@ -40,7 +26,7 @@ task ResolveEditorServicesPath -Before CleanEditorServices, BuildEditorServices

if (!(Test-Path $script:psesRepoPath)) {
# Clear the path so that it won't be used
Write-Host "`n### WARNING: The PowerShellEditorServices repo cannot be found at path $script:psesRepoPath`n" -ForegroundColor Yellow
Write-Warning "`nThe PowerShellEditorServices repo cannot be found at path $script:psesRepoPath`n"
$script:psesRepoPath = $null
}
else {
Expand All @@ -49,7 +35,18 @@ task ResolveEditorServicesPath -Before CleanEditorServices, BuildEditorServices
}
}

task Restore RestoreNodeModules -Before Build -If { -not (Test-Path "$PSScriptRoot/node_modules") }
task UploadArtifacts {
if ($env:TF_BUILD) {
# SYSTEM_PHASENAME is the Job name.
Copy-Item -Path PowerShell-insiders.vsix `
-Destination "$env:BUILD_ARTIFACTSTAGINGDIRECTORY/$($script:PackageJson.name)-$($script:PackageJson.version)-$env:SYSTEM_PHASENAME.vsix"
}
}

#endregion
#region Restore tasks

task Restore RestoreNodeModules -If { -not (Test-Path "$PSScriptRoot/node_modules") }

task RestoreNodeModules {

Expand All @@ -61,6 +58,9 @@ task RestoreNodeModules {
exec { & npm install $logLevelParam }
}

#endregion
#region Clean tasks

task Clean {
Write-Host "`n### Cleaning vscode-powershell`n" -ForegroundColor Green
Remove-Item .\modules\* -Exclude "README.md" -Recurse -Force -ErrorAction Ignore
Expand All @@ -77,7 +77,10 @@ task CleanEditorServices {

task CleanAll CleanEditorServices, Clean

task Build {
#endregion
#region Build tasks

task Build Restore, {
Write-Host "`n### Building vscode-powershell" -ForegroundColor Green
exec { & npm run compile }
}
Expand All @@ -92,17 +95,68 @@ task BuildEditorServices {

task BuildAll BuildEditorServices, Build

#endregion
#region Test tasks

task Test Build, {
if (!$global:IsLinux -and !$global:IsMacOS) {
Write-Host "`n### Running extension tests" -ForegroundColor Green
exec { & npm run test }
}
else {
Write-Host "`n### Skipping extension tests on non-Windows platform" -ForegroundColor Yellow
Write-Warning "Skipping extension tests on Linux and macOS platform for legacy branch."
}
}

task Package {
task TestEditorServices {
if ($script:psesBuildScriptPath) {
Write-Host "`n### Testing PowerShellEditorServices`n" -ForegroundColor Green
Invoke-Build Test $script:psesBuildScriptPath
}
}

task TestAll TestEditorServices, Test

#endregion
#region Package tasks

task UpdateReadme -If { $script:PackageJson.version -like "*preview*" } {
# Add the preview text
$newReadmeTop = '# PowerShell Language Support for Visual Studio Code
> ## 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.
> ### If you are looking for the stable version, please [go here](https://marketplace.visualstudio.com/items?itemName=ms-vscode.PowerShell) or install the extension called "PowerShell" (not "PowerShell Preview")
> ## NOTE: If you have both stable (aka "PowerShell") and preview (aka "PowerShell Preview") installed, you MUST [DISABLE](https://code.visualstudio.com/docs/editor/extension-gallery#_disable-an-extension) one of them for the best performance. Docs on how to disable an extension can be found [here](https://code.visualstudio.com/docs/editor/extension-gallery#_disable-an-extension)'
$readmePath = (Join-Path $PSScriptRoot README.md)
$readmeContent = Get-Content -Path $readmePath
if (!($readmeContent -match "This is the PREVIEW version of the PowerShell extension")) {
$readmeContent[0] = $newReadmeTop
$readmeContent | Set-Content $readmePath -Encoding utf8
}
}

task UpdatePackageJson {
if ($script:PackageJson.version -like "*preview*") {
$script:PackageJson.name = "powershell-preview"
$script:PackageJson.displayName = "PowerShell Preview"
$script:PackageJson.description = "(Preview) Develop PowerShell scripts in Visual Studio Code!"
$script:PackageJson.preview = $true
} else {
$script:PackageJson.name = "powershell"
$script:PackageJson.displayName = "PowerShell"
$script:PackageJson.description = "Develop PowerShell scripts in Visual Studio Code!"
$script:PackageJson.preview = $false
}

$revision = if ($env:BUILD_BUILDID) { $env:BUILD_BUILDID } else { 9999 }
$script:PackageJson.version = "$(Get-Date -Format 'yyyy.M').$revision"

$Utf8NoBomEncoding = [System.Text.UTF8Encoding]::new($false)
[System.IO.File]::WriteAllLines(
(Resolve-Path "$PSScriptRoot/package.json").Path,
($script:PackageJson | ConvertTo-Json -Depth 100),
$Utf8NoBomEncoding)
}
task Package UpdateReadme, UpdatePackageJson, {

if ($script:psesBuildScriptPath) {
Write-Host "`n### Copying PowerShellEditorServices module files" -ForegroundColor Green
Expand All @@ -119,16 +173,12 @@ task Package {
exec { & node ./node_modules/vsce/out/vsce package }

# Change the package to have a static name for automation purposes
Move-Item -Force .\powershell-$($script:ExtensionVersion).vsix .\PowerShell-insiders.vsix
Move-Item -Force .\$($script:PackageJson.name)-$($script:PackageJson.version).vsix .\PowerShell-insiders.vsix
}

task UploadArtifacts {
if ($env:TF_BUILD) {
# SYSTEM_PHASENAME is the Job name.
Copy-Item -Path PowerShell-insiders.vsix `
-Destination "$env:BUILD_ARTIFACTSTAGINGDIRECTORY/powershell-$script:ExtensionVersion-$env:SYSTEM_PHASENAME.vsix"
}
}
#endregion

# The set of tasks for a release
task Release Clean, Build, Test, Package
# The default task is to run the entire CI build
task . GetExtensionVersion, BuildAll, Test, Package, UploadArtifacts
task . Clean, BuildAll, Test, Package, UploadArtifacts