- Add tests #5
This file contains 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 Checks" | ||
defaults: | ||
run: | ||
shell: bash | ||
on: | ||
pull_request: | ||
workflow_dispatch: | ||
jobs: | ||
terraform-linter: | ||
name: Terraform Linter | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
strategy: | ||
matrix: | ||
terraform_version: [1.5.6, 1.10.1] | ||
directory: [., ./examples/complete/] | ||
fail-fast: false | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
- uses: hashicorp/setup-terraform@v3 | ||
with: | ||
terraform_version: ${{ matrix.terraform_version }} | ||
- name: Terraform init | ||
working-directory: ${{ matrix.directory }} | ||
run: terraform init | ||
- name: Tflint Report Output | ||
uses: reviewdog/[email protected] | ||
with: | ||
working_directory: ${{ matrix.directory }} | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
tflint_version: "v0.49.0" | ||
reporter: github-pr-review | ||
fail_on_error: "true" | ||
filter_mode: "added" | ||
flags: "--module" | ||
terraform-formatter: | ||
name: Terraform Formatter | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
strategy: | ||
matrix: | ||
terraform_version: [1.5.6, 1.10.1] | ||
directory: [., ./examples/complete/] | ||
fail-fast: false | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
- uses: hashicorp/setup-terraform@v3 | ||
with: | ||
terraform_version: ${{ matrix.terraform_version }} | ||
- name: Terraform init | ||
working-directory: ${{ matrix.directory }} | ||
run: terraform init | ||
- name: Terraform Format suggestions | ||
working-directory: ${{ matrix.directory }} | ||
run: terraform fmt | ||
- uses: reviewdog/[email protected] | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
tool_name: "terraform" | ||
fail_on_error: "true" | ||
filter_mode: "added" | ||
test-e2e: | ||
name: E2E Tests | ||
strategy: | ||
max-parallel: 1 | ||
matrix: | ||
terraform_version: [1.5.6, 1.10.1] | ||
os: [ubuntu-latest] | ||
runs-on: ${{ matrix.os }} | ||
steps: | ||
- name: Configure Environment Variables | ||
run: | | ||
echo "${{ github.workspace }}/bin/" >> $GITHUB_PATH | ||
echo "ENV=${{ github.job }}-$(echo $GITHUB_SHA | cut -c 1-6)" >> $GITHUB_ENV | ||
- name: Install Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: 1.23.x | ||
- name: Run Tests | ||
working-directory: test/ | ||
env: | ||
LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} | ||
run: | | ||
go install github.com/gruntwork-io/terratest/cmd/terratest_log_parser@latest | ||
go mod tidy | ||
go test -v -timeout 60m -coverprofile=coverage-examples-complete.out -race -covermode=atomic | tee test_output.log | ||
terratest_log_parser -testlog test_output.log -outputdir results | ||
- name: Test Summary | ||
uses: test-summary/action@v2 | ||
with: | ||
paths: | | ||
test/results/**/*.xml | ||
test/results/*.xml | ||
``` | ||