From 51689abe405fef3101dc839c835801ea244ce826 Mon Sep 17 00:00:00 2001 From: Austin Valle Date: Fri, 27 Oct 2023 09:15:23 -0400 Subject: [PATCH] add test for stdout with jq --- .github/workflows/data/local/main.tf | 8 ++-- .github/workflows/setup-terraform.yml | 69 ++++++++++++++++++++++++++- 2 files changed, 72 insertions(+), 5 deletions(-) diff --git a/.github/workflows/data/local/main.tf b/.github/workflows/data/local/main.tf index 77ea07a..81ea344 100644 --- a/.github/workflows/data/local/main.tf +++ b/.github/workflows/data/local/main.tf @@ -1,5 +1,5 @@ -resource "null_resource" "null" { - triggers = { - value = timestamp() - } +resource "random_pet" "pet" {} + +output "pet" { + value = random_pet.pet.id } diff --git a/.github/workflows/setup-terraform.yml b/.github/workflows/setup-terraform.yml index 4dc826e..354c735 100644 --- a/.github/workflows/setup-terraform.yml +++ b/.github/workflows/setup-terraform.yml @@ -1,4 +1,4 @@ -name: 'Setup Terraform' +name: 'setup-terraform tests' on: push: @@ -303,3 +303,70 @@ jobs: - name: Terraform Plan id: plan run: terraform plan + + + terraform-stdout-wrapper: + name: 'Terraform Run Local' + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + defaults: + run: + shell: bash + working-directory: ./.github/workflows/data/local + steps: + - name: Checkout + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 + + - name: Setup Terraform + uses: ./ + with: + terraform_wrapper: true + + - name: Terraform Init + run: terraform init + + - name: Terraform Format + run: terraform fmt -check + + - name: Terraform Apply + id: apply + run: terraform apply -auto-approve + + - name: Terraform Output to JQ + id: output + run: terraform output -json | jq '.pet.value' + + terraform-stdout-no-wrapper: + name: 'Terraform Run Local No Wrapper' + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + defaults: + run: + shell: bash + working-directory: ./.github/workflows/data/local + steps: + - name: Checkout + uses: actions/checkout@8ade135a41bc03ea155e62e844d188df1ea18608 # v4.1.0 + + - name: Setup Terraform + uses: ./ + with: + terraform_wrapper: false + + - name: Terraform Init + run: terraform init + + - name: Terraform Format + run: terraform fmt -check + + - name: Terraform Apply + id: apply + run: terraform apply -auto-approve + + - name: Terraform Output to JQ + id: output + run: terraform output -json | jq '.pet.value'