-
Notifications
You must be signed in to change notification settings - Fork 44
/
azure-pipelines.yml
325 lines (292 loc) · 13 KB
/
azure-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
trigger:
- master
name: 'ODataCodeGenTools'
pool:
vmImage: 'windows-latest'
variables:
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
connectedServiceDir: '$(Build.SourcesDirectory)'
sln: '$(connectedServiceDir)\ODataCodeGenTools.sln'
signigConfigPath: '$(connectedServiceDir)\configs'
signingConfigFiles: '*.*'
productBinPath: '$(connectedServiceDir)\src\ODataConnectedService\bin\$(BuildConfiguration)'
productFiles: 'Microsoft.OData.ConnectedService.*?(*.dll|*.config|*.pdb)'
productBinPathVs2022Plus: '$(connectedServiceDir)\src\ODataConnectedService_VS2022Plus\bin\$(BuildConfiguration)'
productFilesVs2022Plus: 'Microsoft.OData.ConnectedService.VS2022Plus.*?(*.dll|*.config|*.pdb)'
productFilesODataCLI: 'Microsoft.OData.Cli.*?(*.dll|*.config|*.pdb)'
testBinPath: '$(connectedServiceDir)\test\ODataConnectedService.Tests\bin\$(BuildConfiguration)'
testBinPathODataCLI: '$(connectedServiceDir)\test\Microsoft.OData.Cli.Tests\bin\$(BuildConfiguration)'
vsixPath: '$(productBinPath)'
vsixFile: 'Microsoft.OData.ConnectedService.vsix'
vsixFileVs2022Plus: 'Microsoft.OData.ConnectedService.VS2022Plus.vsix'
nupkgFile: 'Microsoft.OData.Cli.nupkg'
signingFiles: 'Microsoft.OData.ConnectedService.dll'
signingFilesVs2022Plus: 'Microsoft.OData.ConnectedService.VS2022Plus.dll'
signingFilesODataCLI: 'Microsoft.OData.Cli.dll'
mainDll: 'Microsoft.OData.ConnectedService.dll'
mainDllVs2022Plus: 'Microsoft.OData.ConnectedService.VS2022Plus.dll'
mainDllODataCLI: 'Microsoft.OData.Cli.dll'
testDll: 'ODataConnectedService.Tests.dll'
testDllODataCLI: 'Microsoft.OData.Cli.Tests.dll'
snExe: 'C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\sn.exe'
snExe64: 'C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64\sn.exe'
stages:
- stage: Build
jobs:
- job: Build
steps:
- task: NuGetToolInstaller@0
inputs:
versionSpec: '>=5.2.0'
- task: NuGetCommand@2
displayName: 'Nuget restore - ODataCodeGenTools.sln'
inputs:
restoreSolution: '$(sln)'
- task: VSBuild@1
displayName: 'Build solution - ODataCodeGenTools.sln'
inputs:
solution: '$(sln)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: 'Pack Microsoft.OData.Cli package'
inputs:
command: pack
packagesToPack: src/Microsoft.OData.Cli/Microsoft.OData.Cli.csproj
outputDir: '$(Build.ArtifactStagingDirectory)\ODataCLINupkg'
nobuild: true
- task: VSTest@2
displayName: 'Unit Tests (ODataConnectedService.Tests)'
inputs:
testSelector: 'testAssemblies'
testAssemblyVer2: '$(testBinPath)\$(testDll)'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
searchFolder: '$(System.DefaultWorkingDirectory)'
resultsFolder: '$(Agent.TempDirectory)\TestResults'
otherConsoleOptions: '/collect:"Code Coverage;Format=Cobertura"'
runSettingsFile: '$(Build.SourcesDirectory)\test.runsettings'
#codeCoverageEnabled: true
- task: DotNetCoreCLI@2
displayName: Unit Tests (Microsoft.OData.Cli.Tests)
inputs:
command: test
publishTestResults: false
projects: $(connectedServiceDir)\test\Microsoft.OData.Cli.Tests\Microsoft.OData.Cli.Tests.csproj
arguments: '--configuration $(buildConfiguration) --settings $(Build.SourcesDirectory)\test.runsettings --no-build --collect "Code Coverage;Format=Cobertura" --logger trx --results-directory $(Agent.TempDirectory)\TestResults'
- task: CmdLine@2
displayName: Install ReportGenerator tool for code coverage
inputs:
script: dotnet tool install --global dotnet-reportgenerator-globaltool --version 4.5.8
- task: CmdLine@2
displayName: Create code coverage report
inputs:
script: reportgenerator -reports:$(Agent.TempDirectory)/TestResults/**/*.cobertura.xml -targetdir:$(Build.SourcesDirectory) -reporttypes:"Cobertura"
# PublishCodeCoverageResults@2 doesn't support line and branch based coverage - https://stackoverflow.com/a/78276341/752739
- task: PublishCodeCoverageResults@1
displayName: Publish code coverage
inputs:
codeCoverageTool: Cobertura
summaryFileLocation: $(Build.SourcesDirectory)/Cobertura.xml
- task: CopyFiles@2
displayName: 'Copy Files - VSIX to Artifacts Staging'
inputs:
SourceFolder: '$(productBinPath)'
Contents: 'Microsoft.OData.ConnectedService.vsix'
TargetFolder: '$(Build.ArtifactStagingDirectory)\VSIX'
OverWrite: true
- task: CopyFiles@2
displayName: 'Copy Files - 2022plus VSIX to Artifacts Staging'
inputs:
SourceFolder: '$(productBinPathVs2022Plus)'
Contents: 'Microsoft.OData.ConnectedService.VS2022Plus.vsix'
TargetFolder: '$(Build.ArtifactStagingDirectory)\VSIX2022plus'
OverWrite: true
- task: CopyFiles@2
displayName: 'Copy Files - Stage Product'
inputs:
SourceFolder: '$(productBinPath)'
Contents: '$(productFiles)'
TargetFolder: '$(Build.ArtifactStagingDirectory)\Product'
OverWrite: true
- task: CopyFiles@2
displayName: 'Copy Files - Stage Product 2022plus'
inputs:
SourceFolder: '$(productBinPathVs2022Plus)'
Contents: '$(productFilesVs2022Plus)'
TargetFolder: '$(Build.ArtifactStagingDirectory)\Product2022plus'
OverWrite: true
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact - VSIX'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)\VSIX'
ArtifactName: 'VSIX'
publishLocation: 'Container'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact - VSIX2022Plus'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)\VSIX2022Plus'
ArtifactName: 'VSIX2022Plus'
publishLocation: 'Container'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact - ODataCLINupkg'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)\ODataCLINupkg'
ArtifactName: 'ODataCLINupkg'
publishLocation: 'Container'
- publish: configs
displayName: Publish Signing Scripts
artifact: configs
- stage: CodeSign
condition: and(succeeded('Build'), not(eq(variables['build.reason'], 'PullRequest')))
jobs:
- deployment: CodeSign
displayName: Code Signing
pool:
vmImage: windows-latest
environment: Code Sign - Approvals
variables:
- group: Code Signing
strategy:
runOnce:
deploy:
steps:
- task: DotNetCoreCLI@2
inputs:
command: custom
custom: tool
arguments: install --tool-path . --prerelease sign
displayName: Install SignTool tool
# Sign the VSIX archive as well as files contained in the VSIX that are listed in config/filelist.txt
# For more info about the Sign CLI tool, visit: https://github.com/dotnet/sign
- task: AzureCLI@2
inputs:
azureSubscription: 'Code Signing'
scriptType: pscore
scriptLocation: inlineScript
inlineScript: |
.\sign code azure-key-vault `
"**/*.{dll,vsix,zip,nupkg}" `
--base-directory "$(Pipeline.Workspace)/VSIX" `
--output "$(Build.ArtifactStagingDirectory)/SignedVSIX" `
--file-list "$(Pipeline.Workspace)/configs/filelist.txt" `
--publisher-name "OData Labs" `
--description "OData Connected Service" `
--description-url "https://github.com/OData/ODataConnectedService" `
--azure-key-vault-managed-identity `
--azure-key-vault-certificate "$(SignKeyVaultCertificate)" `
--azure-key-vault-url "$(SignKeyVaultUrl)"
displayName: Code signing - VSIX
# Publish the signed VSIX as an artifact so we can download it after the build
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: SignedVSIX'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/SignedVSIX'
ArtifactName: 'SignedVSIX'
publishLocation: 'Container'
- stage: CodeSign2
condition: and(succeeded('Build'), not(eq(variables['build.reason'], 'PullRequest')))
jobs:
- deployment: CodeSign
displayName: Code Signing
pool:
vmImage: windows-latest
environment: Code Sign - Approvals
variables:
- group: Code Signing
strategy:
runOnce:
deploy:
steps:
- task: DotNetCoreCLI@2
inputs:
command: custom
custom: tool
arguments: install --tool-path . --prerelease sign
displayName: Install SignTool tool
# Sign the VSIX archive as well as files contained in the VSIX that are listed in config/filelist.txt
# For more info about the SignClient tool, visit: https://github.com/dotnet/sign
- task: AzureCLI@2
inputs:
azureSubscription: 'Code Signing'
scriptType: pscore
scriptLocation: inlineScript
inlineScript: |
.\sign code azure-key-vault `
"**/*.{dll,vsix,zip,nupkg}" `
--base-directory "$(Pipeline.Workspace)/VSIX2022Plus" `
--output "$(Build.ArtifactStagingDirectory)/SignedVSIX2022Plus" `
--file-list "$(Pipeline.Workspace)/configs/filelist.txt" `
--publisher-name "OData Labs" `
--description "OData Connected Service 2022+" `
--description-url "https://github.com/OData/ODataConnectedService" `
--azure-key-vault-managed-identity `
--azure-key-vault-certificate "$(SignKeyVaultCertificate)" `
--azure-key-vault-url "$(SignKeyVaultUrl)"
displayName: Code signing - VSIX2022Plus
# Publish the signed VSIX as an artifact so we can download it after the build
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: SignedVSIX2022Plus'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/SignedVSIX2022Plus'
ArtifactName: 'SignedVSIX2022Plus'
publishLocation: 'Container'
- stage: CodeSignODataCLI
condition: and(succeeded('Build'), not(eq(variables['build.reason'], 'PullRequest')))
jobs:
- deployment: CodeSign
displayName: Code Signing
pool:
vmImage: windows-latest
environment: Code Sign - Approvals
variables:
- group: Code Signing
strategy:
runOnce:
deploy:
steps:
- task: DownloadPipelineArtifact@2
inputs:
artifact: 'ODataCLINupkg'
path: $(Build.ArtifactStagingDirectory)/ODataCLINupkg
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
$nupFile = Get-ChildItem -Path "$(Build.ArtifactStagingDirectory)/ODataCLINupkg" -Filter *.nupkg | Select-Object -First 1 -ExpandProperty Name
Write-Host "Updated nupkgFile value: $nupFile"
Write-Host "##vso[task.setvariable variable=nupkgFile]$nupFile"
- task: DotNetCoreCLI@2
inputs:
command: custom
custom: tool
arguments: install --tool-path . --prerelease sign
displayName: Install SignTool tool
# Sign the CLI
# For more info about the Sign CLI tool, visit: https://github.com/dotnet/sign
- task: AzureCLI@2
inputs:
azureSubscription: 'Code Signing'
scriptType: pscore
scriptLocation: inlineScript
inlineScript: |
.\sign code azure-key-vault `
"**/*.{{dll,exe,zip,nupkg}}" `
--base-directory "$(Pipeline.Workspace)\ODataCLINupkg" `
--output "$(Build.ArtifactStagingDirectory)\SignedODataCLINupkg" `
--file-list "$(Pipeline.Workspace)\configs\filelist.txt" `
--publisher-name "OData Labs" `
--description "OData CLI" `
--description-url "https://github.com/OData/ODataConnectedService" `
--azure-key-vault-managed-identity `
--azure-key-vault-certificate "$(SignKeyVaultCertificate)" `
--azure-key-vault-url "$(SignKeyVaultUrl)"
displayName: Code signing - ODataCLINupkg
# Publish the signed CLI as an artifact so we can download it after the build
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact - Nuget Packages'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)\SignedODataCLINupkg'
ArtifactName: SignedODataCLINupkg
publishLocation: 'Container'