diff --git a/.vsts-ci/azure-pipelines-ci.yml b/.vsts-ci/azure-pipelines-ci.yml index b82e66b037..7fba9ada74 100644 --- a/.vsts-ci/azure-pipelines-ci.yml +++ b/.vsts-ci/azure-pipelines-ci.yml @@ -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: diff --git a/.vsts-ci/templates/ci-general.yml b/.vsts-ci/templates/ci-general.yml index 003f0f2900..bbc75f3c2f 100644 --- a/.vsts-ci/templates/ci-general.yml +++ b/.vsts-ci/templates/ci-general.yml @@ -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 diff --git a/package.json b/package.json index 9632ff2449..e87fdc2cc6 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/tools/releaseBuild/Image/build.ps1 b/tools/releaseBuild/Image/build.ps1 index eb778b1ebf..b4014d7f3e 100644 --- a/tools/releaseBuild/Image/build.ps1 +++ b/tools/releaseBuild/Image/build.ps1 @@ -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" diff --git a/vscode-powershell.build.ps1 b/vscode-powershell.build.ps1 index baa161fa30..b57b35cfca 100644 --- a/vscode-powershell.build.ps1 +++ b/vscode-powershell.build.ps1 @@ -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) { @@ -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 { @@ -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 { @@ -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 @@ -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 } } @@ -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 @@ -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