From 2d44a7ce8231b6a92839b75a42ca766de69de7de Mon Sep 17 00:00:00 2001 From: 0katrinpetrosyan0 Date: Mon, 23 Jan 2023 13:18:36 +0400 Subject: [PATCH 1/2] chore(1972): In Terraform-Test reject pipline if not have tests folder in repo and work with every submodule --- terraform-test/action.yml | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/terraform-test/action.yml b/terraform-test/action.yml index 0ff68ea..61382fe 100644 --- a/terraform-test/action.yml +++ b/terraform-test/action.yml @@ -1,4 +1,4 @@ -name: Terraform TEST +name: Terraform Test Pipeline description: "terraform tool common flow action to init, test terraform code" author: Das Meta branding: @@ -22,7 +22,7 @@ inputs: path: description: "Path where to run terraform test" required: false - default: dashboard + default: / terraform_version: description: "Terraform version used in this action" required: false @@ -48,8 +48,16 @@ runs: with: terraform_version: ${{ inputs.terraform_version }} + - name: Check for tests folder + run: | + if [ ! -d "${{ inputs.path }}/tests" ]; then + echo "Tests folder not found for ${{ inputs.path }}, exiting pipeline" + exit 1 + fi + shell: bash + - name: Run Terraform Test + if: ${{ success() }} run: | - cd ${{ inputs.path }} - terraform test + terraform test -module=${{ inputs.path }} shell: bash From 2a2b60ad8422c78a682d3d636fefa9085af3dc0b Mon Sep 17 00:00:00 2001 From: 0katrinpetrosyan0 Date: Mon, 23 Jan 2023 13:22:06 +0400 Subject: [PATCH 2/2] chore(1972): change --module argument and cd to module --- terraform-test/action.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/terraform-test/action.yml b/terraform-test/action.yml index 61382fe..112ff41 100644 --- a/terraform-test/action.yml +++ b/terraform-test/action.yml @@ -59,5 +59,6 @@ runs: - name: Run Terraform Test if: ${{ success() }} run: | - terraform test -module=${{ inputs.path }} + cd ${{ inputs.path }} + terraform test shell: bash