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 eee9962440..49af89082b 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { - "name": "powershell", - "displayName": "PowerShell", - "version": "2.0.2", + "name": "powershell-preview", + "displayName": "PowerShell Preview", + "version": "2.0.0-preview.3", "preview": true, "publisher": "ms-vscode", - "description": "Develop PowerShell scripts in Visual Studio Code!", + "description": "(Preview) Develop PowerShell scripts in Visual Studio Code!", "engines": { "vscode": "^1.31.0" }, diff --git a/tools/releaseBuild/Image/build.ps1 b/tools/releaseBuild/Image/build.ps1 index 8b38e0f380..1a5242a914 100644 --- a/tools/releaseBuild/Image/build.ps1 +++ b/tools/releaseBuild/Image/build.ps1 @@ -9,6 +9,6 @@ else { } } push-location C:/vscode-powershell -Invoke-Build GetExtensionData,Clean,Build,Test,CheckPreview,Package +Invoke-Build Release Copy-Item -Verbose -Recurse "C:/vscode-powershell/PowerShell-insiders.vsix" "${target}/PowerShell-insiders.vsix" Copy-Item -Verbose -Recurse "C:/vscode-powershell/scripts/Install-VSCode.ps1" "${target}/Install-VSCode.ps1" diff --git a/vscode-powershell.build.ps1 b/vscode-powershell.build.ps1 index 97232fddc7..2dcefe74d2 100644 --- a/vscode-powershell.build.ps1 +++ b/vscode-powershell.build.ps1 @@ -9,29 +9,13 @@ param( #Requires -Modules @{ModuleName="InvokeBuild";ModuleVersion="3.0.0"} -task GetExtensionData -Before Package { - - $script:PackageJson = Get-Content -Raw $PSScriptRoot/package.json | ConvertFrom-Json - $updateVersion = $false - $script:ExtensionVersion = ` - if ($env:VSTS_BUILD) { - $updateVersion = $true - $env:VSTS_BUILD_VERSION - } - else { - $script:PackageJson.version - } - - if ($updateVersion) { - exec { & npm version $script:ExtensionVersion --no-git-tag-version --allow-same-version } - $script:PackageJson.version = $script:ExtensionVersion - } +# 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 - $script:ExtensionName = $script:PackageJson.name - Write-Host "`n### Extension Version: $script:ExtensionVersion Extension Name: $script:ExtensionName`n" -ForegroundColor Green -} +#region Utility tasks -task ResolveEditorServicesPath -Before CleanEditorServices, BuildEditorServices, Package { +task ResolveEditorServicesPath -Before CleanEditorServices, BuildEditorServices, TestEditorServices, Package { $script:psesRepoPath = ` if ($EditorServicesRepoPath) { @@ -43,7 +27,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 { @@ -52,7 +36,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 { @@ -64,6 +59,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 @@ -80,7 +78,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 } } @@ -95,20 +96,34 @@ task BuildEditorServices { task BuildAll BuildEditorServices, Build +#endregion +#region Test tasks + task Test Build, { if (!$global:IsLinux) { Write-Host "`n### Running extension tests" -ForegroundColor Green exec { & npm run test } } else { - Write-Host "`n### Skipping extension tests on Linux platform" -ForegroundColor Yellow + Write-Warning "Skipping extension tests on Linux platform because vscode does not support it." } } -task CheckPreview -If { $script:ExtensionName -like "*Preview*" } ` - UpdateReadme, UpdatePackageJson +task TestEditorServices { + if ($script:psesBuildScriptPath) { + Write-Host "`n### Testing PowerShellEditorServices`n" -ForegroundColor Green + Invoke-Build Test $script:psesBuildScriptPath + } +} + +task TestAll TestEditorServices, Test -task UpdateReadme { +#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. @@ -119,20 +134,34 @@ task UpdateReadme { $readmeContent = Get-Content -Path $readmePath if (!($readmeContent -match "This is the PREVIEW version of the PowerShell extension")) { $readmeContent[0] = $newReadmeTop - $readmeContent > $readmePath + $readmeContent | Set-Content $readmePath -Encoding utf8 } } task UpdatePackageJson { - $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 - $script:ExtensionName = $script:PackageJson.name - Set-Content -Path $PSScriptRoot/package.json ($script:PackageJson | ConvertTo-Json -Depth 100) + 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 { +task Package UpdateReadme, UpdatePackageJson, { if ($script:psesBuildScriptPath) { Write-Host "`n### Copying PowerShellEditorServices module files" -ForegroundColor Green @@ -149,16 +178,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 .\$($script:ExtensionName)-$($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/$script:ExtensionName-$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 . GetExtensionData, CleanAll, BuildAll, Test, CheckPreview, Package, UploadArtifacts +task . CleanAll, BuildAll, Test, Package, UploadArtifacts