forked from smartpcr/bedrock
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
185 lines (170 loc) · 6.91 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
trigger:
batch: true
branches:
include:
- master
- azure-pipelines
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/*
- 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'
jobs:
- job: Bedrock_Test_Harness
displayName: Bedrock_Build_Tests
timeoutInMinutes: 180
pool:
vmImage: 'Ubuntu-16.04'
timeoutInMinutes: 180
variables:
GOBIN: '$(GOPATH)/bin' # Go binaries path
GOROOT: '/usr/local/go1.11' # 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:
- checkout: self
persistCredentials: true
clean: true
- 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
- script: |
mkdir -p '$(GOBIN)'
mkdir -p '$(GOPATH)/pkg'
mkdir -p '$(modulePath)'
shopt -s extglob
shopt -s dotglob
mv !(gopath) '$(modulePath)'
echo '##vso[task.prependpath]$(GOBIN)'
echo '##vso[task.prependpath]$(GOROOT)/bin'
displayName: 'Set up Go workspace'
- script: |
terraform -version
wget https://releases.hashicorp.com/terraform/$(tf_version)/terraform_$(tf_version)_linux_amd64.zip -q
unzip -q terraform_$(tf_version)_linux_amd64.zip
sudo mv terraform /usr/local/bin
terraform -version
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
curl https://raw.githubusercontent.com/helm/helm/master/scripts/get > get_helm.sh
chmod 700 get_helm.sh
./get_helm.sh
displayName: 'Install terraform, kubectl, helm'
- 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'
- 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 '
- script: |
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_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 '
- script: |
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_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 '