Skip to content

Commit

Permalink
Revert "Chore: Remove tests"
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolasrieble authored Sep 6, 2024
1 parent 8e12812 commit cf7b4af
Show file tree
Hide file tree
Showing 48 changed files with 2,793 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/auto.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ jobs:
${{ github.workspace }}/${m}
done
- name: Lint tests directory in a loop
run: |
for m in $(ls -1d tests/*/)
do
tflint \
--config ${{ github.workspace }}/.tflint.hcl \
${{ github.workspace }}/${m}
done
- name: Lint examples directory in a loop
run: |
for m in $(ls -1d examples/*/)
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/dispatcher.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Pull Request Dispatcher

on:
issue_comment:
types:
- created

jobs:
slash_command_dispatch:
name: Slash Command Dispatcher
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Slash Command Dispatch
uses: peter-evans/slash-command-dispatch@a28ee6cd74d5200f99e247ebc7b365c03ae0ef3c # v3.0.1
with:
# The `public_repo` scope is required by this token to create repository_dispatch and workflow_dispatch
# events on public repositories. The default GITHUB_TOKEN does not support the `public_repo` scope.
token: ${{ secrets.GH_DISPATCH_TOKEN }}
reaction-token: ${{ secrets.GITHUB_TOKEN }}
commands: |
test
destroy
help
permission: maintain
issue-type: pull-request
event-type-suffix: -command

208 changes: 208 additions & 0 deletions .github/workflows/handler-destroy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,208 @@
name: Pull Request Destroy Handler

on:
repository_dispatch:
types:
- destroy-command

jobs:
public_active_active:
uses: hashicorp/terraform-random-tfe-utility/.github/workflows/destroy.yml@main
secrets: inherit
name: Destroy Public Active/Active
if: ${{ github.event.client_payload.slash_command.args.unnamed.all == 'all' || github.event.client_payload.slash_command.args.unnamed.all == 'public-active-active' }}
with:
cloud: Azure
test_name: Public Active/Active
utility_test: false
is_replicated_deployment: false
module_repository_id: hashicorp/terraform-azurerm-terraform-enterprise
pull_request_repo_name: ${{ github.event.client_payload.github.payload.repository.full_name }}
pull_request_ref: ${{ github.event.client_payload.pull_request.head.sha }}
pull_request_comment_id: ${{ github.event.client_payload.github.payload.comment.id }}
work_dir: ./tests/public-active-active
TFC_token_secret_name: PUBLIC_ACTIVE_ACTIVE_TFC_TOKEN

private_active_active:
uses: hashicorp/terraform-random-tfe-utility/.github/workflows/destroy.yml@main
secrets: inherit
name: Destroy Private Active/Active
if: ${{ github.event.client_payload.slash_command.args.unnamed.all == 'all' || github.event.client_payload.slash_command.args.unnamed.all == 'private-active-active' }}
with:
cloud: Azure
test_name: Private Active/Active
utility_test: false
is_replicated_deployment: false
module_repository_id: hashicorp/terraform-azurerm-terraform-enterprise
pull_request_repo_name: ${{ github.event.client_payload.github.payload.repository.full_name }}
pull_request_ref: ${{ github.event.client_payload.pull_request.head.sha }}
pull_request_comment_id: ${{ github.event.client_payload.github.payload.comment.id }}
work_dir: ./tests/private-active-active
TFC_token_secret_name: PRIVATE_ACTIVE_ACTIVE_TFC_TOKEN

private_tcp_active_active:
uses: hashicorp/terraform-random-tfe-utility/.github/workflows/destroy.yml@main
secrets: inherit
name: Destroy Private TCP Active/Active
if: ${{ github.event.client_payload.slash_command.args.unnamed.all == 'all' || github.event.client_payload.slash_command.args.unnamed.all == 'private-tcp-active-active' }}
with:
cloud: Azure
test_name: Private TCP Active/Active
utility_test: false
is_replicated_deployment: false
module_repository_id: hashicorp/terraform-azurerm-terraform-enterprise
pull_request_repo_name: ${{ github.event.client_payload.github.payload.repository.full_name }}
pull_request_ref: ${{ github.event.client_payload.pull_request.head.sha }}
pull_request_comment_id: ${{ github.event.client_payload.github.payload.comment.id }}
work_dir: ./tests/private-tcp-active-active
TFC_token_secret_name: PRIVATE_TCP_ACTIVE_ACTIVE_TFC_TOKEN

standalone_external:
uses: hashicorp/terraform-random-tfe-utility/.github/workflows/destroy.yml@main
secrets: inherit
name: Destroy Standalone External
if: ${{ github.event.client_payload.slash_command.args.unnamed.all == 'all' || github.event.client_payload.slash_command.args.unnamed.all == 'standalone-external' }}
with:
cloud: Azure
test_name: Standalone External
utility_test: false
is_replicated_deployment: false
module_repository_id: hashicorp/terraform-azurerm-terraform-enterprise
pull_request_repo_name: ${{ github.event.client_payload.github.payload.repository.full_name }}
pull_request_ref: ${{ github.event.client_payload.pull_request.head.sha }}
pull_request_comment_id: ${{ github.event.client_payload.github.payload.comment.id }}
work_dir: ./tests/standalone-external
TFC_token_secret_name: STANDALONE_EXTERNAL_TFC_TOKEN
TFC_workspace_substitution_pattern: 's/terraform {/terraform {\n\
backend "remote" {\n\
organization = "terraform-enterprise-modules-test"\n\
workspaces {\n\
name = "azure-standalone-external"\n\
}\n\
}\n/'

standalone_mounted_disk:
uses: hashicorp/terraform-random-tfe-utility/.github/workflows/destroy.yml@main
secrets: inherit
name: Destroy Standalone Mounted Disk
if: ${{ github.event.client_payload.slash_command.args.unnamed.all == 'all' || github.event.client_payload.slash_command.args.unnamed.all == 'standalone-mounted-disk' }}
with:
cloud: Azure
test_name: Standalone Mounted Disk
utility_test: false
is_replicated_deployment: false
module_repository_id: hashicorp/terraform-azurerm-terraform-enterprise
pull_request_repo_name: ${{ github.event.client_payload.github.payload.repository.full_name }}
pull_request_ref: ${{ github.event.client_payload.pull_request.head.sha }}
pull_request_comment_id: ${{ github.event.client_payload.github.payload.comment.id }}
work_dir: ./tests/standalone-mounted-disk
TFC_token_secret_name: STANDALONE_MOUNTED_DISK_TFC_TOKEN
TFC_workspace_substitution_pattern: 's/terraform {/terraform {\n\
backend "remote" {\n\
organization = "terraform-enterprise-modules-test"\n\
workspaces {\n\
name = "azure-standalone-mounted-disk"\n\
}\n\
}\n/'

public_active_active_replicated:
uses: hashicorp/terraform-random-tfe-utility/.github/workflows/destroy.yml@main
secrets: inherit
name: Destroy Public Active/Active
if: ${{ github.event.client_payload.slash_command.args.unnamed.all == 'all' || github.event.client_payload.slash_command.args.unnamed.all == 'public-active-active-replicated' }}
with:
cloud: Azure
test_name: Public Active/Active
utility_test: false
is_replicated_deployment: true
module_repository_id: hashicorp/terraform-azurerm-terraform-enterprise
pull_request_repo_name: ${{ github.event.client_payload.github.payload.repository.full_name }}
pull_request_ref: ${{ github.event.client_payload.pull_request.head.sha }}
pull_request_comment_id: ${{ github.event.client_payload.github.payload.comment.id }}
work_dir: ./tests/public-active-active
TFC_token_secret_name: PUBLIC_ACTIVE_ACTIVE_REPLICATED_TFC_TOKEN
TFC_workspace_substitution_pattern: s/azure-public-active-active/azure-public-active-active-replicated/

private_active_active_replicated:
uses: hashicorp/terraform-random-tfe-utility/.github/workflows/destroy.yml@main
secrets: inherit
name: Destroy Private Active/Active
if: ${{ github.event.client_payload.slash_command.args.unnamed.all == 'all' || github.event.client_payload.slash_command.args.unnamed.all == 'private-active-active-replicated' }}
with:
cloud: Azure
test_name: Private Active/Active
utility_test: false
is_replicated_deployment: true
module_repository_id: hashicorp/terraform-azurerm-terraform-enterprise
pull_request_repo_name: ${{ github.event.client_payload.github.payload.repository.full_name }}
pull_request_ref: ${{ github.event.client_payload.pull_request.head.sha }}
pull_request_comment_id: ${{ github.event.client_payload.github.payload.comment.id }}
work_dir: ./tests/private-active-active
TFC_token_secret_name: PRIVATE_ACTIVE_ACTIVE_REPLICATED_TFC_TOKEN
TFC_workspace_substitution_pattern: s/azure-private-active-active/azure-private-active-active-replicated/

private_tcp_active_active_replicated:
uses: hashicorp/terraform-random-tfe-utility/.github/workflows/destroy.yml@main
secrets: inherit
name: Destroy Private TCP Active/Active
if: ${{ github.event.client_payload.slash_command.args.unnamed.all == 'all' || github.event.client_payload.slash_command.args.unnamed.all == 'private-tcp-active-active-replicated' }}
with:
cloud: Azure
test_name: Private TCP Active/Active
utility_test: false
is_replicated_deployment: true
module_repository_id: hashicorp/terraform-azurerm-terraform-enterprise
pull_request_repo_name: ${{ github.event.client_payload.github.payload.repository.full_name }}
pull_request_ref: ${{ github.event.client_payload.pull_request.head.sha }}
pull_request_comment_id: ${{ github.event.client_payload.github.payload.comment.id }}
work_dir: ./tests/private-tcp-active-active
TFC_token_secret_name: PRIVATE_TCP_ACTIVE_ACTIVE_REPLICATED_TFC_TOKEN
TFC_workspace_substitution_pattern: s/azure-private-tcp-active-active/azure-private-tcp-active-active-replicated/

standalone_external_replicated:
uses: hashicorp/terraform-random-tfe-utility/.github/workflows/destroy.yml@main
secrets: inherit
name: Destroy Standalone External
if: ${{ github.event.client_payload.slash_command.args.unnamed.all == 'all' || github.event.client_payload.slash_command.args.unnamed.all == 'standalone-external-replicated' }}
with:
cloud: Azure
test_name: Standalone External
utility_test: false
is_replicated_deployment: true
module_repository_id: hashicorp/terraform-azurerm-terraform-enterprise
pull_request_repo_name: ${{ github.event.client_payload.github.payload.repository.full_name }}
pull_request_ref: ${{ github.event.client_payload.pull_request.head.sha }}
pull_request_comment_id: ${{ github.event.client_payload.github.payload.comment.id }}
work_dir: ./tests/standalone-external
TFC_token_secret_name: STANDALONE_EXTERNAL_REPLICATED_TFC_TOKEN
TFC_workspace_substitution_pattern: 's/terraform {/terraform {\n\
backend "remote" {\n\
organization = "terraform-enterprise-modules-test"\n\
workspaces {\n\
name = "azure-standalone-external-replicated"\n\
}\n\
}\n/'

standalone_mounted_disk_replicated:
uses: hashicorp/terraform-random-tfe-utility/.github/workflows/destroy.yml@main
secrets: inherit
name: Destroy Standalone Mounted Disk
if: ${{ github.event.client_payload.slash_command.args.unnamed.all == 'all' || github.event.client_payload.slash_command.args.unnamed.all == 'standalone-mounted-disk-replicated' }}
with:
cloud: Azure
test_name: Standalone Mounted Disk
utility_test: false
is_replicated_deployment: true
module_repository_id: hashicorp/terraform-azurerm-terraform-enterprise
pull_request_repo_name: ${{ github.event.client_payload.github.payload.repository.full_name }}
pull_request_ref: ${{ github.event.client_payload.pull_request.head.sha }}
pull_request_comment_id: ${{ github.event.client_payload.github.payload.comment.id }}
work_dir: ./tests/standalone-mounted-disk
TFC_token_secret_name: STANDALONE_MOUNTED_DISK_REPLICATED_TFC_TOKEN
TFC_workspace_substitution_pattern: 's/terraform {/terraform {\n\
backend "remote" {\n\
organization = "terraform-enterprise-modules-test"\n\
workspaces {\n\
name = "azure-standalone-mounted-disk-replicated"\n\
}\n\
}\n/'
43 changes: 43 additions & 0 deletions .github/workflows/handler-help.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Pull Request Help Handler

on:
repository_dispatch:
types:
- help-command

jobs:
help:
name: Run help
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Update comment
uses: peter-evans/create-or-update-comment@67dcc547d311b736a8e6c5c236542148a47adc3d # v2.1.1
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
body: |
> | Command | Description |
> | ------- | ----------- |
> | /test <all\|test case name...> [destroy=false] | Run the Terraform test workflow on the modules in the tests/ directory. Unnamed arguments can be "all" to run all test cases or specific test case names to only run selected cases. The named argument "destroy=false" will disable the destruction of test infrastructure for debugging purposes. |
> | /destroy <all\|test case name...> | Destroy any resources that may still be in Terraform state from previous tests. Unnamed arguments can be "all" to destroy all resources from all test cases or specific test case names to only destroy selected test case resources. |
> | /help | Shows this help message |
>
> ## Test Case Names
>
> ### FDO
> * private-active-active
> * private-tcp-active-active
> * public-active-active
> * standalone-external
> * standalone-mounted-disk
>
> ### Replicated
> * private-active-active-replicated
> * private-tcp-active-active-replicated
> * public-active-active-replicated
> * standalone-external-replicated
> * standalone-mounted-disk-replicated
reaction-type: confused
Loading

0 comments on commit cf7b4af

Please sign in to comment.