-
Notifications
You must be signed in to change notification settings - Fork 2
/
azure-pipelines.sds.pr-release.yml
310 lines (287 loc) · 13.5 KB
/
azure-pipelines.sds.pr-release.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
name: $(Date:yyyyMMddHHmm)-$(Rev:r)
resources:
repositories:
- repository: azTemplates
type: github
name: hmcts/azure-devops-templates
ref: master
endpoint: hmcts
trigger: none
pr:
- master
pool:
vmImage: ubuntu-22.04
stages:
####################################################
# CI Build Checks. #################################
- stage: CI_Build
displayName: CI Build
variables:
- template: variables/shared.yaml
jobs:
- job: CI_Helm
displayName: "Helm CI"
steps:
- checkout: self
- template: templates\Containerisation\helm\helm-lint.yaml@azTemplates
parameters:
chartPath: ${{ variables.chartPath }}
chartValuesPath: ${{ variables.chartPath }}
helmVersion: "3.12.3"
- job: UnitAndIntegrationTests
displayName: "Unit and Integration Tests"
steps:
- checkout: self
- template: templates/dotnet/build-test-analyse.yml@azTemplates
parameters:
dotnetVersion: ${{ variables.dotnetVersion }}
nugetConfigPath: nuget.config
appName: ${{ variables.appName }}
dockerComposeTestFile: docker-compose.tests.yml
sonarExtraProperties: |
sonar.cs.opencover.reportsPaths=$(System.DefaultWorkingDirectory)/coverage.opencover.xml
sonar.cpd.exclusions=**/NotificationType.cs,**/TemplateDataForEnvironments.cs,*/Validations/*.cs,**/Services/NotificationParameterMapper.cs
sonar.exclusions=**/Program.cs, **/Startup.cs, **/Testing.Common/**/*, **/NotificationApi/Swagger/**/*, **/NotificationApi.DAL/Migrations/**, **/NotificationApi.DAL/TemplateDataForEnvironments.cs
sonar.coverage.exclusions=**/NotificationApi/Swagger/**/*, **/Program.cs, **/Startup.cs, **/Testing.Common/**/*, **/NotificationApi.Common/**/*, **/NotificationApi.IntegrationTests/**/*, **/NotificationApi.UnitTests/**/*, **/NotificationApi/Extensions/*, **/NotificationApi.DAL/Migrations/**/*
####################################################
# Pre Release Tasks. ###############################
- stage: Pre_Release_Tasks
displayName: Pre-Release Tasks
variables:
- template: variables/shared.yaml
jobs:
- job: Generate_Entity_Framework_Script
displayName: "Generate Entity Framework Script"
steps:
- template: templates/Database/EntityFramework/generate-script.yaml@azTemplates
parameters:
efVersion: ${{ variables.efDotnetToolVersion }}
outputPath: $(Build.StagingDirectory)
contextName: ${{ variables.efContextName }}
workingPath: $(System.DefaultWorkingDirectory)/${{ variables.appName }}/${{ variables.appName }}
migrationsPath: ${{ variables.appName }}/${{ variables.appName }}.DAL/Migrations
projectName: ${{ variables.efProjectName }}
- job: package_nuget
displayName: "Package NuGet Packages"
steps:
- template: templates\dotnet\package-nuget-packages.yml@azTemplates
parameters:
nugetProjectPath: "${{ variables.appName }}/${{ variables.nuget_package_name }}"
vstsFeed: "${{ variables.nuget_org_name }}/${{ variables.nuget_feed_name }}"
gitVersionConfigPath: ${{ variables.git_version_config_path }}
- job: PublishAcceptanceTests
dependsOn: package_nuget
displayName: Publish Acceptance Tests
variables:
projectPath: "${{ variables.appName }}/${{ variables.appName }}"
steps:
- template: templates\dotnet\publish-acceptance-tests.yml@azTemplates
parameters:
netVersion: ${{ variables.dotnetVersion }}
vstsFeedId: "${{ variables.nuget_org_name }}/${{ variables.nuget_feed_name }}"
coreProjectPath: $(projectPath)
#####################################################
# Build Docker Image & Generate EF Script. ##########
- stage: Dock
displayName: Docker Build & Push Image
variables:
- group: aks-cluster-info
- template: variables/dev.yaml
- template: variables/shared.yaml
parameters:
env: ${{ variables.env }}
- group: vh-github-app-credentials
jobs:
- job: Dock
displayName: "Build and Push Image ${{ variables.git_repo_name }}"
steps:
- checkout: self
- template: templates\Github\get-app-token.yaml@azTemplates
parameters:
privateKeyFileName: ${{ variables.gh_app_private_key_file_name }}
appId: $(gh_app_app_id)
- template: templates\Github\bump-chart-versions.yaml@azTemplates
parameters:
chartName: ${{ variables.chartName }}
chartPath: $(Build.SourcesDirectory)
chartBranch: $(System.PullRequest.SourceBranch)
githubToken: $(githubappinstall.token)
githubUsername: $(gh_app_name)
githubEmail: "$(gh_app_app_id)+$(gh_app_name)[bot]@users.noreply.github.com"
- bash: |
sed -i "s|</configuration>|<packageSourceCredentials><vh-packages><add key=\"Username\" value=\"PAT\" /><add key=\"ClearTextPassword\" value=\"$(System.AccessToken)\" /></vh-packages></packageSourceCredentials></configuration>|" nuget.config
displayName: Add NuGet Feed Authentication
workingDirectory: ${{ variables.appName }}
- template: templates\Containerisation\docker\docker-compose.yaml@azTemplates
parameters:
azureSubscription: ${{ variables.acrSubscription }}
acrName: ${{ variables.acrName }}
repositoryName: ${{ variables.repositoryName }}
- template: templates\Containerisation\docker\docker-push-azure.yaml@azTemplates
parameters:
azureSubscription: ${{ variables.acrSubscription }}
acrName: ${{ variables.acrName }}
repositoryName: ${{ variables.repositoryName }}
imageName: "${{ replace(variables.git_repo_name, '-', '') }}"
imageTags:
- "${{ variables.prTagName }}"
##################################################
# Deploy Nuget Packages. #########################
- stage: Push_Nuget
dependsOn: Pre_Release_Tasks
displayName: Deploy NuGet Packages
variables:
- template: variables/dev.yaml
- template: variables/shared.yaml
parameters:
env: ${{ variables.env }}
jobs:
- job: Publish_Nuget
displayName: Publish NuGet Packages
steps:
- template: templates\dotnet\push-nuget-packages.yml@azTemplates
parameters:
vstsFeed: "${{ variables.nuget_org_name }}/${{ variables.nuget_feed_name }}"
#####################################################
# Run Entity Framework Dev. #########################
- stage: Run_Entity_Framework_Dev
displayName: Run Entity Framework Dev
dependsOn: Dock
variables:
- template: variables/dev.yaml
- template: variables/shared.yaml
parameters:
env: ${{ variables.env }}
jobs:
- job: Run_Entity_Framework_Dev
pool:
vmImage: "windows-latest" # This Job Must be Run on Windows
displayName: Run Entity Framework Dev
steps:
- download: current
displayName: Download Sql Artifact
- template: templates/Database/EntityFramework/run-entity-framework.yaml@azTemplates
parameters:
sqlServerResourceGroup: ${{ variables.vhResourceGroup }}
sqlServerName: ${{ variables.vhSQLServerName }}
databaseName: ${{ variables.NotificationApiDbName }}
azureSubscription: ${{ variables.subscriptionName }}
sqlScriptLocation: "$(Pipeline.Workspace)/${{ variables.efContextName }}-$(Build.BuildId)/${{ variables.efContextName }}.sql"
kvfirewallRequired: false
kvName: ${{ variables.vhKeyVault }}
kvSqlPasswordSecret: ${{ variables.vhSqlPasswordSecret }}
kvSqlUsernameSecret: ${{ variables.vhSqlUsernameSecret }}
#####################################################
# Deploy Helm Chart to Dev. #########################
- stage: Install
dependsOn: Run_Entity_Framework_Dev
displayName: Deploy Helm Chart Dev AKS
variables:
- group: vh-github-app-credentials
- template: variables/dev.yaml
- template: variables/shared.yaml
parameters:
env: ${{ variables.env }}
- name: dnsRecordName
value: vh-${{ variables.git_repo_name }}-${{ variables.prTagPrefix }}
jobs:
- job: helm_uninstall
displayName: Uninstall Helm from Dev
steps:
- template: templates\Azure\Aks\get-active-cluster.yaml@azTemplates
parameters:
subscriptionName: "${{ variables.subscriptionName }}"
environment: ${{ variables.env }}
- template: templates/Containerisation/helm/helm-uninstall.yaml@azTemplates
parameters:
namespace: "vh"
releaseName: "${{ variables.chartName }}-${{ variables.prTagPrefix }}"
azureSubscription: "${{ variables.subscriptionName }}"
aksResourceGroupName: "$(aksCluster.resourceGroup)"
aksClusterName: "$(aksCluster.name)"
- job: aks_push
displayName: Deploy To Dev AKS
dependsOn: helm_uninstall
steps:
- template: templates\Azure\Aks\get-active-cluster.yaml@azTemplates
parameters:
subscriptionName: "${{ variables.subscriptionName }}"
environment: ${{ variables.env }}
- template: templates/Containerisation/helm/helm-install.yaml@azTemplates
parameters:
privateKeyFileName: ${{ variables.gh_app_private_key_file_name }}
appId: $(gh_app_app_id)
envValuesTemplatePath: ${{ variables.envValuesTemplatePath }}
envValuesPath: ${{ variables.envValuesPath }}
acrName: ${{ variables.acrName }}
repositoryName: ${{ variables.repositoryName }}
prTagName: ${{ variables.prTagName }}
releaseName: "${{ variables.chartName }}-${{ variables.prTagPrefix }}"
dnsRecordName: ${{ variables.dnsRecordName }}
dnsZone: ${{ variables.dnsZone }}
env: ${{ variables.env }}
chartName: ${{ variables.chartName }}
chartPath: ${{ variables.chartPath }}
subscriptionName: "${{ variables.subscriptionName }}"
aksResourceGroupName: "$(aksCluster.resourceGroup)"
aksClusterName: "$(aksCluster.name)"
dnsSubscriptionName: "${{ variables.dnsZoneSubscription }}"
dnsResourceGroupName: "${{ variables.dnsZoneResourceGroup }}"
##################################################
# Run Acceptance Tests. ##########################
- stage: Acceptance_Tests_Dev
dependsOn: Install
displayName: Acceptance Tests Dev
variables:
- group: govuk-notify-dev
- group: vh-notification-api
- template: variables/dev.yaml
- template: variables/shared.yaml
parameters:
env: ${{ variables.env }}
- name: dnsRecordName
value: vh-${{ variables.git_repo_name }}-${{ variables.prTagPrefix }}
jobs:
- job: AcceptanceTestsDev
pool: VH Self Hosted
displayName: Acceptance Tests Dev
steps:
- template: templates/dotnet/run-acceptance-tests.yml@azTemplates
parameters:
netVersion: ${{ variables.dotnetVersion }}
environment: ${{ variables.env }}
azureSubscription: ${{ variables.subscriptionName }}
acceptanceTestSettings:
- name: ConnectionStrings:VhNotificationsApi
value: connectionstrings--vhnotificationsapi
keyVaultName: vh-infra-core-${{ variables.env }}
secret: true
- name: Services:NotificationApiUrl
value: "https://vh-notification-api-pr-$(System.PullRequest.PullRequestNumber).dev.platform.hmcts.net"
- name: Services:VhNotificationApiResourceId
value: azuread--identifieruri
keyVaultName: vh-notification-api-${{ variables.env }}
secret: true
- name: ApplicationInsights:ConnectionString
value: connectionstrings--applicationinsights
keyVaultName: vh-infra-core-${{ variables.env }}
secret: true
- name: AzureAd:ClientId
value: azuread--clientid
keyVaultName: vh-notification-api-${{ variables.env }}
secret: true
- name: AzureAd:ClientSecret
value: azuread--clientsecret
keyVaultName: vh-notification-api-${{ variables.env }}
secret: true
- name: AzureAd:TenantId
value: azuread--tenantid
keyVaultName: vh-infra-core-${{ variables.env }}
secret: true
# GOV Notify Configuration
- name: NotifyConfiguration:ApiKey
value: $(notify-api-key)
- name: NotifyConfiguration:CallbackSecret
value: $(notify-callback-secret)
- name: NotifyConfiguration:Environment
value: $(notify-environment)