From 1d6055fbb385527a6d15d67fcc51c6ce39122749 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 23 Jul 2021 10:32:26 -0700 Subject: [PATCH 1/8] Replace Tyler with Andy in GitHub code owners --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 76be6cf65..4d54b18d7 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,7 +1,7 @@ # https://help.github.com/articles/about-codeowners/ # Global reviewers -* @tylerl0706 @rjmholt +* @andschwa @rjmholt # Area: Analysis & Formatting src/PowerShellEditorServices/Analysis/ @rjmholt From 629e1c098e2644a53df3d97aeff399b2ef05b263 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 23 Jul 2021 10:33:48 -0700 Subject: [PATCH 2/8] Add Windows Server 2019 with PowerShell 5.1 to matrix --- .vsts-ci/azure-pipelines-ci.yml | 35 ++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/.vsts-ci/azure-pipelines-ci.yml b/.vsts-ci/azure-pipelines-ci.yml index d9ff9a82d..0551e0b13 100644 --- a/.vsts-ci/azure-pipelines-ci.yml +++ b/.vsts-ci/azure-pipelines-ci.yml @@ -32,35 +32,42 @@ trigger: - /LICENSE - /CODE_OF_CONDUCT.md -# TODO: Setup matrix of image support. jobs: -- job: 'PS51_Win10' - displayName: PowerShell 5.1 | Windows 10 +- job: PS51_Win2016 + displayName: PowerShell 5.1 - Windows Server 2016 pool: - # TODO: Update this image. - vmImage: 'vs2017-win2016' + vmImage: vs2017-win2016 steps: - template: templates/ci-general.yml parameters: pwsh: false -- job: 'PS7_Win10' - displayName: PowerShell 7 | Windows 10 +- job: PS51_Win2019 + displayName: PowerShell 5.1 - Windows Server 2019 pool: - vmImage: 'windows-2019' + vmImage: windows-2019 + steps: + - template: templates/ci-general.yml + parameters: + pwsh: false + +- job: PS7_Win2019 + displayName: PowerShell 7 - Windows Server 2019 + pool: + vmImage: windows-2019 steps: - template: templates/ci-general.yml -- job: 'PS7_macOS' - displayName: PowerShell 7 | macOS +- job: PS7_macOS + displayName: PowerShell 7 - macOS 10.15 pool: - vmImage: 'macOS-10.15' + vmImage: macOS-10.15 steps: - template: templates/ci-general.yml -- job: 'PS7_Ubuntu' - displayName: PowerShell 7 | Ubuntu +- job: PS7_Ubuntu + displayName: PowerShell 7 - Ubuntu 20.04 pool: - vmImage: 'ubuntu-20.04' + vmImage: ubuntu-20.04 steps: - template: templates/ci-general.yml From 2a13e7b7a7ffd654ab2a89d3b1194a35cfeb0a2c Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 23 Jul 2021 10:35:27 -0700 Subject: [PATCH 3/8] A little more cleanup Also fixes the endpoing for the PR compliance job. --- .vsts-ci/azure-pipelines-ci.yml | 19 ------------------- .vsts-ci/misc-analysis.yml | 15 +++------------ .vsts-ci/templates/ci-general.yml | 2 +- .vsts-ci/templates/publish-general.yml | 10 +++++++++- .vsts-ci/templates/release-general.yml | 11 +++++------ 5 files changed, 18 insertions(+), 39 deletions(-) diff --git a/.vsts-ci/azure-pipelines-ci.yml b/.vsts-ci/azure-pipelines-ci.yml index 0551e0b13..da48dddde 100644 --- a/.vsts-ci/azure-pipelines-ci.yml +++ b/.vsts-ci/azure-pipelines-ci.yml @@ -9,28 +9,9 @@ variables: 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: PS51_Win2016 diff --git a/.vsts-ci/misc-analysis.yml b/.vsts-ci/misc-analysis.yml index 1c229a7ae..0e301f05f 100644 --- a/.vsts-ci/misc-analysis.yml +++ b/.vsts-ci/misc-analysis.yml @@ -1,31 +1,22 @@ name: PR-$(System.PullRequest.PullRequestNumber)-$(Date:yyyyMMdd)$(Rev:.rr) -trigger: - # Batch merge builds together while a merge build is running - batch: true - branches: - include: - - master -pr: +trigger: branches: include: - master - - legacy/1.x resources: repositories: - repository: ComplianceRepo type: github - endpoint: ComplianceGHRepo + endpoint: GitHub name: PowerShell/compliance jobs: -- job: Compliance_Job +- job: Compliance pool: vmImage: windows-latest steps: - checkout: self - clean: true - checkout: ComplianceRepo - clean: true - template: ci-compliance.yml@ComplianceRepo diff --git a/.vsts-ci/templates/ci-general.yml b/.vsts-ci/templates/ci-general.yml index f3e237e88..d56ce9387 100644 --- a/.vsts-ci/templates/ci-general.yml +++ b/.vsts-ci/templates/ci-general.yml @@ -4,7 +4,7 @@ parameters: default: true steps: -- pwsh: '$PSVersionTable' +- pwsh: $PSVersionTable displayName: PowerShell version - task: PowerShell@2 diff --git a/.vsts-ci/templates/publish-general.yml b/.vsts-ci/templates/publish-general.yml index 56177e389..0c1ee715e 100644 --- a/.vsts-ci/templates/publish-general.yml +++ b/.vsts-ci/templates/publish-general.yml @@ -1,15 +1,23 @@ steps: - checkout: self + - checkout: vscode-powershell + - download: current artifact: PowerShellEditorServices displayName: Download signed pipeline artifacts + - pwsh: | + Write-Host "Install and import PowerShell modules" Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | Out-Null - Install-Module -Name PowerShellForGitHub -Scope CurrentUser -Force -Confirm:$false + Install-Module -Name PowerShellForGitHub -Scope CurrentUser -Force Import-Module '$(Build.SourcesDirectory)/vscode-powershell/tools/ReleaseTools.psm1' + + Write-Host "Setup authentication" Set-GitHubConfiguration -SuppressTelemetryReminder $password = ConvertTo-SecureString -String '$(GitHubToken)' -AsPlainText -Force Set-GitHubAuthentication -Credential (New-Object System.Management.Automation.PSCredential ("token", $password)) + + Write-Host "Publish draft release" New-DraftRelease -RepositoryName PowerShellEditorServices -Assets '$(Pipeline.Workspace)/PowerShellEditorServices/PowerShellEditorServices.zip' displayName: Drafting a GitHub Release diff --git a/.vsts-ci/templates/release-general.yml b/.vsts-ci/templates/release-general.yml index a56229448..2bd8914d8 100644 --- a/.vsts-ci/templates/release-general.yml +++ b/.vsts-ci/templates/release-general.yml @@ -1,5 +1,4 @@ steps: - - download: current displayName: Download unsigned pipeline artifacts @@ -52,10 +51,6 @@ steps: replaceExistingArchive: true verbose: true -- publish: PowerShellEditorServices.zip - artifact: PowerShellEditorServices - displayName: Publish signed pipeline artifacts - - checkout: self - template: assembly-module-compliance.yml@ComplianceRepo @@ -74,5 +69,9 @@ steps: optionsFTPath: $(Build.SourcesDirectory)/PowerShellEditorServices/tools/terms/FileTypeSet.xml # tsa-upload codeBaseName: PowerShell_PowerShellEditorServices_20210201 - # selections + # We don't use any Windows APIs directly, so we don't need API scan APIScan: false + +- publish: PowerShellEditorServices.zip + artifact: PowerShellEditorServices + displayName: Publish signed pipeline artifacts From fef7fad41a4d8ed412ec030b3267a8707bd81a52 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 23 Jul 2021 13:34:29 -0700 Subject: [PATCH 4/8] Share `ReleaseTools` setup with `vscode-powershell` Also change trigger to the `release` branch per upstream changes. --- .vsts-ci/azure-pipelines-release.yml | 5 +---- .vsts-ci/templates/publish-general.yml | 15 ++------------- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/.vsts-ci/azure-pipelines-release.yml b/.vsts-ci/azure-pipelines-release.yml index aecf27d07..5007f4738 100644 --- a/.vsts-ci/azure-pipelines-release.yml +++ b/.vsts-ci/azure-pipelines-release.yml @@ -11,10 +11,7 @@ variables: trigger: branches: include: - - release/* - tags: - include: - - v* + - release resources: repositories: diff --git a/.vsts-ci/templates/publish-general.yml b/.vsts-ci/templates/publish-general.yml index 0c1ee715e..cb26033b3 100644 --- a/.vsts-ci/templates/publish-general.yml +++ b/.vsts-ci/templates/publish-general.yml @@ -1,6 +1,5 @@ steps: - checkout: self - - checkout: vscode-powershell - download: current @@ -8,16 +7,6 @@ steps: displayName: Download signed pipeline artifacts - pwsh: | - Write-Host "Install and import PowerShell modules" - Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | Out-Null - Install-Module -Name PowerShellForGitHub -Scope CurrentUser -Force - Import-Module '$(Build.SourcesDirectory)/vscode-powershell/tools/ReleaseTools.psm1' - - Write-Host "Setup authentication" - Set-GitHubConfiguration -SuppressTelemetryReminder - $password = ConvertTo-SecureString -String '$(GitHubToken)' -AsPlainText -Force - Set-GitHubAuthentication -Credential (New-Object System.Management.Automation.PSCredential ("token", $password)) - - Write-Host "Publish draft release" - New-DraftRelease -RepositoryName PowerShellEditorServices -Assets '$(Pipeline.Workspace)/PowerShellEditorServices/PowerShellEditorServices.zip' + $(Build.SourcesDirectory)/vscode-powershell/tools/setupReleaseTools.ps1 -Token $(GitHubToken) + New-DraftRelease -RepositoryName PowerShellEditorServices -Assets $(Pipeline.Workspace)/PowerShellEditorServices/PowerShellEditorServices.zip displayName: Drafting a GitHub Release From f43a656123e2fa9a51a1a7ef67901ac72b5422b7 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 23 Jul 2021 13:35:16 -0700 Subject: [PATCH 5/8] Update release agent images --- .vsts-ci/azure-pipelines-release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.vsts-ci/azure-pipelines-release.yml b/.vsts-ci/azure-pipelines-release.yml index 5007f4738..e3e1d934a 100644 --- a/.vsts-ci/azure-pipelines-release.yml +++ b/.vsts-ci/azure-pipelines-release.yml @@ -29,7 +29,7 @@ stages: jobs: - job: Build pool: - vmImage: vs2017-win2016 + vmImage: windows-2019 steps: - template: templates/ci-general.yml @@ -51,7 +51,7 @@ stages: - deployment: Publish environment: PowerShellEditorServices pool: - name: 1ES + vmImage: ubuntu-latest variables: - group: Publish strategy: From 51cb7eac984d2e4ef51610dd1f52254c83a9fb59 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Mon, 26 Jul 2021 11:09:22 -0700 Subject: [PATCH 6/8] Zip artifacts before publishing We apparently have very limited artifact storage on Azure DevOps, and since these artifacts to compress from ~300 MB to ~20 MB, this is a decent workaround. The only cost is that zip files instead of navigable folders will show up in the artifact viewer. --- .vsts-ci/templates/ci-general.yml | 14 ++++++++++++-- .vsts-ci/templates/release-general.yml | 11 +++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.vsts-ci/templates/ci-general.yml b/.vsts-ci/templates/ci-general.yml index d56ce9387..016b340dc 100644 --- a/.vsts-ci/templates/ci-general.yml +++ b/.vsts-ci/templates/ci-general.yml @@ -13,10 +13,20 @@ steps: filePath: tools/azurePipelinesBuild.ps1 pwsh: ${{ parameters.pwsh }} -- publish: module +# NOTE: We zip the artifacts because they're ~20 MB compressed, but ~300 MB raw, +# and we have limited pipeline artifact storage space. +- task: ArchiveFiles@2 + displayName: Zip pipeline artifacts + inputs: + rootFolderOrFile: module + includeRootFolder: false + archiveType: zip + archiveFile: PowerShellEditorServices-Build.zip + verbose: true + +- publish: PowerShellEditorServices-Build.zip artifact: PowerShellEditorServices-Build-$(System.JobId) displayName: Publish unsigned pipeline artifacts - condition: succeededOrFailed() - task: PublishTestResults@2 displayName: Publish test results diff --git a/.vsts-ci/templates/release-general.yml b/.vsts-ci/templates/release-general.yml index 2bd8914d8..7ef4e1479 100644 --- a/.vsts-ci/templates/release-general.yml +++ b/.vsts-ci/templates/release-general.yml @@ -2,13 +2,20 @@ steps: - download: current displayName: Download unsigned pipeline artifacts +- task: ExtractFiles@1 + displayName: Extract unsigned artifacts + inputs: + archiveFilePatterns: $(Pipeline.Workspace)/PowerShellEditorServices-Build-*/PowerShellEditorServices-Build.zip + destinationFolder: $(Pipeline.Workspace)/Unsigned + cleanDestinationFolder: true + - checkout: ComplianceRepo # NOTE: The signing templates explicitly copy everything along as they run, so # the last output path has every signed (and intentionally unsigned) file. - template: EsrpSign.yml@ComplianceRepo parameters: - buildOutputPath: $(Pipeline.Workspace)/PowerShellEditorServices-Build-* + buildOutputPath: $(Pipeline.Workspace)/Unsigned signOutputPath: $(Pipeline.Workspace)/FirstPartySigned alwaysCopy: true certificateId: CP-230012 # Authenticode certificate @@ -42,7 +49,7 @@ steps: **/UnixConsoleEcho.dll - task: ArchiveFiles@2 - displayName: Zip finished assets + displayName: Zip signed artifacts inputs: rootFolderOrFile: $(Pipeline.Workspace)/ThirdPartySigned includeRootFolder: false From 8cf570b68836ea04d3869fd072ac57a08dbb713b Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Mon, 26 Jul 2021 12:58:29 -0700 Subject: [PATCH 7/8] Force installation of required modules in `azurePipelinesBuild.ps1` This suddenly decided to be an issue, where the modules were being not being installed because `-Force` was missing (also clean up because we don't need `-Confirm:$false`). --- tools/azurePipelinesBuild.ps1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/azurePipelinesBuild.ps1 b/tools/azurePipelinesBuild.ps1 index ef25e0595..3bdb78af2 100644 --- a/tools/azurePipelinesBuild.ps1 +++ b/tools/azurePipelinesBuild.ps1 @@ -6,9 +6,9 @@ $ErrorActionPreference = 'Stop' Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | Out-Null if ($IsWindows -or $PSVersionTable.PSVersion.Major -lt 6) { # We rely on PowerShellGet's -AllowPrerelease which is in PowerShellGet 1.6 so we need to update PowerShellGet. - Get-Module PowerShellGet,PackageManagement | Remove-Module -Force -Verbose - powershell -Command { Install-Module -Name PowerShellGet -MinimumVersion 1.6 -Force -Confirm:$false -Verbose } - powershell -Command { Install-Module -Name PackageManagement -MinimumVersion 1.1.7.0 -Force -Confirm:$false -Verbose } + Get-Module PowerShellGet,PackageManagement | Remove-Module -Force + powershell -Command { Install-Module -Name PowerShellGet -MinimumVersion 1.6 -Force } + powershell -Command { Install-Module -Name PackageManagement -MinimumVersion 1.1.7.0 -Force } Import-Module -Name PowerShellGet -MinimumVersion 1.6 -Force Import-Module -Name PackageManagement -MinimumVersion 1.1.7.0 -Force } @@ -17,7 +17,7 @@ if ($IsWindows -or $PSVersionTable.PSVersion.Major -lt 6) { Update-Help -Force -ErrorAction SilentlyContinue # Needed for build and docs gen. -Install-Module InvokeBuild -MaximumVersion 5.1.0 -Scope CurrentUser -Install-Module PlatyPS -RequiredVersion 0.9.0 -Scope CurrentUser +Install-Module -Name InvokeBuild -MaximumVersion 5.1.0 -Scope CurrentUser -Force +Install-Module -Name PlatyPS -RequiredVersion 0.9.0 -Scope CurrentUser -Force Invoke-Build -Configuration Release From fc903fe0faefd89b8b40029d4e5e6a27d3a1e777 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Mon, 26 Jul 2021 18:04:00 -0700 Subject: [PATCH 8/8] Add PR trigger back to YAML I think these previously worked without the YAML PR trigger because of GUI setup that I messed up by changing the service connection. --- .vsts-ci/azure-pipelines-ci.yml | 3 +++ .vsts-ci/misc-analysis.yml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/.vsts-ci/azure-pipelines-ci.yml b/.vsts-ci/azure-pipelines-ci.yml index da48dddde..25706f2c0 100644 --- a/.vsts-ci/azure-pipelines-ci.yml +++ b/.vsts-ci/azure-pipelines-ci.yml @@ -13,6 +13,9 @@ trigger: include: - master +pr: +- master + jobs: - job: PS51_Win2016 displayName: PowerShell 5.1 - Windows Server 2016 diff --git a/.vsts-ci/misc-analysis.yml b/.vsts-ci/misc-analysis.yml index 0e301f05f..2647eb182 100644 --- a/.vsts-ci/misc-analysis.yml +++ b/.vsts-ci/misc-analysis.yml @@ -5,6 +5,9 @@ trigger: include: - master +pr: +- master + resources: repositories: - repository: ComplianceRepo