-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathazure-pipelines.yaml
284 lines (273 loc) · 11.2 KB
/
azure-pipelines.yaml
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
name: $(Build.BuildId)
# Triggers
trigger:
- master
pr:
autoCancel: true
drafts: false
branches:
include:
- "*"
paths:
exclude:
- ".github/workflows/*"
- .gitignore
- .pre-commit-config.yaml
- .tflint.hcl
- LICENSE
- README.md
- renovate.json
# Define resources for container to use.
resources:
containers:
- container: prime
image: dfdsdk/prime-pipeline:2.1.1
env:
AWS_DEFAULT_REGION: eu-west-1
AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY)
ARM_CLIENT_SECRET: $(ARM_CLIENT_SECRET)
TF_VAR_fluxcd_bootstrap_repo_owner_token: $(TF_VAR_fluxcd_bootstrap_repo_owner_token)
TF_VAR_atlantis_github_token: $(TF_VAR_atlantis_github_token)
TF_VAR_monitoring_kube_prometheus_stack_azure_tenant_id: $(ARM_TENANT_ID)
TF_VAR_grafana_agent_api_token: $(TF_VAR_grafana_agent_api_token)
TF_VAR_grafana_agent_prometheus_url: $(TF_VAR_grafana_agent_prometheus_url)
TF_VAR_grafana_agent_prometheus_username: $(TF_VAR_grafana_agent_prometheus_username)
TF_VAR_grafana_agent_loki_url: $(TF_VAR_grafana_agent_loki_url)
TF_VAR_grafana_agent_loki_username: $(TF_VAR_grafana_agent_loki_username)
TF_VAR_grafana_agent_tempo_url: $(TF_VAR_grafana_agent_tempo_url)
TF_VAR_grafana_agent_tempo_username: $(TF_VAR_grafana_agent_tempo_username)
TF_IN_AUTOMATION: "true"
TERRAGRUNT_TFPATH: /usr/local/bin/tofu
- container: aws-nuke
image: dfdsdk/aws-nuke:0.0.26
env:
AWS_SECRET_ACCESS_KEY: $(AWS_SECRET_ACCESS_KEY)
ARM_CLIENT_SECRET: $(ARM_CLIENT_SECRET)
- container: go-build
image: golang:1.23.5-bullseye
repositories:
- repository: Origin
type: github
endpoint: "dfds (2)"
name: dfds/infrastructure-modules
ref: master
- repository: Nuke
type: github
endpoint: "dfds (2)"
name: dfds/qa-nuke-config
ref: main
# Define variable group to use
variables:
- group: "Infrastructure-Modules QA"
lockBehavior: sequential
pool:
vmImage: "ubuntu-latest"
stages:
- stage: nuke
displayName: "Nuke QA Account"
condition: eq(variables['NUKE_QA'], 'true')
jobs:
- deployment: destroy
displayName: Destroy resources
cancelTimeoutInMinutes: 5
container: prime
environment: QA
strategy:
runOnce:
deploy:
steps:
- checkout: origin
fetchDepth: 1
fetchTags: false
- bash: ./src/qa-test-eks.sh destroy-velero-bucket eu-west-1 _global/s3-bucket-velero
displayName: "Terraform destroy Velero S3 bucket"
condition: succeededOrFailed()
timeoutInMinutes: 30
- bash: ./src/qa-test-eks.sh destroy-cluster eu-west-1 qa
displayName: "Terraform destroy cluster & services"
condition: succeededOrFailed()
timeoutInMinutes: 60
- bash: ./src/qa-test-eks.sh destroy-public-bucket eu-west-1 _global/eks-public-s3-bucket
displayName: "Terraform destroy shared resources"
condition: succeededOrFailed()
timeoutInMinutes: 30
- deployment: nuke_account
displayName: Nuke QA's AWS account
cancelTimeoutInMinutes: 5
container: aws-nuke
dependsOn: destroy
condition: succeededOrFailed()
environment: QA
strategy:
runOnce:
deploy:
steps:
- checkout: Nuke
fetchDepth: 1
fetchTags: false
- bash: /usr/local/bin/aws-nuke -c ./nuke-config.yaml --force --force-sleep 5 --no-dry-run
displayName: "Nuke resources in QA account"
timeoutInMinutes: 60
- stage: test
displayName: "Testing"
dependsOn: nuke
condition: or(succeededOrFailed('nuke'), ne(variables['NUKE_QA'], 'true'))
jobs:
- job: build_test_master
displayName: Build test binary from master branch
container: go-build
cancelTimeoutInMinutes: 0
variables:
GO_CACHE_DIR: $(Pipeline.Workspace)/.cache/go-build/
steps:
- checkout: Origin
fetchDepth: 1
fetchTags: false
- task: [email protected]
inputs:
key: '"go" | "$(Agent.OS)" | $(Build.Repository.LocalPath)/test/integration/suite/go.sum | $(Build.Repository.LocalPath)/src/qa-test-eks.sh'
restoreKeys: '"go" | "$(Agent.OS)"'
path: $(GO_CACHE_DIR)
displayName: Restore Go build cache
- bash: ./src/qa-test-eks.sh test-build eu-west-1 qa $(Build.ArtifactStagingDirectory)/test-master.bin
env:
GOCACHE: $(GO_CACHE_DIR)
displayName: "Build test binary"
timeoutInMinutes: 15
- task: [email protected]
inputs:
pathToPublish: $(Build.ArtifactStagingDirectory)/test-master.bin
artifactName: test-master
- job: build_test_feature
displayName: Build test binary from feature branch
cancelTimeoutInMinutes: 0
condition: and(succeeded(), ne(variables['Build.SourceBranchName'], 'master'))
container: go-build
variables:
GO_CACHE_DIR: $(Pipeline.Workspace)/.cache/go-build/
steps:
- checkout: self
fetchDepth: 1
fetchTags: false
- task: [email protected]
inputs:
key: '"go" | "$(Agent.OS)" | $(Build.Repository.LocalPath)/test/integration/suite/go.sum | $(Build.Repository.LocalPath)/src/qa-test-eks.sh'
restoreKeys: '"go" | "$(Agent.OS)"'
path: $(GO_CACHE_DIR)
displayName: Restore Go build cache
- bash: ./src/qa-test-eks.sh test-build eu-west-1 qa $(Build.ArtifactStagingDirectory)/test-feature.bin
env:
GOCACHE: $(GO_CACHE_DIR)
displayName: "Build test binary"
timeoutInMinutes: 15
- task: [email protected]
inputs:
pathToPublish: $(Build.ArtifactStagingDirectory)/test-feature.bin
artifactName: test-feature
- deployment: init
displayName: Provision from master branch
cancelTimeoutInMinutes: 5
container: prime
dependsOn: build_test_master
condition: succeeded()
environment: QA
strategy:
runOnce:
deploy:
steps:
- checkout: Origin
fetchDepth: 1
fetchTags: false
path: source
- bash: ./src/qa-test-eks.sh apply-shared _global/eks-public-s3-bucket
workingDirectory: $(Agent.BuildDirectory)/source
displayName: "Provision shared EKS S3 bucket"
timeoutInMinutes: 15
- bash: ./src/qa-test-eks.sh apply-cluster eu-west-1 qa
workingDirectory: $(Agent.BuildDirectory)/source
displayName: "Provision cluster & services"
timeoutInMinutes: 60
- bash: ./src/qa-test-eks.sh apply-shared _global/s3-bucket-velero
workingDirectory: $(Agent.BuildDirectory)/source
displayName: "Provision Velero S3 bucket"
timeoutInMinutes: 15
- bash: wait-for-ngs.sh qa
displayName: "Wait for managed node groups to become active"
timeoutInMinutes: 15
- bash: wait-for-asgs.sh qa
displayName: "Wait for auto scaling groups's instances to be in service"
timeoutInMinutes: 15
- download: current
displayName: "Download test binary"
artifact: test-master
- bash: ./src/qa-test-eks.sh test-run eu-west-1 qa $(Pipeline.Workspace)/test-master/test-master.bin
workingDirectory: $(Agent.BuildDirectory)/source
displayName: "Run tests"
timeoutInMinutes: 15
- deployment: apply
displayName: Apply from feature branch
cancelTimeoutInMinutes: 5
container: prime
dependsOn:
- init
- build_test_feature
condition: and(succeeded(), ne(variables['Build.SourceBranchName'], 'master'))
environment: QA
strategy:
runOnce:
deploy:
steps:
- checkout: self
fetchDepth: 1
fetchTags: false
path: source
- bash: ./src/qa-test-eks.sh apply-shared _global/eks-public-s3-bucket
workingDirectory: $(Agent.BuildDirectory)/source
displayName: "Provision shared EKS S3 bucket"
timeoutInMinutes: 15
- bash: ./src/qa-test-eks.sh apply-cluster eu-west-1 qa
workingDirectory: $(Agent.BuildDirectory)/source
displayName: "Provision cluster & services"
timeoutInMinutes: 60
- bash: ./src/qa-test-eks.sh apply-shared _global/s3-bucket-velero
workingDirectory: $(Agent.BuildDirectory)/source
displayName: "Provision Velero S3 bucket"
timeoutInMinutes: 15
- bash: wait-for-ngs.sh qa
displayName: "Wait for managed node groups to become active"
timeoutInMinutes: 15
- bash: wait-for-asgs.sh qa
displayName: "Wait for auto scaling groups's instances to be in service"
- download: current
displayName: "Download test binary"
artifact: test-feature
- bash: ./src/qa-test-eks.sh test-run eu-west-1 qa $(Pipeline.Workspace)/test-feature/test-feature.bin
workingDirectory: $(Agent.BuildDirectory)/source
displayName: "Run tests"
timeoutInMinutes: 15
- deployment: destroy
displayName: Destroy resources
cancelTimeoutInMinutes: 5
container: prime
dependsOn: apply
condition: and(succeededOrFailed(), eq(variables['TEST_DESTROY'], 'true'))
environment: QA
strategy:
runOnce:
deploy:
steps:
- checkout: self
fetchDepth: 1
fetchTags: false
- bash: ./src/qa-test-eks.sh destroy-velero-bucket eu-west-1 _global/s3-bucket-velero
displayName: "Terraform destroy Velero S3 bucket"
condition: succeededOrFailed()
timeoutInMinutes: 30
- bash: ./src/qa-test-eks.sh destroy-cluster eu-west-1 qa
displayName: "Terraform destroy cluster & services"
condition: succeededOrFailed()
timeoutInMinutes: 60
- bash: ./src/qa-test-eks.sh destroy-public-bucket eu-west-1 _global/eks-public-s3-bucket
displayName: "Terraform destroy shared resources"
condition: succeededOrFailed()
timeoutInMinutes: 30