This repository was archived by the owner on Apr 6, 2026. It is now read-only.
dev_center_dev_box_definition implementation #4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Terraform Tests" | |
| on: | |
| pull_request: | |
| paths: | |
| - "**.tf" | |
| - "**.tfvars" | |
| - "**.tftest.hcl" | |
| - ".github/workflows/terraform-tests.yml" | |
| permissions: | |
| contents: read | |
| jobs: | |
| pre-check: | |
| name: Format and Validate | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: hashicorp/setup-terraform@v3 | |
| with: | |
| terraform_version: 1.11.4 | |
| - name: Terraform Init | |
| run: terraform init -backend=false | |
| - name: Terraform Format | |
| run: terraform fmt -check -recursive | |
| - name: Terraform Validate | |
| run: terraform validate | |
| discover-tests: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| unit_tests: ${{ steps.find-unit-tests.outputs.tests }} | |
| integration_tests: ${{ steps.find-integration-tests.outputs.tests }} | |
| example_tests: ${{ steps.find-example-tests.outputs.tests }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Find unit tests | |
| id: find-unit-tests | |
| run: | | |
| TESTS=$(find tests/unit -name "*_test.tftest.hcl" -type f | jq -R -s -c 'split("\n")[:-1]') | |
| echo "tests=$TESTS" >> $GITHUB_OUTPUT | |
| - name: Find integration tests | |
| id: find-integration-tests | |
| run: | | |
| TESTS=$(find tests/integration -name "*_test.tftest.hcl" -type f | jq -R -s -c 'split("\n")[:-1]') | |
| echo "tests=$TESTS" >> $GITHUB_OUTPUT | |
| - name: Find example tests | |
| id: find-example-tests | |
| run: | | |
| TESTS=$(find tests/examples -name "*_test.tftest.hcl" -type f | jq -R -s -c 'split("\n")[:-1]') | |
| echo "tests=$TESTS" >> $GITHUB_OUTPUT | |
| unit-tests: | |
| needs: [pre-check, discover-tests] | |
| if: needs.discover-tests.outputs.unit_tests != '[]' | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| test: ${{fromJson(needs.discover-tests.outputs.unit_tests)}} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: hashicorp/setup-terraform@v3 | |
| with: | |
| terraform_version: 1.11.4 | |
| - name: Terraform Init | |
| run: terraform init -backend=false | |
| - name: Run Test | |
| run: terraform test -verbose "${{ matrix.test }}" | |
| integration-tests: | |
| needs: [pre-check, discover-tests] | |
| if: needs.discover-tests.outputs.integration_tests != '[]' | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| test: ${{fromJson(needs.discover-tests.outputs.integration_tests)}} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: hashicorp/setup-terraform@v3 | |
| with: | |
| terraform_version: 1.11.4 | |
| - name: Terraform Init | |
| run: terraform init -backend=false | |
| - name: Run Test | |
| run: terraform test -verbose "${{ matrix.test }}" | |
| example-tests: | |
| needs: [pre-check, discover-tests] | |
| if: needs.discover-tests.outputs.example_tests != '[]' | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| test: ${{fromJson(needs.discover-tests.outputs.example_tests)}} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: hashicorp/setup-terraform@v3 | |
| with: | |
| terraform_version: 1.11.4 | |
| - name: Terraform Init | |
| run: terraform init -backend=false | |
| - name: Run Test | |
| run: terraform test -verbose "${{ matrix.test }}" |