forked from gruntwork-io/terratest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.yml
251 lines (207 loc) · 8.02 KB
/
config.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
defaults: &defaults
machine:
enabled: true
image: "ubuntu-1604:201903-01"
environment:
GRUNTWORK_INSTALLER_VERSION: v0.0.21
MODULE_CI_VERSION: v0.13.12
TERRAFORM_VERSION: 0.11.11
TERRAGRUNT_VERSION: v0.18.3
PACKER_VERSION: 1.3.3
GOLANG_VERSION: 1.11
K8S_VERSION: v1.10.0 # Same as EKS
HELM_VERSION: v2.12.2
KUBECONFIG: /home/circleci/.kube/config
install_helm: &install_helm
name: install helm
command: |
# install helm
curl -Lo helm.tar.gz https://storage.googleapis.com/kubernetes-helm/helm-${HELM_VERSION}-linux-amd64.tar.gz
tar -xvf helm.tar.gz
chmod +x linux-amd64/helm
sudo mv linux-amd64/helm /usr/local/bin/
# Deploy Tiller
helm init --wait
install_gruntwork_utils: &install_gruntwork_utils
name: install gruntwork utils
command: |
curl -Ls https://raw.githubusercontent.com/gruntwork-io/gruntwork-installer/master/bootstrap-gruntwork-installer.sh | bash /dev/stdin --version "${GRUNTWORK_INSTALLER_VERSION}"
gruntwork-install --module-name "gruntwork-module-circleci-helpers" --repo "https://github.com/gruntwork-io/module-ci" --tag "${MODULE_CI_VERSION}"
gruntwork-install --module-name "kubernetes-circleci-helpers" --repo "https://github.com/gruntwork-io/module-ci" --tag "${MODULE_CI_VERSION}"
configure-environment-for-gruntwork-module \
--circle-ci-2-machine-executor \
--terraform-version ${TERRAFORM_VERSION} \
--terragrunt-version ${TERRAGRUNT_VERSION} \
--packer-version ${PACKER_VERSION} \
--use-go-dep \
--go-version ${GOLANG_VERSION} \
--go-src-path ./
version: 2
jobs:
setup:
<<: *defaults
steps:
- checkout
- restore_cache:
keys:
- dep-{{ checksum "Gopkg.lock" }}
# Install gruntwork utilities
- run:
<<: *install_gruntwork_utils
- save_cache:
key: dep-{{ checksum "Gopkg.lock" }}
paths:
- ./vendor
# Run pre-commit hooks and fail the build if any hook finds required changes.
- run: go get golang.org/x/tools/cmd/goimports
- run: pip install pre-commit==1.11.2
- run: pre-commit install
- run: pre-commit run --all-files
# Build any binaries that need to be built
# We always want to build the binaries, because we will use the terratest_log_parser to parse out the test output
# during a failure.
- run:
command: |
cd ~/.go_workspace/src/github.com/gruntwork-io/terratest
GO_ENABLED=0 build-go-binaries \
--circle-ci-2 \
--app-name terratest_log_parser \
--src-path ./cmd/terratest_log_parser \
--dest-path ./cmd/bin \
--ld-flags "-X main.VERSION=$CIRCLE_TAG -extldflags '-static'"
when: always
- persist_to_workspace:
root: /home/circleci
paths:
- project
test:
<<: *defaults
steps:
- attach_workspace:
at: /home/circleci
- run:
<<: *install_gruntwork_utils
# The weird way you have to set PATH in Circle 2.0
- run: echo 'export PATH=$HOME/.local/bin:$HOME/terraform:$HOME/packer:$PATH' >> $BASH_ENV
# Make GCP Service Account creds available as a file
- run: echo $GCLOUD_SERVICE_KEY > ${HOME}/gcloud-service-key.json
- run: echo 'export GOOGLE_APPLICATION_CREDENTIALS=${HOME}/gcloud-service-key.json' >> $BASH_ENV
# Run the tests. Note that we set the "-p 1" flag to tell Go to run tests in each package sequentially. Without
# this, Go buffers all log output until all packages are done, which with slower running tests can cause CircleCI
# to kill the build after more than 10 minutes without log output.
# NOTE: because this doesn't build with the kubernetes tag, it will not run the kubernetes tests. See
# kubernetes_test build steps.
- run: mkdir -p /tmp/logs
- run: run-go-tests --packages "-p 1 ./..." | tee /tmp/logs/test_output.log
- run:
command: ./cmd/bin/terratest_log_parser_linux_amd64 --testlog /tmp/logs/test_output.log --outputdir /tmp/logs
when: always
# Store test result and log artifacts for browsing purposes
- store_artifacts:
path: /tmp/logs
- store_test_results:
path: /tmp/logs
kubernetes_test:
<<: *defaults
steps:
- attach_workspace:
at: /home/circleci
- run:
<<: *install_gruntwork_utils
# The weird way you have to set PATH in Circle 2.0
- run: echo 'export PATH=$HOME/.local/bin:$HOME/terraform:$HOME/packer:$PATH' >> $BASH_ENV
- run:
command: setup-minikube
# Run the Kubernetes tests. These tests are run because the kubernetes build tag is included, and we explicitly
# select the kubernetes tests
- run:
command: |
mkdir -p /tmp/logs
# Run the unit tests first, then the integration tests. They are separate because the integration tests
# require additional filtering.
run-go-tests --packages "-tags kubernetes ./modules/k8s" | tee /tmp/logs/test_output.log
run-go-tests --packages "-tags kubernetes -run TestKubernetes ./test" | tee -a /tmp/logs/test_output.log
- run:
command: ./cmd/bin/terratest_log_parser_linux_amd64 --testlog /tmp/logs/test_output.log --outputdir /tmp/logs
when: always
# Store test result and log artifacts for browsing purposes
- store_artifacts:
path: /tmp/logs
- store_test_results:
path: /tmp/logs
helm_test:
<<: *defaults
steps:
- attach_workspace:
at: /home/circleci
- run:
<<: *install_gruntwork_utils
# The weird way you have to set PATH in Circle 2.0
- run: echo 'export PATH=$HOME/.local/bin:$HOME/terraform:$HOME/packer:$PATH' >> $BASH_ENV
- run:
command: setup-minikube
- run:
<<: *install_helm
# Run the Helm tests. These tests are run because the helm build tag is included, and we explicitly
# select the helm tests
- run:
command: |
mkdir -p /tmp/logs
# Run the unit tests first, then the integration tests. They are separate because the integration tests
# require additional filtering.
run-go-tests --packages "-tags helm ./modules/helm" | tee /tmp/logs/test_output.log
run-go-tests --packages "-tags helm -run TestHelm ./test" | tee -a /tmp/logs/test_output.log
- run:
command: ./cmd/bin/terratest_log_parser_linux_amd64 --testlog /tmp/logs/test_output.log --outputdir /tmp/logs
when: always
# Store test result and log artifacts for browsing purposes
- store_artifacts:
path: /tmp/logs
- store_test_results:
path: /tmp/logs
deploy:
machine: true
steps:
- checkout
- attach_workspace:
at: /home/circleci
- run: curl -Ls https://raw.githubusercontent.com/gruntwork-io/gruntwork-installer/master/bootstrap-gruntwork-installer.sh | bash /dev/stdin --version v0.0.21
- run: gruntwork-install --module-name "gruntwork-module-circleci-helpers" --repo "https://github.com/gruntwork-io/module-ci" --tag "v0.13.2"
- run: cd cmd/bin && sha256sum * > SHA256SUMS
- run: upload-github-release-assets cmd/bin/*
workflows:
version: 2
build-and-test:
jobs:
- setup:
filters:
tags:
only: /^v.*/
- test:
requires:
- setup
filters:
tags:
only: /^v.*/
- kubernetes_test:
requires:
- setup
filters:
tags:
only: /^v.*/
- helm_test:
requires:
- setup
filters:
tags:
only: /^v.*/
- deploy:
requires:
- test
- kubernetes_test
- helm_test
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/