-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathazure-pipelines.yml
237 lines (210 loc) · 7.02 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
trigger:
branches:
include:
- v13/main
- v13/develop
- v13/release/*
- v13/hotfix
tags:
include:
- 13.*
pool:
name: Default
parameters:
- name: deployWebsite
displayName: Deploy website to testing environment
type: boolean
default: false
variables:
- group: nuget-package
- group: test-server
- name: BuildConfiguration
value: 'release'
- name: BuildPlatform
value: 'any cpu'
- name: Solution
value: '**\*.sln'
- name: NpmWorkingDirectory
value: 'src\UrlTracker.Backoffice.UI'
- name: PackageDownloadPatterns
value: |
**/*.nupkg
**/*.snupkg
stages:
- stage: build
displayName: Build
jobs:
- job: build
displayName: Build
steps:
- checkout: self
displayName: Clone repository
fetchDepth: 0
clean: true
- task: GitVersion@5
displayName: GitVersion
inputs:
configFilePath: GitVersion.yml
updateAssemblyInfo: true
- task: NodeTool@0
displayName: 'Use node 20.x'
inputs:
versionSpec: '20.x'
- task: Npm@1
displayName: 'Install front end packages'
inputs:
command: 'custom'
workingDir: $(NpmWorkingDirectory)
customCommand: 'ci --prefer-offline --no-audit'
- task: Npm@1
displayName: 'Build front end'
inputs:
command: 'custom'
workingDir: $(NpmWorkingDirectory)
customCommand: 'run build'
- task: UseDotNet@2
displayName: 'Use .NET 8'
inputs:
packageType: 'sdk'
version: '8.x'
includePreviewVersions: false
- task: DotNetCoreCLI@2
displayName: 'Build solution'
inputs:
command: 'build'
projects: 'UrlTracker.sln'
arguments: '--configuration $(BuildConfiguration) -p:Version=$(GitVersion.NuGetVersion)'
- task: DotNetCoreCLI@2
displayName: 'Run tests'
inputs:
command: 'test'
projects: |
test/UrlTracker.Core.Caching.Memory.Tests/UrlTracker.Core.Caching.Memory.Tests.csproj
test/UrlTracker.Core.Tests/UrlTracker.Core.Tests.csproj
test/UrlTracker.IntegrationTests/UrlTracker.IntegrationTests.csproj
test/UrlTracker.Middleware.Tests/UrlTracker.Middleware.Tests.csproj
test/UrlTracker.Web.Tests/UrlTracker.Web.Tests.csproj
arguments: '--configuration $(BuildConfiguration) -p:Version=$(GitVersion.NuGetVersion) --collect "XPlat Code Coverage" --no-build'
# - task: PublishCodeCoverageResults@2
# displayName: 'Publish code coverage results'
# inputs:
# summaryFileLocation: $(Agent.WorkFolder)/**/coverage.cobertura.xml
# failIfCoverageEmpty: true
# - script: |
# dotnet tool install -g dotnet-reportgenerator-globaltool
# reportgenerator -reports:$(Agent.WorkFolder)/**/coverage.cobertura.xml -targetdir:$(Build.SourcesDirectory)/CodeCoverage -reporttypes:Cobertura -assemblyfilters:+UrlTracker.*;-UrlTracker.Resources.*;-UrlTracker.*.Tests
# displayName: Create code coverage report
# - task: PublishCodeCoverageResults@1
# displayName: 'Publish code coverage report'
# inputs:
# codeCoverageTool: 'Cobertura'
# summaryFileLocation: '$(Build.SourcesDirectory)/CodeCoverage/Cobertura.xml'
# reportDirectory: '$(Build.SourcesDirectory)/CodeCoverage'
- task: DotNetCoreCLI@2
displayName: 'dotnet pack'
inputs:
command: pack
packagesToPack: src/**/*.csproj
configurationToPack: $(BuildConfiguration)
nobuild: true
versioningScheme: byEnvVar
versionEnvVar: GitVersion.NuGetVersion
verbosityPack: Normal
packDirectory: '$(Build.ArtifactStagingDirectory)/packages'
- task: PublishBuildArtifacts@1
displayName: 'Publish package artifacts'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)/packages'
ArtifactName: 'drop'
publishLocation: 'Container'
- ${{ if eq(parameters.deployWebsite, true) }}:
- task: DotNetCoreCLI@2
displayName: 'Create website deployment package'
inputs:
command: publish
publishWebProjects: false
projects: test/**/UrlTracker.Resources.Website.csproj
arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)/website -p:Version=$(GitVersion.NuGetVersion) --no-build'
- task: PublishBuildArtifacts@1
displayName: 'Publish website artifacts'
inputs:
PathtoPublish: '$(build.artifactstagingdirectory)/website'
ArtifactName: 'drop-website'
publishLocation: 'Container'
- stage: dryrun
displayName: Dry run
dependsOn: build
condition: and(succeeded(), not(startsWith(variables['Build.SourceBranch'], 'refs/tags/')))
jobs:
- job: download
displayName: Test download
workspace:
clean: all
steps:
- checkout: none
- download: current
artifact: 'drop'
patterns: $(PackageDownloadPatterns)
displayName: Download packages and symbols
- stage: release
displayName: Release
dependsOn: build
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/tags/'))
variables:
packageGlob: '$(Pipeline.Workspace)/**/UrlTracker*.nupkg'
symbolsGlob: '$(Pipeline.Workspace)/**/UrlTracker*.snupkg'
jobs:
- job: releaseArtifact
displayName: Push to artifacts
workspace:
clean: all
steps:
- checkout: none
- download: current
artifact: 'drop'
patterns: $(PackageDownloadPatterns)
displayName: Download build artifact
- task: DotNetCoreCLI@2
displayName: 'Push package to artifacts'
inputs:
command: push
publishVstsFeed: '3356baca-d7d8-497c-a5fa-ebd93f79f7c7'
versioningScheme: byBuildNumber
packagesToPush: $(packageGlob)
- task: DotNetCoreCLI@2
displayName: 'Push symbols to artifacts'
inputs:
command: push
publishVstsFeed: '3356baca-d7d8-497c-a5fa-ebd93f79f7c7'
versioningScheme: byBuildNumber
packagesToPush: $(symbolsGlob)
- job: releaseNuget
displayName: Push to nuget
workspace:
clean: all
steps:
- checkout: none
- download: current
patterns: $(PackageDownloadPatterns)
displayName: Download build artifact
- task: DotNetCoreCLI@2
displayName: 'push package to nuget.org'
inputs:
command: custom
custom: nuget
arguments: 'push $(packageGlob) -s https://api.nuget.org/v3/index.json --api-key $(NuGetApiKey)'
- ${{ if eq(parameters.deployWebsite, true) }}:
- stage: testing
displayName: Deploy to testing
dependsOn: build
condition: succeeded()
jobs:
- template: 'azure-pipelines-deploy-iis.yml'
parameters:
websiteName: 'urltracker13'
dropFolder: '$(pipeline.workspace)/drop-website/UrlTracker.Resources.Website.zip'
environment: 'Testing'
stageName: 'Testing'
deploymentPath: $(TestPhysicalPath)
dropName: 'drop-website'
variableGroup: 'urltracker-testing-13'