Skip to content

Commit

Permalink
Add failing test for version constraint in a file we fail to parse
Browse files Browse the repository at this point in the history
  • Loading branch information
dflook committed Jan 23, 2025
1 parent 5335987 commit 9b477ab
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 1 deletion.
28 changes: 27 additions & 1 deletion .github/workflows/test-version.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -888,7 +888,7 @@ jobs:
with:
persist-credentials: false

- name: Test terraform-version
- name: Test tofu-version
uses: ./tofu-version
id: tofu-version
env:
Expand All @@ -907,3 +907,29 @@ jobs:
echo "::error:: Terraform version not selected"
exit 1
fi
hard_parse:
runs-on: ubuntu-24.04
name: Get version constraint from hard to parse file
steps:
- name: Checkout
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Test terraform-version
uses: ./terraform-version
id: terraform-version
with:
path: tests/workflows/test-version/hard-parse

- name: Check the version
env:
DETECTED_TERRAFORM_VERSION: ${{ steps.tofu-version.outputs.terraform }}
run: |
echo "The terraform version was $DETECTED_TERRAFORM_VERSION"
if [[ "$DETECTED_TERRAFORM_VERSION" != "1.10.4" ]]; then
echo "::error:: Terraform constraint not parsed correctly"
exit 1
fi
54 changes: 54 additions & 0 deletions tests/workflows/test-version/hard-parse/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
terraform {

}

terraform {
required_version = "1.10.4"
}

locals {
cloud_run_services = [
{
service_name = "service-1",
output_topics = [
{
name = "topic-1",
version = "v1"
}
]
}
]
}


module "pubsub" {
for_each = {
for service in local.cloud_run_services : service.service_name => service
}
source = "./module"
topics = [
for entity in each.value.output_topics : {
topic_name = entity.version != "" ? format("Topic-%s-%s", entity.name, entity.version) : format("Topic-%s", entity.name)
subscription_name = entity.version != "" ? format("Sub-%s-%s", entity.name, entity.version) : format("Sub-%s", entity.name)
}
]
}


variable "not" {}

variable "should-be-sensitive" {
sensitive=true
}

variable "not-again" {
sensitive = false
}

variable also_sensitive {
sensitive = "true"
}

terraform {
backend "s3" {}
}
1 change: 1 addition & 0 deletions tests/workflows/test-version/hard-parse/module/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
variable "topics" {}

0 comments on commit 9b477ab

Please sign in to comment.