Skip to content

Commit a987d4d

Browse files
committed
Make CI build template actually generic
This now uses a repository resource or the triggering pipeline artifact to provide the PowerShellEditorServices sources (or bits). Coupled with the change to the build script, this means the template can be used to build for CI or for a release. We also moved to zipped pipeline artifacts as build artifacts have been deprecated, but we need to reduce the cost of the stored artifacts themselves. These are provided for developers to test and for the release pipeline to use.
1 parent 660ab45 commit a987d4d

File tree

2 files changed

+57
-22
lines changed

2 files changed

+57
-22
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ trigger:
1313
include:
1414
- master
1515

16+
resources:
17+
repositories:
18+
- repository: PowerShellEditorServices
19+
type: github
20+
endpoint: GitHub
21+
name: PowerShell/PowerShellEditorServices
22+
ref: master
23+
1624
jobs:
1725
- job: Win2019
1826
displayName: Windows Server 2019

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

Lines changed: 49 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,57 @@
1+
parameters:
2+
- name: usePipelineArtifact
3+
type: boolean
4+
default: false
5+
16
steps:
2-
- pwsh: '$PSVersionTable'
7+
- pwsh: $PSVersionTable
38
displayName: PowerShell version
49

5-
- pwsh: Write-Host "##vso[build.updatebuildnumber]$env:BUILD_SOURCEBRANCHNAME-$env:BUILD_SOURCEVERSION-$((get-date).ToString("yyyyMMddhhmmss"))"
6-
displayName: Set Build Name for Non-PR
7-
condition: ne(variables['Build.Reason'], 'PullRequest')
10+
- checkout: self
811

9-
# TODO: Use a submodule or some such so we can actually track a version here.
10-
- pwsh: |
11-
git clone https://github.com/PowerShell/PowerShellEditorServices.git ../PowerShellEditorServices
12-
Install-Module InvokeBuild -Scope CurrentUser -Force
13-
Install-Module PlatyPS -Scope CurrentUser -Force
14-
New-Item -ItemType Directory $(Build.ArtifactStagingDirectory)/vscode-powershell
12+
# NOTE: We either checkout the Git repo for PowerShellEditorServices, or we
13+
# download a pre-built artifact from the triggering pipeline and extract it to
14+
# the modules folder. In this way we do not accidentally build a release of the
15+
# server from this pipeline.
16+
- checkout: PowerShellEditorServices
17+
condition: not(${{ parameters.usePipelineArtifact }})
1518

16-
# Build
17-
- pwsh: Invoke-Build
19+
- task: DownloadPipelineArtifact@2
20+
condition: ${{ parameters.usePipelineArtifact }}
21+
displayName: Download PowerShellEditorServices
22+
inputs:
23+
source: specific
24+
project: PowerShellEditorServices
25+
pipeline: 36
26+
preferTriggeringPipeline: true
27+
allowPartiallySucceededBuilds: true
28+
artifact: PowerShellEditorServices
1829

19-
- task: PublishTestResults@2
20-
displayName: Publish test results
21-
inputs:
22-
testRunner: JUnit
23-
testResultsFiles: '**/test-results.xml'
24-
condition: succeededOrFailed()
30+
- task: ExtractFiles@1
31+
condition: ${{ parameters.usePipelineArtifact }}
32+
displayName: Extract PowerShellEditorServices module
33+
inputs:
34+
archiveFilePatterns: $(Pipeline.Workspace)/PowerShellEditorServices.zip
35+
destinationFolder: $(Build.SourcesDirectory)/vscode-powershell/modules
36+
37+
- pwsh: |
38+
Install-Module InvokeBuild -Scope CurrentUser -Force
39+
Invoke-Build
40+
Write-Host "##vso[task.setvariable variable=vsixPath]$(Resolve-Path powershell-*.vsix)"
41+
displayName: Build and test
42+
workingDirectory: $(Build.SourcesDirectory)/vscode-powershell
2543

26-
- task: PublishBuildArtifacts@1
27-
inputs:
28-
ArtifactName: vscode-powershell
29-
PathtoPublish: '$(Build.ArtifactStagingDirectory)/vscode-powershell'
44+
- publish: $(vsixPath)
45+
artifact: vscode-powershell-vsix-$(System.JobId)
46+
displayName: Publish extension artifact
3047

48+
- publish: $(Build.SourcesDirectory)/vscode-powershell/scripts/Install-VSCode.ps1
49+
artifact: vscode-powershell-unsigned-script-$(System.JobId)
50+
displayName: Publish unsigned script artifact
51+
52+
- task: PublishTestResults@2
53+
displayName: Publish test results
54+
inputs:
55+
testRunner: JUnit
56+
testResultsFiles: '**/test-results.xml'
57+
condition: succeededOrFailed()

0 commit comments

Comments
 (0)