forked from lulzzz/bedrock
-
Notifications
You must be signed in to change notification settings - Fork 1
/
azure-pipelines.yml
230 lines (222 loc) · 9.86 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
trigger:
batch: true
branches:
include:
- master
- azure-pipelines
- bedrock-testing-v2
- bedrock_testing
paths:
include:
- /cluster/azure/*
- /cluster/common/*
- /cluster/environments/azure-simple/*
- /cluster/environments/azure-single-keyvault/*
- /cluster/environments/azure-common-infra/*
- /cluster/environments/azure-multiple-clusters/*
- /pipelines/*
- azure-pipelines.yml
exclude:
- gitops/*
- '**/*.md'
pr:
autoCancel: false
branches:
include:
- master
paths:
include:
- /cluster/azure/*
- /cluster/common/*
- /cluster/environments/azure-simple/*
- /cluster/environments/azure-single-keyvault/*
- /cluster/environments/azure-common-infra/*
- /cluster/environments/azure-multiple-clusters/*
- /test/*
- gitops/*
- azure-pipelines.yml
exclude:
- '**/*.md'
variables:
GOBIN: '$(GOPATH)/bin' # Go binaries path
GOROOT: '/usr/local/go1.13' # Go installation path
GOPATH: '$(system.defaultWorkingDirectory)/gopath' # Go workspace path
modulePath: '$(GOPATH)/src/github.com/$(build.repository.name)' # Path to the module's code
stages:
- stage: Bedrock_Init_Validation
jobs:
- job: Bedrock_Init_Validate
steps:
- checkout: self
persistCredentials: true
clean: true
- template: pipelines/bedrock-integration-test-whitelist.yml
- task: "HelmInstaller@1"
inputs:
helmVersionToInstall: "2.16.3"
- task: ShellScript@2
displayName: Validate GitOps pipeline
inputs:
scriptPath: gitops/azure-devops/build.sh
env:
VERIFY_ONLY: 1
HLD_PATH: git://github.com/Microsoft/fabrikate-production-cluster-demo.git
- template: pipelines/bedrock-test-init.yml
- bash: |
# Fail if any of these files have warnings
find . -path ./gopath -prune -o -path ./get_helm.sh -prune -o -type f \( -name "*.sh" -o -name "*.bash" -o -name "*.ksh" \) -print |
while IFS="" read -r file
do
shellcheck "$file"
done
displayName: 'Run Shell Linting (ShellCheck)'
- script: |
terraform fmt -check=true -write=false -list=true > /dev/null
if [ $? -eq 0 ]
then
echo "Bedrock_Linting: All terraform files are valid."
else
echo "Bedrock_Linting: Terraform files invalid format, submit new commit with changes (run terraform fmt)."
exit 1
fi
gofmt -d ../bedrock/test/ | grep "^@@.*@@" > /dev/null
if [ "$?" -eq "1" ]; then
echo "Bedrock_Linting: All golang files are valid."
else
go fmt ../bedrock/test/
echo "Bedrock_Linting: Golang files invalid format, submit new commit with changes (run gofmt in /test/ directory)."
exit 1
fi
workingDirectory: '$(modulePath)/cluster'
displayName: 'Terraform lint check'
- bash: |
AZ_SIMPLE_TEST=$(Whitelist_Bedrock.AZ_SIMPLE_TEST)
AZ_COMMON_MC_TEST=$(Whitelist_Bedrock.AZ_COMMON_MC_TEST)
ALL_IT_TESTS=$(Whitelist_Bedrock.ALL_IT_TESTS)
AZ_COMMON_KV_TEST=$(Whitelist_Bedrock.AZ_COMMON_KV_TEST)
mkdir -p $(Pipeline.Workspace)/variables
echo "Whitelisting Integration Test Values 1. ALL_TESTS: $ALL_IT_TESTS 2. AZ_SIMPLE: $AZ_SIMPLE_TEST 3. AZ_COMMON: $AZ_COMMON_KV_TEST 4. AZ_MC: $AZ_COMMON_MC_TEST"
echo "$ALL_IT_TESTS" > $(Pipeline.Workspace)/variables/ALL_IT_TESTS
echo "$AZ_SIMPLE_TEST" > $(Pipeline.Workspace)/variables/AZ_SIMPLE_TEST
echo "$AZ_COMMON_KV_TEST" > $(Pipeline.Workspace)/variables/AZ_COMMON_KV_TEST
echo "$AZ_COMMON_MC_TEST" > $(Pipeline.Workspace)/variables/AZ_COMMON_MC_TEST
displayName: Exporting Integration Test Trigger Variables to Pipeline Workspace
- publish: $(Pipeline.Workspace)/variables
artifact: variables
- job: Bedrock_Test_SIMPLE
displayName: Bedrock_Build_Azure_Simple
dependsOn: Bedrock_Init_Validate
condition: and(succeeded(), or(eq(dependencies.Bedrock_Init_Validate.outputs['Whitelist_Bedrock.AZ_SIMPLE_TEST'], 'true'), eq(dependencies.Bedrock_Init_Validate.outputs['Whitelist_Bedrock.ALL_IT_TESTS'], 'true')))
timeoutInMinutes: 60
pool:
vmImage: 'Ubuntu-16.04'
timeoutInMinutes: 60
steps:
- task: GoTool@0
inputs:
version: '1.13.5'
- template: pipelines/bedrock-whitelist-artifact-embed.yml
- template: pipelines/bedrock-test-init.yml
- script: |
ssh-keygen -f id_rsa -t rsa -N "bedrock@microsoft.com"
export ssh_key=$(readlink -f id_rsa.pub)
export public_key=$(cat id_rsa.pub)
find $(modulePath)/cluster/environments/azure-simple -type f -name '*.tf' -exec sed -i 's/github.com\/Microsoft\/bedrock\/cluster/..\/../g' {} \;
go test -v -run TestIT_Bedrock_AzureSimple_Test -timeout 99999s
env:
ARM_CLIENT_ID: $(ARM_CLIENT_ID)
ARM_CLIENT_SECRET: $(ARM_CLIENT_SECRET)
ARM_SUBSCRIPTION_ID: $(ARM_SUBSCRIPTION_ID)
ARM_TENANT_ID: $(ARM_TENANT_ID)
ARM_BACKEND_STORAGE_NAME: $(ARM_BACKEND_STORAGE_NAME)
ARM_BACKEND_STORAGE_KEY: $(ARM_BACKEND_STORAGE_KEY)
ARM_BACKEND_STORAGE_CONTAINER: $(ARM_BACKEND_STORAGE_CONTAINER)
workingDirectory: '$(modulePath)/test'
displayName: 'Integration Test: Bedrock_Azure-Simple '
- job: Bedrock_Test_KEYVAULT
displayName: Bedrock_Build_Azure_Single_KeyVault
dependsOn: Bedrock_Init_Validate
condition: and(succeeded(), or(eq(dependencies.Bedrock_Init_Validate.outputs['Whitelist_Bedrock.AZ_COMMON_KV_TEST'], 'true'), eq(dependencies.Bedrock_Init_Validate.outputs['Whitelist_Bedrock.ALL_IT_TESTS'], 'true')))
timeoutInMinutes: 60
pool:
vmImage: 'Ubuntu-16.04'
timeoutInMinutes: 60
variables:
GOBIN: '$(GOPATH)/bin' # Go binaries path
GOROOT: '/usr/local/go1.13' # Go installation path
GOPATH: '$(system.defaultWorkingDirectory)/gopath' # Go workspace path
modulePath: '$(GOPATH)/src/github.com/$(build.repository.name)' # Path to the module's code
steps:
- task: GoTool@0
inputs:
version: '1.13.5'
- template: pipelines/bedrock-whitelist-artifact-embed.yml
- template: pipelines/bedrock-test-init.yml
- script: |
ssh-keygen -f id_rsa -t rsa -N "bedrock@microsoft.com"
export ssh_key=$(readlink -f id_rsa.pub)
export public_key=$(cat id_rsa.pub)
find $(modulePath)/cluster/environments/azure-single-keyvault -type f -name '*.tf' -exec sed -i 's/github.com\/Microsoft\/bedrock\/cluster/..\/../g' {} \;
go test -v -run TestIT_Bedrock_AzureCommon_KV_Test -timeout 99999s
env:
ARM_CLIENT_ID: $(ARM_CLIENT_ID)
ARM_CLIENT_OBJECT_ID: $(ARM_CLIENT_OBJECT_ID)
ARM_CLIENT_SECRET: $(ARM_CLIENT_SECRET)
ARM_SUBSCRIPTION_ID: $(ARM_SUBSCRIPTION_ID)
ARM_TENANT_ID: $(ARM_TENANT_ID)
ARM_BACKEND_STORAGE_NAME: $(ARM_BACKEND_STORAGE_NAME)
ARM_BACKEND_STORAGE_KEY: $(ARM_BACKEND_STORAGE_KEY)
ARM_BACKEND_STORAGE_CONTAINER: $(ARM_BACKEND_STORAGE_CONTAINER)
workingDirectory: '$(modulePath)/test'
displayName: 'Integration Test: Bedrock_Azure-Common-KeyVault '
- job: Bedrock_Test_MULTIPLE
dependsOn: Bedrock_Init_Validate
condition: and(succeeded(), or(eq(dependencies.Bedrock_Init_Validate.outputs['Whitelist_Bedrock.AZ_COMMON_MC_TEST'], 'true'), eq(dependencies.Bedrock_Init_Validate.outputs['Whitelist_Bedrock.ALL_IT_TESTS'], 'true')))
displayName: Bedrock_Build_Azure_Multiple_Clusters
timeoutInMinutes: 60
pool:
vmImage: 'Ubuntu-16.04'
timeoutInMinutes: 60
variables:
GOBIN: '$(GOPATH)/bin' # Go binaries path
GOROOT: '/usr/local/go1.13' # Go installation path
GOPATH: '$(system.defaultWorkingDirectory)/gopath' # Go workspace path
modulePath: '$(GOPATH)/src/github.com/$(build.repository.name)' # Path to the module's code
steps:
- task: GoTool@0
inputs:
version: '1.13.5'
- template: pipelines/bedrock-whitelist-artifact-embed.yml
- template: pipelines/bedrock-test-init.yml
- script: |
ssh-keygen -f id_rsa -t rsa -N "bedrock@microsoft.com"
export ssh_key=$(readlink -f id_rsa.pub)
export public_key=$(cat id_rsa.pub)
find $(modulePath)/cluster/environments/azure-multiple-clusters -type f -name '*.tf' -exec sed -i 's/github.com\/Microsoft\/bedrock\/cluster/..\/../g' {} \;
go test -v -run TestIT_Bedrock_AzureMC_Test -timeout 99999s
env:
ARM_CLIENT_ID: $(ARM_CLIENT_ID)
ARM_CLIENT_OBJECT_ID: $(ARM_CLIENT_OBJECT_ID)
ARM_CLIENT_SECRET: $(ARM_CLIENT_SECRET)
ARM_SUBSCRIPTION_ID: $(ARM_SUBSCRIPTION_ID)
ARM_TENANT_ID: $(ARM_TENANT_ID)
ARM_BACKEND_STORAGE_NAME: $(ARM_BACKEND_STORAGE_NAME)
ARM_BACKEND_STORAGE_KEY: $(ARM_BACKEND_STORAGE_KEY)
ARM_BACKEND_STORAGE_CONTAINER: $(ARM_BACKEND_STORAGE_CONTAINER)
workingDirectory: '$(modulePath)/test'
displayName: 'Integration Test: Bedrock_Azure-Common-MultiCluster '
# - script: |
# export ssh_key=$(readlink -f id_rsa.pub)
# export public_key=$(cat id_rsa.pub)
# find $(modulePath)/cluster/environments/azure-multiple-clusters-waf-tm-apimgmt -type f -name '*.tf' -exec sed -i 's/github.com\/Microsoft\/bedrock\/cluster/..\/../g' {} \;
# go test -v -run TestIT_Bedrock_AzureMC_APIM_Test -timeout 99999s
# env:
# ARM_CLIENT_ID: $(ARM_CLIENT_ID)
# ARM_CLIENT_SECRET: $(ARM_CLIENT_SECRET)
# ARM_SUBSCRIPTION_ID: $(ARM_SUBSCRIPTION_ID)
# ARM_TENANT_ID: $(ARM_TENANT_ID)
# ARM_BACKEND_STORAGE_NAME: $(ARM_BACKEND_STORAGE_NAME)
# ARM_BACKEND_STORAGE_KEY: $(ARM_BACKEND_STORAGE_KEY)
# ARM_BACKEND_STORAGE_CONTAINER: $(ARM_BACKEND_STORAGE_CONTAINER)
# workingDirectory: '$(modulePath)/test'
# displayName: 'Integration Test: azure-multiple-clusters-waf-tm-apimgmt '