Skip to content

Commit

Permalink
feat: add terratest.yml in workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
theprashantyadav committed May 11, 2023
1 parent 034d640 commit d39f5b3
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 22 deletions.
17 changes: 8 additions & 9 deletions .github/workflows/readme.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

name: 'Create README.md file'
on:
push:
Expand All @@ -11,9 +10,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Checkout'
uses: actions/checkout@v2.3.4
uses: actions/checkout@master

- name: Set up Python 3.7.
- name: 'Set up Python 3.7'
uses: actions/setup-python@v2
with:
python-version: '3.x'
Expand All @@ -22,16 +21,16 @@ jobs:
uses: 'clouddrove/github-actions@v9.0.2'
with:
actions_subcommand: 'readme'
github_token: '${{ secrets.GITHUB }}'
github_token: '${{ secrets.GITHUB}}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}


- name: pre-commit check errors
- name: 'pre-commit check errors'
uses: pre-commit/action@v2.0.0
continue-on-error: true

- name: pre-commit fix errors
- name: 'pre-commit fix erros'
uses: pre-commit/action@v2.0.0
continue-on-error: true

Expand All @@ -41,7 +40,7 @@ jobs:
with:
actions_subcommand: 'push'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}

- name: 'Slack Notification'
uses: clouddrove/action-slack@v2
Expand All @@ -52,4 +51,4 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TERRAFORM }} # required
if: always()
if: always()
4 changes: 3 additions & 1 deletion .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ jobs:
- ${{ needs.versionExtract.outputs.minVersion }}
- ${{ needs.versionExtract.outputs.maxVersion }}
directory:
- _example/
- _example/different-account
- _example/single-account

steps:
- name: Checkout
Expand All @@ -58,6 +59,7 @@ jobs:
- name: tflint
uses: reviewdog/action-tflint@master
with:
tflint_version: v0.29.0
github_token: ${{ secrets.GITHUB }}
working_directory: ${{ matrix.directory }}
fail_on_error: 'true'
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/terratest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: 'Terratest GitHub Actions'
on:
pull_request:
branches:
- master
types: [labeled]

jobs:
Terratest:
name: 'terratest'
runs-on: ubuntu-latest
steps:

- name: 'Checkout'
uses: actions/checkout@v2.3.4

- name: 'Configure AWS Credentials'
uses: clouddrove/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.TEST_AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.TEST_AWS_ACCESS_SECRET_KEY }}
aws-region: us-east-2

- name: 'terratest'
uses: 'clouddrove/github-actions@v9.0.2'
with:
actions_subcommand: 'terratest'
if: ${{ github.event.label.name == 'terratest' }}
tf_actions_working_dir: '_test'

- name: 'Slack Notification'
uses: clouddrove/action-slack@v2
with:
status: ${{ job.status }}
fields: repo,author
author_name: 'CloudDrove'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TERRAFORM }} # required
if: always()
4 changes: 2 additions & 2 deletions _example/different-account/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ provider "aws" {

module "vpc" {
source = "clouddrove/vpc/aws"
version = "0.15.1"
version = "1.3.0"

name = "vpc"
environment = "test"
Expand All @@ -14,7 +14,7 @@ module "vpc" {

module "subnets" {
source = "clouddrove/subnet/aws"
version = "0.15.3"
version = "1.3.0"

name = "subnets"
environment = "test"
Expand Down
1 change: 0 additions & 1 deletion _example/different-account/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

output "tags" {
value = module.transit-gateway.tags
description = "A mapping of tags to assign to the transit-gateway."
Expand Down
4 changes: 2 additions & 2 deletions _example/different-account/versions.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Terraform version
terraform {
required_version = ">= 0.14.11"
required_version = ">= 1.3.6"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.1.15"
version = ">= 4.48.0"
}
}
}
9 changes: 5 additions & 4 deletions _example/single-account/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ provider "aws" {

module "vpc" {
source = "clouddrove/vpc/aws"
version = "0.15.1"
version = "1.3.0"

name = "vpc"
environment = "test"
Expand All @@ -14,7 +14,7 @@ module "vpc" {

module "subnets" {
source = "clouddrove/subnet/aws"
version = "0.15.3"
version = "1.3.0"

name = "subnets"
environment = "test"
Expand All @@ -30,7 +30,7 @@ module "subnets" {

module "vpc-other" {
source = "clouddrove/vpc/aws"
version = "0.15.1"
version = "1.3.0"

name = "vpc"
environment = "test"
Expand All @@ -41,7 +41,8 @@ module "vpc-other" {

module "subnets-other" {
source = "clouddrove/subnet/aws"
version = "0.15.3"
version = "1.3.0"

name = "subnets"
environment = "test"
label_order = ["environment", "name"]
Expand Down
4 changes: 2 additions & 2 deletions _example/single-account/versions.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Terraform version
terraform {
required_version = ">= 0.14.11"
required_version = ">= 1.3.6"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.1.15"
version = ">= 4.48.0"
}
}
}
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# convention.
module "labels" {
source = "clouddrove/labels/aws"
version = "0.15.0"
version = "1.3.0"

enabled = var.enable
name = var.name
Expand Down

0 comments on commit d39f5b3

Please sign in to comment.