Skip to content

Commit

Permalink
Remove outdated test files and add new validation and workflow trigge…
Browse files Browse the repository at this point in the history
…r tests for EKS cluster deployment
  • Loading branch information
arnol377 committed Apr 14, 2025
1 parent 1139704 commit fbf89c9
Show file tree
Hide file tree
Showing 20 changed files with 140 additions and 39 deletions.
63 changes: 63 additions & 0 deletions .terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .terraform/modules/github_repo
Submodule github_repo added at b6b6cb
1 change: 1 addition & 0 deletions .terraform/modules/modules.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Modules":[{"Key":"","Source":"","Dir":"."},{"Key":"github_repo","Source":"registry.terraform.io/HappyPathway/repo/github","Version":"1.0.83","Dir":".terraform/modules/github_repo"}]}
19 changes: 16 additions & 3 deletions examples/basic/basic.tftest.hcl → basic.tftest.hcl
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
variables {
github_token = "mock-token"
name = "test-eks-cluster"
organization = "test-org"
template_repo_org = "test-org"
environment = "dev"
region = "us-east-1"
cluster_config = {
cluster_name = "dev-eks-01"
account_name = "dev-account"
aws_account_id = "123456789012"
aws_profile = "dev-profile"
environment_abbr = "dev"
vpc_name = "dev-vpc"
vpc_domain_name = "dev.example.com"
}
}

provider "github" {
owner = "my-org"
token = "mock-token"
token = var.github_token
base_url = "https://github.mycompany.com/api/v3"
}

run "verify_repository_config" {
command = plan

assert {
condition = module.eks_deployment.github_repo.name == "eks-test-cluster"
condition = module.eks_deployment.github_repo.name == "test-eks-cluster"
error_message = "Repository name does not match expected value"
}

Expand Down
Submodule eks_deployment.github_repo added at b6b6cb
1 change: 1 addition & 0 deletions examples/basic/.terraform/modules/modules.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Modules":[{"Key":"","Source":"","Dir":"."},{"Key":"eks_deployment","Source":"../..","Dir":"../.."},{"Key":"eks_deployment.github_repo","Source":"registry.terraform.io/HappyPathway/repo/github","Version":"1.0.83","Dir":".terraform/modules/eks_deployment.github_repo"}]}
32 changes: 0 additions & 32 deletions examples/basic/workflow_trigger.tftest.hcl

This file was deleted.

4 changes: 2 additions & 2 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ module "github_repo" {

resource "null_resource" "trigger_workflow" {
triggers = {
repository_name = module.github_repo.github_repo.name
github_repo_name = module.github_repo.github_repo.name
}

provisioner "local-exec" {
command = "python3 scripts/trigger_workflow.py ${module.github_repo.github_repo.name} cluster-plan '{\"environment\":\"${var.environment}\",\"region\":\"${var.region}\",\"cluster_dir\":\"${var.cluster_config.cluster_dir}\",\"auto_approve\":true}'"
command = "python3 scripts/trigger_workflow.py ${module.github_repo.github_repo.name} cluster-plan '{\"environment\":\"${var.environment}\",\"region\":\"${var.region}\",\"cluster_dir\":\"${var.cluster_config.cluster_name}\",\"auto_approve\":true}'"

environment = {
GITHUB_TOKEN = var.github_token
Expand Down
1 change: 1 addition & 0 deletions terraform_data_dirs/default/modules/github_repo
Submodule github_repo added at b6b6cb
1 change: 1 addition & 0 deletions terraform_data_dirs/default/modules/modules.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Modules":[{"Key":"","Source":"","Dir":"."},{"Key":"github_repo","Source":"registry.terraform.io/HappyPathway/repo/github","Version":"1.0.83","Dir":"/data/terraform/workspaces/arnol377/git/terraform-eks-deployment/terraform_data_dirs/default/modules/github_repo"}]}
17 changes: 15 additions & 2 deletions examples/basic/validation.tftest.hcl → validation.tftest.hcl
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
variables {
github_token = "mock-token"
name = "test-eks-cluster"
organization = "test-org"
template_repo_org = "test-org"
environment = "dev"
region = "us-east-1"
cluster_config = {
cluster_name = "dev-eks-01"
account_name = "dev-account"
aws_account_id = "123456789012"
aws_profile = "dev-profile"
environment_abbr = "dev"
vpc_name = "dev-vpc"
vpc_domain_name = "dev.example.com"
}
}

provider "github" {
owner = "my-org"
token = "mock-token"
token = var.github_token
base_url = "https://github.mycompany.com/api/v3"
}

Expand Down
1 change: 1 addition & 0 deletions varfiles/default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Empty file added varfiles/default.tfvars
Empty file.
31 changes: 31 additions & 0 deletions workflow_trigger.tftest.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
variables {
github_token = "mock-token"
name = "test-eks-cluster"
organization = "test-org"
template_repo_org = "test-org"
environment = "dev"
region = "us-east-1"
cluster_config = {
cluster_name = "dev-eks-01"
account_name = "dev-account"
aws_account_id = "123456789012"
aws_profile = "dev-profile"
environment_abbr = "dev"
vpc_name = "dev-vpc"
vpc_domain_name = "dev.example.com"
}
}

provider "github" {
token = var.github_token
base_url = "https://github.mycompany.com/api/v3"
}

run "verify_workflow_trigger" {
command = plan

assert {
condition = can([github_repository_dispatch.dispatch])
error_message = "Workflow trigger failed to dispatch"
}
}

0 comments on commit fbf89c9

Please sign in to comment.