-
Notifications
You must be signed in to change notification settings - Fork 0
Add Terraform & OpenTofu End-to-End tests, minor cleanup #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,157 @@ | ||
| name: "Tests" | ||
| defaults: | ||
| run: | ||
| shell: bash | ||
| on: | ||
| pull_request: | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| terraform-linter: | ||
| name: Linter | ||
| runs-on: ubuntu-24.04 | ||
| 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: Formatter | ||
| runs-on: ubuntu-24.04 | ||
| 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" | ||
|
|
||
| terraform-e2e: | ||
| name: E2E Tests (Terraform) | ||
| strategy: | ||
| max-parallel: 1 | ||
| matrix: | ||
| terraform_version: [1.5.6, 1.10.1] | ||
| os: [ubuntu-24.04] | ||
| runs-on: ${{ matrix.os }} | ||
| steps: | ||
| - name: Checkout Code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| submodules: true | ||
|
|
||
| - uses: hashicorp/setup-terraform@v3 | ||
| with: | ||
| terraform_version: ${{ matrix.terraform_version }} | ||
|
|
||
| - 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 | ||
|
|
||
| opentofu-e2e: | ||
| name: E2E Tests (OpenTofu) | ||
| strategy: | ||
| max-parallel: 1 | ||
| matrix: | ||
| opentofu_version: [1.6.0, 1.8.7] | ||
| os: [ubuntu-24.04] | ||
| runs-on: ${{ matrix.os }} | ||
| steps: | ||
| - name: Checkout Code | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| submodules: true | ||
|
|
||
| - uses: opentofu/setup-opentofu@v1 | ||
| with: | ||
| tofu_version: ${{ matrix.opentofu_version }} | ||
|
|
||
| - 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 | ||
|
|
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| ### Terraform template | ||
| # Local .terraform directories | ||
| **/.terraform/* | ||
|
|
||
| # .tfstate files | ||
| *.tfstate | ||
| *.tfstate.* | ||
|
|
||
| # Crash log files | ||
| crash.log | ||
| crash.*.log | ||
|
|
||
| # Exclude all .tfvars files, which are likely to contain sensitive data, such as | ||
| # password, private keys, and other secrets. These should not be part of version | ||
| # control as they are data points which are potentially sensitive and subject | ||
| # to change depending on the environment. | ||
| *.tfvars | ||
| *.tfvars.json | ||
|
|
||
| # Ignore override files as they are usually used to override resources locally and so | ||
| # are not checked in | ||
| override.tf | ||
| override.tf.json | ||
| *_override.tf | ||
| *_override.tf.json | ||
|
|
||
| # Ignore transient lock info files created by terraform apply | ||
| .terraform.tfstate.lock.info | ||
|
|
||
| # Include override files you do wish to add to version control using negated pattern | ||
| # !example_override.tf | ||
|
|
||
| # Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan | ||
| # example: *tfplan* | ||
|
|
||
| # Ignore CLI configuration files | ||
| .terraformrc | ||
| terraform.rc | ||
|
|
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| # Basic tflint configuration | ||
| plugin "aws" { | ||
| enabled = true | ||
| } |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| # Simple Terraform Module Example doesn't have provider configuration | ||
| plugin "aws" { | ||
| enabled = true | ||
| } | ||
|
|
||
| # Ignore missing providers warning | ||
| rule "missing-provider" { | ||
| enabled = false | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| resource "aws_s3_bucket" "krabby_demo" { | ||
| bucket = "dev-krabby-demo" | ||
| tags = { | ||
| Name = "Demo Krabby bucket" | ||
| Environment = "dev" | ||
| } | ||
| } | ||
|
|
||
| module "krabby" { | ||
| source = "../../" | ||
| env = "dev" | ||
| name = "krabby" | ||
|
|
||
| parameters = { | ||
| API_KEY = "api-XXXXXXXXXXXXXXXXXXXXX" | ||
| S3_BUCKET_ARN = aws_s3_bucket.krabby_demo.arn | ||
| S3_BUCKET_NAME = aws_s3_bucket.krabby_demo.id | ||
| } | ||
| } | ||
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.