From 27654e60bc36c95e518be7aee4e30a41c0d2ce29 Mon Sep 17 00:00:00 2001 From: Artjoms Laivins Date: Thu, 17 Oct 2024 13:00:11 +0200 Subject: [PATCH 1/3] feat: add CI action to test module --- .github/workflows/test.yaml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..8353143 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,30 @@ +name: "CI TF Test" + +on: + push: + branches: + - main + pull_request: + branches: + - main + types: [opened, synchronize, reopened] + workflow_dispatch: # allows manual build + +env: + ARM_TENANT_ID: ${{ secrets.REPO_AZURE_DSB_TENANT_ID }} + ARM_SUBSCRIPTION_ID: ${{ secrets.REPO_AZURE_SUBSCRIPTION_ID }} + ARM_CLIENT_ID: ${{ secrets.REPO_AZURE_TERRAFORM_USER_SERVICE_PRINCIPAL }} + ARM_USE_OIDC: true + ARM_USE_AZUREAD: true + TF_IN_AUTOMATION: true + +jobs: + tf: + uses: dsb-norge/github-actions-terraform/.github/workflows/terraform-module-ci.yaml@tf-test + secrets: inherit + permissions: + contents: read # required for checkout action. + id-token: write # required for Azre passwodless login + pull-requests: write # required for commenting on PR + with: + terraform-version: "1.9.x" \ No newline at end of file From 2678862443604ea9eb9488bb8c65a6dd0d0771fc Mon Sep 17 00:00:00 2001 From: artlvns Date: Mon, 21 Oct 2024 09:51:38 +0200 Subject: [PATCH 2/3] fix: fmt --- tests/unit-tests.tftest.hcl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/unit-tests.tftest.hcl b/tests/unit-tests.tftest.hcl index bce74db..e90da45 100644 --- a/tests/unit-tests.tftest.hcl +++ b/tests/unit-tests.tftest.hcl @@ -216,8 +216,8 @@ run "it_should_output_resource_id_for_cost_anomaly_alert" { cost_anomaly_alert_email_receivers = ["vaild.dummy@epost.her"] } - assert { - condition = length(output.cost_anomaly_alert_id) > 0 - error_message = "Cost anomaly alert id outpout is missing" - } + assert { + condition = length(output.cost_anomaly_alert_id) > 0 + error_message = "Cost anomaly alert id outpout is missing" + } } From 997c338a4662ccf9fa2ee9ff7aa52a4567c76576 Mon Sep 17 00:00:00 2001 From: artlvns Date: Mon, 21 Oct 2024 10:03:13 +0200 Subject: [PATCH 3/3] fix: make names unique for integration tests --- examples/01-basic/main.tf | 2 +- examples/02-full/main.tf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/01-basic/main.tf b/examples/01-basic/main.tf index 2a7f470..dd20af4 100644 --- a/examples/01-basic/main.tf +++ b/examples/01-basic/main.tf @@ -5,7 +5,7 @@ provider "azurerm" { module "consumption_budget" { source = "../../" - app_short_name = "my-azure-app" + app_short_name = "my-budget-basic" subscription = "sub-name" environment = "prod" consumption_budget_amount = 9000 # in local currency of subscription location diff --git a/examples/02-full/main.tf b/examples/02-full/main.tf index a3d282b..7aa7f65 100644 --- a/examples/02-full/main.tf +++ b/examples/02-full/main.tf @@ -5,7 +5,7 @@ provider "azurerm" { module "consumption_budget" { source = "../../" - app_short_name = "my-azure-app" + app_short_name = "my-budget-full" subscription = "sub-name" environment = "prod" consumption_budget_amount = 9000 # in local currency of subscription location