-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
Copy pathconfig.yml
338 lines (325 loc) · 11.8 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
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
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
orbs:
# The Windows orb gives us everything we need to start using the Windows executor.
win: circleci/windows@2.4.0
go: circleci/go@1.7.3
# The "sign binary" rubs in a MacOS environment, so it's necessary to download GW's binaries
env: &env
environment:
GRUNTWORK_INSTALLER_VERSION: v0.0.39
MODULE_CI_VERSION: v0.52.6
defaults: &defaults
docker:
- image: 087285199408.dkr.ecr.us-east-1.amazonaws.com/circle-ci-test-image-base:go1.21-tf1.5-tg39.1-pck1.8-ci50.7
install_tofu: &install_tofu
name: Install OpenTofu
command: |
pushd .
cd /tmp
curl -L "https://github.com/opentofu/opentofu/releases/download/v1.6.0-rc1/tofu_1.6.0-rc1_linux_amd64.zip" -o tofu.zip
unzip -o tofu.zip
sudo install -m 0755 tofu /usr/local/bin/tofu
rm -rf tofu
rm -rf tofu.zip
popd
tofu --version
install_tflint: &install_tflint
name: Install Tflint
command: |
pushd .
cd /tmp
curl -L "https://github.com/terraform-linters/tflint/releases/download/v0.47.0/tflint_linux_amd64.zip" -o tflint.zip
unzip -o tflint.zip
sudo install -m 0755 tflint /usr/local/bin/tflint
rm -rf tflint
rm -rf tflint.zip
popd
tflint --version
version: 2.1
jobs:
test_windows:
executor:
name: win/default
size: "large"
steps:
- checkout
- run:
name: Install golang
shell: powershell.exe
command: ./_ci/install-golang.ps1
- run:
name: Install Terraform
shell: powershell.exe
command: ./_ci/install-terraform.ps1
- run:
name: Install Opentofu
shell: powershell.exe
command: ./_ci/install-opentofu.ps1
- run:
name: Install TFLint
shell: powershell.exe
command: ./_ci/install-tflint.ps1
- run:
name: Run go terraform tests
shell: powershell.exe
no_output_timeout: 45m
command: |
# We're running this test only on Windows currently to provide a convenient
# means of reproducing Terragrunt issues that only occur on that platform
go test -v ./... -run TestWindowsTerragruntSourceMapDebug -timeout 45m
go test -v ./... -run TestWindowsTflintIsInvoked -timeout 45m
- run:
name: Run go tofu tests
shell: powershell.exe
no_output_timeout: 45m
environment:
TERRAGRUNT_TFPATH: tofu
command: |
# We're running this test only on Windows currently to provide a convenient
# means of reproducing Terragrunt issues that only occur on that platform
go test -v ./... -run TestWindowsTerragruntSourceMapDebug -timeout 45m
go test -v ./... -run TestWindowsTflintIsInvoked -timeout 45m
# We're running unit tests separately from integration tests - with no parallelization.
# With heavy parallelization coupled with re-use of test fixtures we've witnessed slight
# instability with the tests. The unit tests are fast to execute, so there is negligible
# performance penalty.
unit_test:
<<: *defaults
steps:
- checkout
# Run pre-commit hooks and fail the build if any hook finds required changes.
- run:
name: run precommit
command: |
# Oct 26, 2019: Install the last known working version of pre-commit. Also, we have to pin the version of
# transitive dependencies that are being pulled in which released new versions that are no longer compatible
# with any python < 3.6.
pip3 install pre-commit==1.21.0 cfgv==2.0.1 zipp==1.1.0
go install golang.org/x/tools/cmd/goimports@latest
export GOPATH=~/go/bin && export PATH=$PATH:$GOPATH
pre-commit install
pre-commit run --all-files
- run:
name: run lint
command: |
make install-lint
make run-lint
- run:
command: |
mkdir -p logs
go mod tidy
run-go-tests --parallelism 1 --packages "$(go list ./... | grep -v /test | tr '\n' ' ')" | tee logs/unit.log
- run:
command: terratest_log_parser --testlog logs/unit.log --outputdir logs
when: always
- store_artifacts:
path: logs
- store_test_results:
path: logs
integration_test_terraform:
resource_class: large
<<: *defaults
steps:
- checkout
- run: gruntwork-install --binary-name 'terratest_log_parser' --repo 'https://github.com/gruntwork-io/terratest' --tag 'v0.30.0'
- run:
<<: *install_tflint
- run:
# Install Terraform 1.6 for integration tests
command: |
pushd .
cd /tmp
curl -L "https://releases.hashicorp.com/terraform/1.6.2/terraform_1.6.2_linux_amd64.zip" -o terraform.zip
unzip -o terraform.zip
sudo install -m 0755 terraform /usr/local/bin/terraform
rm -rf terraform
rm -rf terraform.zip
popd
terraform --version
# 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
# Import test / dev key for SOPS
- run:
command: |
gpg --import --no-tty --batch --yes ./test/fixture-sops/test_pgp_key.asc
mkdir -p logs
run-go-tests --packages "$(go list ./... | grep /test | tr '\n' ' ')" | tee logs/integration.log
no_output_timeout: 30m
- run:
command: terratest_log_parser --testlog logs/integration.log --outputdir logs
when: always
- store_artifacts:
path: logs
- store_test_results:
path: logs
integration_test_tofu:
resource_class: large
<<: *defaults
steps:
- checkout
- run: gruntwork-install --binary-name 'terratest_log_parser' --repo 'https://github.com/gruntwork-io/terratest' --tag 'v0.30.0'
- run:
<<: *install_tofu
- run:
<<: *install_tflint
# 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
# Import test / dev key for SOPS
- run:
command: |
gpg --import --no-tty --batch --yes ./test/fixture-sops/test_pgp_key.asc
# remove terraform
sudo rm -f $(which terraform)
mkdir -p logs
run-go-tests --packages "$(go list ./... | grep /test | tr '\n' ' ')" | tee logs/integration.log
no_output_timeout: 30m
environment:
# use tofu as wrapper
TERRAGRUNT_TFPATH: tofu
- run:
command: terratest_log_parser --testlog logs/integration.log --outputdir logs
when: always
- store_artifacts:
path: logs
- store_test_results:
path: logs
integration_test_tflint:
resource_class: large
<<: *defaults
steps:
- checkout
- run: gruntwork-install --binary-name 'terratest_log_parser' --repo 'https://github.com/gruntwork-io/terratest' --tag 'v0.30.0'
- run:
<<: *install_tofu
- run:
<<: *install_tflint
# 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
# Import test / dev key for SOPS
- run:
command: |
gpg --import --no-tty --batch --yes ./test/fixture-sops/test_pgp_key.asc
no_output_timeout: 30m
# Run TFLint tests separately as tflint during execution change working directory.
- run:
command: |
mkdir -p logs
run-go-tests --packages "-tags tflint -run TestTflint ./test" | tee logs/integration.log
no_output_timeout: 30m
- run:
command: terratest_log_parser --testlog logs/integration.log --outputdir logs
when: always
- store_artifacts:
path: logs
- store_test_results:
path: logs
build:
resource_class: large
<<: *defaults
steps:
- checkout
- run: build-go-binaries --app-name terragrunt --dest-path bin --ld-flags "-X github.com/gruntwork-io/go-commons/version.Version=$CIRCLE_TAG -extldflags '-static'"
- persist_to_workspace:
root: .
paths: bin
deploy:
<<: *env
macos:
xcode: 14.2.0
resource_class: macos.x86.medium.gen2
steps:
- checkout
- attach_workspace:
at: .
- go/install:
version: "1.20.5"
- run:
name: Install sign-binary-helpers
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/terraform-aws-ci" --tag "${MODULE_CI_VERSION}"
gruntwork-install --module-name "sign-binary-helpers" --repo "https://github.com/gruntwork-io/terraform-aws-ci" --tag "${MODULE_CI_VERSION}"
- run:
name: Compile and sign the binaries
command: |
sign-binary --install-macos-sign-dependencies --os mac .gon_amd64.hcl
sign-binary --os mac .gon_arm64.hcl
echo "Done signing the binary"
# Replace the files in bin. These are the same file names generated from .gon_amd64.hcl and .gon_arm64.hcl
unzip terragrunt_darwin_amd64.zip
mv terragrunt_darwin_amd64 bin/
unzip terragrunt_darwin_arm64.zip
mv terragrunt_darwin_arm64 bin/
- run:
name: Run SHA256SUM
command: |
brew install coreutils
cd bin && sha256sum * > SHA256SUMS
- run: upload-github-release-assets bin/*
workflows:
version: 2
build-and-test:
jobs:
- test_windows:
filters:
tags:
only: /^v.*/
context:
- AWS__PHXDEVOPS__circle-ci-test
- GCP__automated-tests
- GITHUB__PAT__gruntwork-ci
- unit_test:
filters:
tags:
only: /^v.*/
context:
- AWS__PHXDEVOPS__circle-ci-test
- GCP__automated-tests
- GITHUB__PAT__gruntwork-ci
- integration_test_terraform:
filters:
tags:
only: /^v.*/
context:
- AWS__PHXDEVOPS__circle-ci-test
- GCP__automated-tests
- GITHUB__PAT__gruntwork-ci
- integration_test_tofu:
filters:
tags:
only: /^v.*/
context:
- AWS__PHXDEVOPS__circle-ci-test
- GCP__automated-tests
- GITHUB__PAT__gruntwork-ci
- integration_test_tflint:
filters:
tags:
only: /^v.*/
context:
- AWS__PHXDEVOPS__circle-ci-test
- GCP__automated-tests
- GITHUB__PAT__gruntwork-ci
- build:
filters:
tags:
only: /^v.*/
context:
- AWS__PHXDEVOPS__circle-ci-test
- GCP__automated-tests
- GITHUB__PAT__gruntwork-ci
- deploy:
requires:
- build
filters:
tags:
only: /^v.*/
branches:
ignore: /.*/
context:
- AWS__PHXDEVOPS__circle-ci-test
- GCP__automated-tests
- GITHUB__PAT__gruntwork-ci
- APPLE__OSX__code-signing