Skip to content

Commit

Permalink
add tests to demo-context
Browse files Browse the repository at this point in the history
  • Loading branch information
osterman committed Jun 15, 2024
1 parent a08b31b commit 82646fd
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 6 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,15 @@ jobs:
terraform_version: ${{ steps.config.outputs.terraform-version }}
terraform_wrapper: false

- name: tflint
- 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 --recursive"
flags: >-
--enable-rule=terraform_unused_declarations
--disable-rule=terraform_typed_variables
--minimum-failure-severity=warning
--recursive
--config=${{ github.workspace }}/examples/.tflint.hcl
fail_on_error: true
4 changes: 4 additions & 0 deletions examples/.tflint.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
plugin "terraform" {
enabled = true
preset = "recommended"
}
12 changes: 11 additions & 1 deletion examples/demo-context/atmos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,14 @@ logs:
file: "/dev/stderr"
level: Info


commands:
- name: "test"
description: "Run all tests"
steps:
- atmos validate stacks
- atmos terraform plan demo -s acme-west-dev
- atmos terraform plan demo -s acme-west-staging
- atmos terraform plan demo -s acme-west-prod
- atmos terraform apply demo -s acme-west-dev -auto-approve
- atmos terraform apply demo -s acme-west-staging -auto-approve
- atmos terraform apply demo -s acme-west-prod -auto-approve
3 changes: 3 additions & 0 deletions examples/demo-context/components/terraform/petset/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ data "context_label" "this" {

# Create tags based on the context. Add the value of the name label to the tags
data "context_tags" "this" {
values = {
"type" = var.pet
}
}

module "pet_set" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ data "context_tags" "this" {

locals {
instance_types = {
"alien" = "👽" # Alien
"ant" = "🐜" # Ant
"dog" = "🐶" # Dog
"cat" = "🐱" # Cat
Expand Down
5 changes: 5 additions & 0 deletions examples/demo-context/components/terraform/petset/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,8 @@ output "label" {
output "pet_set" {
value = [for k, v in module.pet_set : v.name]
}

output "delimiter" {
description = "Delimiter used in the context"
value = data.context_config.this.delimiter
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
variable "pet" {
description = "A list of pets to include in the PetSet"
description = "The type of instance to include in the PetSet"
type = string
default = "dog"
}
Expand Down
3 changes: 2 additions & 1 deletion examples/demo-context/stacks/catalog/demo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ components:
context:
values:
name: petset
vars: {}
vars:
pet: "dog"
1 change: 1 addition & 0 deletions examples/demo-context/stacks/deploy/_defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ terraform:
required: true
instance: {}
component: {}
type: {}
repo: {}
stack: {}
stack_file: {}
Expand Down
2 changes: 1 addition & 1 deletion examples/demo-context/stacks/deploy/prod/demo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ components:
type: real
vars:
size: 10
type: "horse"
pet: "alien"

0 comments on commit 82646fd

Please sign in to comment.