-
-
Notifications
You must be signed in to change notification settings - Fork 153
606 lines (529 loc) · 19.8 KB
/
test.yml
File metadata and controls
606 lines (529 loc) · 19.8 KB
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
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
name: Tests
on:
pull_request:
types: [opened, synchronize, reopened]
paths-ignore:
- "README.md"
push:
branches:
- main
- release/v*
paths-ignore:
- ".github/**"
- "docs/**"
- "examples/**"
- "test/**"
workflow_dispatch:
env:
TERRAFORM_VERSION: "1.9.7"
OPEN_TOFU_VERSION: "1.9.1"
HELM_VERSION: "v3.19.2"
HELMFILE_VERSION: "v1.1.0"
PACKER_VERSION: "1.14.2"
jobs:
# ensure the code builds...
build:
name: Build (${{ matrix.target }})
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
include:
- os: "runs-on=${{github.run_id}}/runner=terraform/tag=atmos/extras=s3-cache/private=false"
target: linux
- os: "windows-latest"
target: windows
- os: "macos-latest"
target: macos
runs-on: ${{ matrix.os }}
steps:
- uses: runs-on/action@v1
if: matrix.target == 'linux'
- name: Build
if: ${{ ! ( matrix.target == 'windows' && github.event.pull_request.draft ) }}
run: echo "Building on ${{ matrix.os }}"
- name: Add GNU tar to PATH (significantly faster than windows tar)
if: matrix.target == 'windows' && ! github.event.pull_request.draft
run: echo "C:\Program Files\Git\usr\bin" >> $Env:GITHUB_PATH
- name: Check out code into the Go module directory
if: ${{ ! ( matrix.target == 'windows' && github.event.pull_request.draft ) }}
uses: actions/checkout@v4
- name: Set up Go
if: ${{ ! ( matrix.target == 'windows' && github.event.pull_request.draft ) }}
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
id: go
- name: Get dependencies
if: ${{ ! ( matrix.target == 'windows' && github.event.pull_request.draft ) }}
run: |
make deps
- name: Build
if: ${{ ! ( matrix.target == 'windows' && github.event.pull_request.draft ) }}
run: |
make build-${{ matrix.target }}
- name: Version
if: ${{ ! ( matrix.target == 'windows' && github.event.pull_request.draft ) }}
run: |
make version-${{ matrix.target }}
- name: Upload build artifacts
uses: actions/upload-artifact@v4
if: ${{ ! ( matrix.target == 'windows' && github.event.pull_request.draft ) }}
with:
name: build-artifacts-${{ matrix.target }}
path: |
./build/
# run acceptance tests
test:
name: Acceptance Tests (${{ matrix.flavor.target }})
needs: [build]
strategy:
fail-fast: false
matrix:
flavor:
- { os: "runs-on=${{github.run_id}}/runner=terraform/tag=atmos/extras=s3-cache/private=false", target: linux }
- { os: "windows-latest", target: windows }
- { os: "macos-latest", target: macos }
timeout-minutes: 30
runs-on: ${{ matrix.flavor.os }}
steps:
- uses: runs-on/action@v1
if: matrix.flavor.target == 'linux'
- name: Check out code into the Go module directory
if: ${{ ! ( matrix.flavor.target == 'windows' && github.event.pull_request.draft ) }}
uses: actions/checkout@v4
- name: Add GNU tar to PATH (significantly faster than windows tar)
if: matrix.flavor.target == 'windows' && ! github.event.pull_request.draft
run: echo "C:\Program Files\Git\usr\bin" >> $Env:GITHUB_PATH
- name: Download build artifacts for ${{ matrix.flavor.target }}
uses: actions/download-artifact@v4
if: ${{ ! ( matrix.flavor.target == 'windows' && github.event.pull_request.draft ) }}
with:
name: build-artifacts-${{ matrix.flavor.target }}
path: ${{ github.workspace }}
- name: Add build artifacts directory to PATH for linux or macos
if: matrix.flavor.target == 'linux' || matrix.flavor.target == 'macos'
run: |
echo "${{ github.workspace }}" >> $GITHUB_PATH
chmod +x "${{ github.workspace }}/atmos"
- name: Add build artifacts directory to PATH for windows
if: matrix.flavor.target == 'windows' && ! github.event.pull_request.draft
shell: pwsh
run: |
$atmosPath = Join-Path ${{ github.workspace }} "atmos.exe"
if (-not (Test-Path $atmosPath)) {
throw "atmos.exe not found at: $atmosPath"
}
echo "${{ github.workspace }}" >> $Env:GITHUB_PATH
- name: Install Terraform
uses: hashicorp/setup-terraform@v3
if: ${{ ! ( matrix.flavor.target == 'windows' && github.event.pull_request.draft ) }}
with:
terraform_version: ${{ env.TERRAFORM_VERSION }}
terraform_wrapper: false
- name: Install OpenTofu
uses: opentofu/setup-opentofu@v1
if: ${{ ! ( matrix.flavor.target == 'windows' && github.event.pull_request.draft ) }}
with:
tofu_version: ${{ env.OPEN_TOFU_VERSION }}
tofu_wrapper: false
# https://github.com/hashicorp/setup-packer
- name: Install Packer
uses: hashicorp/setup-packer@main
if: ${{ ! ( matrix.flavor.target == 'windows' && github.event.pull_request.draft ) }}
with:
version: ${{ env.PACKER_VERSION }}
# https://github.com/helmfile/helmfile-action
- name: Install Helmfile
uses: helmfile/helmfile-action@v2.0.5
if: ${{ ! ( matrix.flavor.target == 'windows' && github.event.pull_request.draft ) }}
with:
helm-version: ${{ env.HELM_VERSION }}
helmfile-version: ${{ env.HELMFILE_VERSION }}
helmfile-args: version
helmfile-auto-init: "false"
helm-plugins: ""
- name: Install helm-diff plugin
if: ${{ ! ( matrix.flavor.target == 'windows' && github.event.pull_request.draft ) }}
run: helm plugin install https://github.com/databus23/helm-diff
- name: Check atmos.exe integrity
if: matrix.flavor.target == 'windows' && ! github.event.pull_request.draft
shell: pwsh
run: |
Write-Output "PATH=$Env:PATH"
Write-Output "PATHEXT=$Env:PATHEXT"
Get-ChildItem "${{ github.workspace }}"
Get-Command "${{ github.workspace }}\atmos.exe"
atmos version
- name: Set up Go
uses: actions/setup-go@v5
if: ${{ ! ( matrix.flavor.target == 'windows' && github.event.pull_request.draft ) }}
with:
go-version-file: "go.mod"
id: go
- name: Get dependencies
if: ${{ ! ( matrix.flavor.target == 'windows' && github.event.pull_request.draft ) }}
run: |
make deps
# Enable this after merging test-cases
# Only seems to work with remote schema files
#- name: Validate YAML Schema for Test Cases
# uses: InoUno/yaml-ls-check@v1.4.0
# with:
# root: "tests/test-cases"
# schemaMapping: |
# {
# "schema.json": [
# "**/*.yaml"
# ]
# }
- name: Acceptance tests
timeout-minutes: 30
if: ${{ ! ( matrix.flavor.target == 'windows' && github.event.pull_request.draft ) }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Use the GitHub token for downloading the Packer plugins
PACKER_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Skip precondition checks in CI to ensure tests run and maintain coverage
ATMOS_TEST_SKIP_PRECONDITION_CHECKS: true
run: make testacc-cover
- name: Upload coverage report to Codecov
if: matrix.flavor.target == 'linux' && (success() || failure())
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: ${{ github.repository }}
files: coverage.out
fail_ci_if_error: true
flags: unittests
verbose: true
docker:
name: "[lint] Dockerfile"
needs: build
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
- uses: hadolint/hadolint-action@v3.1.0
id: hadolint
with:
dockerfile: Dockerfile
failure-threshold: warning
format: sarif
output-file: hadolint.sarif
# https://github.com/hadolint/hadolint?tab=readme-ov-file#rules
# DL3008 Pin versions in apt-get install
ignore: DL3008
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v4
if: always()
with:
# Path to SARIF file relative to the root of the repository
sarif_file: hadolint.sarif
# Optional category for the results (used to differentiate multiple results for one commit)
category: hadolint
wait-for-processing: true
# run localstack demo tests
localstack:
name: "[localstack] ${{ matrix.demo-folder }}"
needs: build
runs-on: ubuntu-latest
services:
localstack:
image: public.ecr.aws/localstack/localstack:1.4.0
ports:
- 4566:4566
- 4510-4559:4510-4559
env:
SERVICES: s3, iam, lambda, dynamodb, sts, account, ec2
DEBUG: 0
DOCKER_HOST: unix:///var/run/docker.sock
AWS_ACCESS_KEY_ID: test
AWS_SECRET_ACCESS_KEY: test
AWS_DEFAULT_REGION: us-east-1
AWS_REGION: us-east-1
volumes:
- /var/run/docker.sock:/var/run/docker.sock
strategy:
fail-fast: false
matrix:
demo-folder:
- demo-localstack
timeout-minutes: 20
steps:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts-linux
path: /usr/local/bin
- name: Set execute permissions on atmos
run: chmod +x /usr/local/bin/atmos
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Install Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ env.TERRAFORM_VERSION }}
terraform_wrapper: false
- name: Install OpenTofu
uses: opentofu/setup-opentofu@v1
with:
tofu_version: ${{ env.OPEN_TOFU_VERSION }}
tofu_wrapper: false
# https://github.com/hashicorp/setup-packer
- name: Install Packer
uses: hashicorp/setup-packer@main
with:
version: ${{ env.PACKER_VERSION }}
- name: Run tests for ${{ matrix.demo-folder }}
run: |
cd examples/${{ matrix.demo-folder }}
atmos test
# run k3s demo tests
k3s:
name: "[k3s] ${{ matrix.demo-folder }}"
needs: build
runs-on: ubuntu-latest
env:
KUBECONFIG: ${{github.workspace}}/examples/${{ matrix.demo-folder }}/kubeconfig.yaml
ATMOS_LOGS_LEVEL: Debug
strategy:
matrix:
demo-folder:
- demo-helmfile
timeout-minutes: 20
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Start Docker Compose
working-directory: examples/${{ matrix.demo-folder }}
run: docker compose up -d --wait
- name: Wait for k3s to start
working-directory: examples/${{ matrix.demo-folder }}
run: |
until kubectl get pods --all-namespaces >/dev/null 2>&1; do
echo "Retrying..."
sleep 1
done
kubectl get pods --all-namespaces
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts-linux
path: /usr/local/bin
- name: Set execute permissions on atmos
run: chmod +x /usr/local/bin/atmos
- name: Install the Cloud Posse package repository
run: curl -1sLf 'https://dl.cloudsmith.io/public/cloudposse/packages/cfg/setup/bash.deb.sh' | sudo bash
- name: Install kubectl and helmfile
run: sudo apt-get -y install kubectl helmfile
- name: Install Helm
uses: azure/setup-helm@v4
with:
version: ${{ env.HELM_VERSION }}
- name: Install helm-diff plugin
run: helm plugin install https://github.com/databus23/helm-diff
- name: Write a default AWS profile to the AWS config file
run: |
mkdir -p ~/.aws
echo '[default]' > ~/.aws/config
- name: Run tests for ${{ matrix.demo-folder }}
run: |
cd examples/${{ matrix.demo-folder }}
atmos test
# run other demo tests
mock:
name: "[mock-${{ matrix.flavor.target}}] ${{ matrix.demo-folder }}"
needs: build
runs-on: ${{ matrix.flavor.os }}
strategy:
fail-fast: false
matrix:
flavor:
- { os: ubuntu-latest, target: linux }
- { os: windows-latest, target: windows }
- { os: macos-latest, target: macos }
demo-folder:
- examples/demo-atlantis
# - examples/demo-component-manifest
- examples/demo-component-versions
- examples/demo-context
# - examples/demo-custom-command
# - examples/demo-json-validation
# - examples/demo-opa-validation
# - examples/demo-opentofu
# - examples/demo-project
# - examples/demo-stacks
# - examples/demo-terraform
# - examples/demo-terraform-overrides
# - examples/demo-workflows
# - examples/demo-yaml-anchors
# - examples/demo-mock-architecture
# - examples/demo-stack-templating
# - examples/demo-multi-cloud
- examples/demo-vendoring
- examples/config-profiles
- tests/fixtures/scenarios/complete
timeout-minutes: 20
steps:
- name: Check out code into the Go module directory
if: ${{ ! ( matrix.flavor.target == 'windows' && github.event.pull_request.draft ) }}
uses: actions/checkout@v4
- name: Add GNU tar to flavor.target (significantly faster than windows tar)
if: matrix.flavor.target == 'windows' && ! github.event.pull_request.draft
run: echo "C:\Program Files\Git\usr\bin" >> $Env:GITHUB_PATH
- name: Download build artifacts for ${{ matrix.flavor.target }}
if: ${{ ! ( matrix.flavor.target == 'windows' && github.event.pull_request.draft ) }}
uses: actions/download-artifact@v4
with:
name: build-artifacts-${{ matrix.flavor.target }}
path: ${{ github.workspace }}
- name: Add build artifacts directory to PATH for linux or macos
if: matrix.flavor.target == 'linux' || matrix.flavor.target == 'macos'
run: |
echo "${{ github.workspace }}" >> $GITHUB_PATH
chmod +x "${{ github.workspace }}/atmos"
- name: Add build artifacts directory to PATH for windows
if: matrix.flavor.target == 'windows' && ! github.event.pull_request.draft
shell: pwsh
run: |
echo "${{ github.workspace }}" >> $Env:GITHUB_PATH
- name: Install Terraform
if: ${{ ! ( matrix.flavor.target == 'windows' && github.event.pull_request.draft ) }}
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ env.TERRAFORM_VERSION }}
terraform_wrapper: false
- name: Install OpenTofu
if: ${{ ! ( matrix.flavor.target == 'windows' && github.event.pull_request.draft ) }}
uses: opentofu/setup-opentofu@v1
with:
tofu_version: ${{ env.OPEN_TOFU_VERSION }}
tofu_wrapper: false
# https://github.com/hashicorp/setup-packer
- name: Install Packer
uses: hashicorp/setup-packer@main
with:
version: ${{ env.PACKER_VERSION }}
- name: Run tests in ${{ matrix.demo-folder }} for ${{ matrix.flavor.target }}
working-directory: ${{ matrix.demo-folder }}
if: matrix.flavor.target == 'linux' || matrix.flavor.target == 'macos'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
atmos test
- name: Check atmos.exe integrity
if: matrix.flavor.target == 'windows' && ! github.event.pull_request.draft
shell: pwsh
run: |
Write-Output "PATH=$Env:PATH"
Write-Output "PATHEXT=$Env:PATHEXT"
Get-ChildItem "${{ github.workspace }}"
Get-Command "${{ github.workspace }}\atmos.exe"
atmos version
- name: Run tests in ${{ matrix.demo-folder }} for ${{ matrix.flavor.target }}
working-directory: ${{ matrix.demo-folder }}
if: matrix.flavor.target == 'windows' && ! github.event.pull_request.draft
shell: pwsh
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
atmos test
# run other demo tests
lint:
name: "[lint] ${{ matrix.demo-folder }}"
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
demo-folder:
# - demo-component-manifest
- demo-context
# - demo-custom-command
# - demo-json-validation
# - demo-library
# - demo-localstack
# - demo-opa-validation
# - demo-opentofu
# - demo-project
# - demo-stacks
# - demo-terraform
# - demo-terraform-overrides
# - demo-workflows
# - demo-yaml-anchors
# - demo-mock-architecture
# - demo-stack-templating
# - demo-multi-cloud
- quick-start-advanced
#- quick-start-simple
timeout-minutes: 20
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
- name: Install Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_version: ${{ env.TERRAFORM_VERSION }}
terraform_wrapper: false
- name: Install OpenTofu
uses: opentofu/setup-opentofu@v1
with:
tofu_version: ${{ env.OPEN_TOFU_VERSION }}
tofu_wrapper: false
# https://github.com/hashicorp/setup-packer
- name: Install Packer
uses: hashicorp/setup-packer@main
with:
version: ${{ env.PACKER_VERSION }}
- name: Lint examples/${{ matrix.demo-folder }}/components/terraform
uses: reviewdog/action-tflint@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
working_directory: examples/${{ matrix.demo-folder }}/components/terraform
flags: >-
--enable-rule=terraform_unused_declarations
--disable-rule=terraform_typed_variables
--minimum-failure-severity=warning
--recursive
--config=${{ github.workspace }}/examples/.tflint.hcl
fail_level: error
# run other demo tests
validate:
name: "[validate] ${{ matrix.demo-folder }}"
needs: build
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
demo-folder:
- demo-context
- demo-localstack
- demo-stacks
- demo-helmfile
- quick-start-advanced
- quick-start-simple
timeout-minutes: 20
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Validate YAML Schema for Stacks
uses: InoUno/yaml-ls-check@v1.4.0
with:
root: "examples/${{ matrix.demo-folder }}/stacks"
schemaMapping: |
{
"https://atmos.tools/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json": [
"examples/${{ matrix.demo-folder }}/stacks/**/*.yaml",
"examples/${{ matrix.demo-folder }}/stacks/**/*.yml"
]
}
release:
needs: [test, lint, mock, k3s, localstack, docker, validate]
if: github.event_name == 'push'
uses: cloudposse/.github/.github/workflows/shared-go-auto-release.yml@main
with:
publish: false
format: binary
runs-on: '["runs-on=${{github.run_id}}", "runner=large", "tag=atmos","extras=s3-cache", "private=false"]'
secrets: inherit