forked from dotnet/Nerdbank.GitVersioning
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines.yml
376 lines (342 loc) · 14.1 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
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
trigger:
batch: true
branches:
include:
- master
- 'v*.*'
- 'validate/*'
paths:
exclude:
- doc
- '*.md'
- azure-pipelines/release.yml
resources:
containers:
- container: xenial
image: andrewarnott/linux-buildagent
- container: bionic
image: mcr.microsoft.com/dotnet/core/sdk:3.1-bionic
- container: focal
image: mcr.microsoft.com/dotnet/core/sdk:3.1-focal
- container: archlinux
image: andrewarnott/archlinux
variables:
TreatWarningsAsErrors: true
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
BuildConfiguration: Release
BuildPlatform: Any CPU
stages:
- stage: Build
jobs:
- job: Build
strategy:
matrix:
linux:
imageName: 'ubuntu-20.04'
testModifier: -f net5.0
windows:
imageName: 'windows-2019'
testModifier:
dotnet32: "\"C:\\Program Files (x86)\\dotnet\\dotnet.exe\""
variables:
- ${{ if eq(variables['System.TeamFoundationCollectionUri'], 'https://dev.azure.com/andrewarnott/') }}:
- group: dotnetfoundation code signing
pool:
vmImage: $(imageName)
steps:
- checkout: self
clean: true
submodules: true # keep the warnings quiet about the wiki not being enlisted
- script: |
git config --global user.name ci
git config --global user.email [email protected]
displayName: Configure git commit author for testing
- task: UseDotNet@2
displayName: Install .NET Core 5.0.401 SDK
inputs:
packageType: sdk
version: 5.0.401
- task: UseDotNet@2
displayName: Install .NET Core 3.1 runtime
inputs:
packageType: runtime
version: 3.1.x
- pwsh: |
Invoke-WebRequest -Uri "https://dot.net/v1/dotnet-install.ps1" -OutFile dotnet-install.ps1
& .\dotnet-install.ps1 -Architecture x86 -Version 5.0.401 -InstallDir "C:\Program Files (x86)\dotnet\" -NoPath -Verbose
& .\dotnet-install.ps1 -Architecture x86 -Channel 3.1 -InstallDir "C:\Program Files (x86)\dotnet\" -NoPath -Verbose
displayName: Install 32-bit .NET Core SDK 5.0.401, 3.1
condition: ne(variables['dotnet32'], '')
- script: dotnet --info
displayName: Show dotnet SDK info
- pwsh: |
dotnet tool install --tool-path . nbgv
./nbgv cloud -a
displayName: Set build number
- task: DotNetCoreCLI@2
displayName: Restore NuGet packages
inputs:
command: restore
verbosityRestore: normal # detailed, normal, minimal
projects: src/**/*.sln
feedsToUse: config
nugetConfigPath: src/nuget.config
workingDirectory: src
- task: YarnInstaller@3
displayName: 'Use Yarn 1.x'
- task: Yarn@3
displayName: 'Yarn install'
inputs:
projectDirectory: 'src/nerdbank-gitversioning.npm'
- script: dotnet build -c $(BuildConfiguration) --no-restore /t:build,pack /bl:"$(Build.ArtifactStagingDirectory)/build_logs/msbuild.binlog"
displayName: Build NuGet package and tests
workingDirectory: src
- script: dotnet pack -c $(BuildConfiguration) --no-build -p:PackLKG=true /bl:"$(Build.ArtifactStagingDirectory)/build_logs/msbuild_lkg.binlog"
displayName: Build LKG package
workingDirectory: src/Nerdbank.GitVersioning.Tasks
- script: dotnet publish -c $(BuildConfiguration) -o ../nerdbank-gitversioning.npm/out/nbgv.cli/tools/netcoreapp3.1/any /bl:"$(Build.ArtifactStagingDirectory)/build_logs/nbgv_publish.binlog"
displayName: Publish nbgv tool
workingDirectory: src/nbgv
- task: gulp@0
displayName: Build nerdbank-gitversioning NPM package
inputs:
gulpfile: src/nerdbank-gitversioning.npm/gulpfile.js
- script: >
dotnet test NerdBank.GitVersioning.Tests
--no-build $(testModifier)
-c $(BuildConfiguration)
--filter "TestCategory!=FailsOnAzurePipelines"
--logger "trx;LogFileName=$(Build.ArtifactStagingDirectory)/TestLogs/TestResults.x64.trx"
--results-directory $(Build.ArtifactStagingDirectory)/CodeCoverage/
--collect:"XPlat Code Coverage"
--
RunConfiguration.DisableAppDomain=true
displayName: Run x64 tests
workingDirectory: src
- script: >
$(dotnet32) test NerdBank.GitVersioning.Tests
--no-build $(testModifier)
-c $(BuildConfiguration)
--filter "TestCategory!=FailsOnAzurePipelines"
--logger "trx;LogFileName=$(Build.ArtifactStagingDirectory)/TestLogs/TestResults.x86.trx"
--results-directory $(Build.ArtifactStagingDirectory)/CodeCoverage/
--collect:"XPlat Code Coverage"
--
RunConfiguration.DisableAppDomain=true
displayName: Run x86 tests
workingDirectory: src
condition: ne(variables['dotnet32'], '')
- script: >
dotnet test Cake.GitVersioning.Tests
--no-build $(testModifier)
-c $(BuildConfiguration)
--filter "TestCategory!=FailsOnAzurePipelines"
--logger "trx;LogFileName=$(Build.ArtifactStagingDirectory)/TestLogs/TestResults.cake.trx"
--results-directory $(Build.ArtifactStagingDirectory)/CodeCoverage/
--collect:"XPlat Code Coverage"
--
RunConfiguration.DisableAppDomain=true
displayName: Run cake tests
workingDirectory: src
- task: PublishCodeCoverageResults@1
displayName: Publish code coverage results
inputs:
codeCoverageTool: 'cobertura'
summaryFileLocation: $(Build.ArtifactStagingDirectory)/CodeCoverage/**/coverage.cobertura.xml
- task: PublishTestResults@2
displayName: Publish test results
inputs:
testResultsFormat: VSTest
testResultsFiles: '*.trx'
searchFolder: $(Build.ArtifactStagingDirectory)/TestLogs
buildPlatform: $(BuildPlatform)
buildConfiguration: $(BuildConfiguration)
publishRunAttachments: false
condition: always()
- task: CopyFiles@1
inputs:
sourceFolder: $(System.DefaultWorkingDirectory)/bin
Contents: |
**\*.nupkg
!**\*.LKG*
js\*.tgz
TargetFolder: $(Build.ArtifactStagingDirectory)/deployables
flattenFolders: true
displayName: Collecting deployable artifacts
- task: CopyFiles@1
inputs:
sourceFolder: $(System.DefaultWorkingDirectory)/bin
Contents: |
**\*.LKG*.nupkg
TargetFolder: $(Build.ArtifactStagingDirectory)/deployables-lkg
flattenFolders: true
displayName: Collecting LKG artifacts
- pwsh: >
dotnet tool install --tool-path obj SignClient
obj/SignClient sign
--baseDirectory '$(Build.ArtifactStagingDirectory)/deployables'
--input '**/*'
--config '$(System.DefaultWorkingDirectory)/azure-pipelines/SignClient.json'
--filelist '$(System.DefaultWorkingDirectory)/azure-pipelines/signfiles.txt'
--user '$(codesign_username)'
--secret '$(codesign_secret)'
--name 'Nerdbank.GitVersioning'
--descriptionUrl 'https://github.com/dotnet/Nerdbank.GitVersioning'
displayName: Code sign
condition: and(succeeded(), eq(variables['System.TeamFoundationCollectionUri'], 'https://dev.azure.com/andrewarnott/'), eq(variables['Agent.OS'], 'Windows_NT'), ne(variables['Build.Reason'], 'PullRequest'))
- pwsh: >
obj/SignClient sign
--baseDirectory '$(Build.ArtifactStagingDirectory)/deployables-lkg'
--input '**/*'
--config '$(System.DefaultWorkingDirectory)/azure-pipelines/SignClient.json'
--filelist '$(System.DefaultWorkingDirectory)/azure-pipelines/signfiles.txt'
--user '$(codesign_username)'
--secret '$(codesign_secret)'
--name 'Nerdbank.GitVersioning'
--descriptionUrl 'https://github.com/dotnet/Nerdbank.GitVersioning'
displayName: Code sign LKG
condition: and(succeeded(), eq(variables['System.TeamFoundationCollectionUri'], 'https://dev.azure.com/andrewarnott/'), eq(variables['Agent.OS'], 'Windows_NT'), ne(variables['Build.Reason'], 'PullRequest'))
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: $(Build.ArtifactStagingDirectory)/deployables
ArtifactName: deployables
ArtifactType: Container
displayName: Publish deployables artifacts
# Only deploy when from a single build in the build matrix
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: $(Build.ArtifactStagingDirectory)/deployables-lkg
ArtifactName: deployables-lkg
ArtifactType: Container
displayName: Publish deployables-lkg artifact
# Only deploy when from a single build in the build matrix
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: $(Build.ArtifactStagingDirectory)/build_logs
ArtifactName: build_logs
ArtifactType: Container
displayName: Publish build_logs artifacts
condition: succeededOrFailed()
- task: NuGetCommand@2
displayName: Pushing package to PublicCI feed
inputs:
command: push
packagesToPush: $(Build.ArtifactStagingDirectory)/deployables/*.*nupkg
nuGetFeedType: internal
publishVstsFeed: OSS/PublicCI
allowPackageConflicts: true
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'), eq(variables['System.TeamFoundationCollectionUri'], 'https://dev.azure.com/andrewarnott/'), ne(variables['Build.Reason'], 'PullRequest'))
- pwsh: Set-Content -Path "$(Agent.TempDirectory)/.npmrc" -Value "registry=https://pkgs.dev.azure.com/andrewarnott/OSS/_packaging/PublicCI/npm/registry/`nalways-auth=true"
displayName: Prepare to push to PublicCI
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'), eq(variables['System.TeamFoundationCollectionUri'], 'https://dev.azure.com/andrewarnott/'), ne(variables['Build.Reason'], 'PullRequest'))
- task: npmAuthenticate@0
displayName: Authenticate to PublicCI
inputs:
workingFile: $(Agent.TempDirectory)/.npmrc
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'), eq(variables['System.TeamFoundationCollectionUri'], 'https://dev.azure.com/andrewarnott/'), ne(variables['Build.Reason'], 'PullRequest'))
- pwsh: |
$tgz = (Get-ChildItem "$(Build.ArtifactStagingDirectory)/deployables/*.tgz")[0].FullName
Write-Host "Will publish $tgz"
npm publish $tgz
workingDirectory: $(Agent.TempDirectory)
displayName: npm publish to PublicCI feed
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'), eq(variables['System.TeamFoundationCollectionUri'], 'https://dev.azure.com/andrewarnott/'), ne(variables['Build.Reason'], 'PullRequest'))
continueOnError: true
- stage: Test
displayName: Functional testing
jobs:
- job: linux
strategy:
matrix:
# xenial:
# containerImage: xenial
# configureContainerCommand: 'sudo apt update && sudo apt-get install -y git'
Ubuntu_Bionic:
containerImage: bionic
Ubuntu_Focal:
containerImage: focal
# Arch_Linux:
# containerImage: archlinux
# configureContainerCommand: 'sudo pacman -Sy --noconfirm git dotnet-sdk openssl-1.0'
pool:
vmImage: ubuntu-20.04
container: $[ variables['containerImage'] ]
steps:
- bash: $(configureContainerCommand)
displayName: Configure container
condition: ne(variables['configureContainerCommand'], '')
- template: azure-pipelines/xplattest-pipeline.yml
- job: macOS
pool:
vmImage: macOS-10.15
steps:
- template: azure-pipelines/xplattest-pipeline.yml
- stage: PerfAnalysis
displayName: Perf analysis
dependsOn: []
jobs:
- job: PerfTest
strategy:
matrix:
ubuntu:
imageName: ubuntu-18.04
repoDir: '~/git'
windows:
imageName: windows-2019
repoDir: '${USERPROFILE}/source/repos'
macOS:
imageName: macOS-10.15
repoDir: '~/git'
pool:
vmImage: $(imageName)
steps:
- task: UseDotNet@2
displayName: Install .NET Core 3.1 runtime
inputs:
packageType: runtime
version: 3.1.x
- task: UseDotNet@2
displayName: Install .NET Core 5.0.401 SDK
inputs:
packageType: sdk
version: 5.0.401
- script: dotnet --info
displayName: Show dotnet SDK info
- bash: |
mkdir -p $(repoDir)
git clone https://github.com/xunit/xunit $(repoDir)/xunit
git clone https://github.com/gimlichael/Cuemon $(repoDir)/Cuemon
git clone https://github.com/kerryjiang/SuperSocket $(repoDir)/SuperSocket
git clone https://github.com/dotnet/NerdBank.GitVersioning $(repoDir)/NerdBank.GitVersioning
displayName: Clone test repositories
- script: |
dotnet build -c Release
workingDirectory: src/
displayName: Build in Release mode
- script: |
dotnet run -c Release -f netcoreapp3.1 -- --filter GetVersionBenchmarks --artifacts $(Build.ArtifactStagingDirectory)/benchmarks/packed/$(imageName)
workingDirectory: src/NerdBank.GitVersioning.Benchmarks
displayName: Run benchmarks (packed)
- bash: |
cd $(repoDir)/xunit
git unpack-objects < .git/objects/pack/*.pack
cd $(repoDir)/Cuemon
git unpack-objects < .git/objects/pack/*.pack
cd $(repoDir)/SuperSocket
git unpack-objects < .git/objects/pack/*.pack
cd $(repoDir)/NerdBank.GitVersioning
git unpack-objects < .git/objects/pack/*.pack
displayName: Unpack Git repositories
- script: |
dotnet run -c Release -f netcoreapp3.1 -- --filter GetVersionBenchmarks --artifacts $(Build.ArtifactStagingDirectory)/benchmarks/unpacked/$(imageName)
workingDirectory: src/NerdBank.GitVersioning.Benchmarks
displayName: Run benchmarks (unpacked)
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: $(Build.ArtifactStagingDirectory)/benchmarks
ArtifactName: benchmarks
ArtifactType: Container
displayName: Publish benchmarks artifacts
condition: succeededOrFailed()