Skip to content

Commit

Permalink
update terratest pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
dhyanio committed Oct 20, 2020
1 parent 7283c80 commit 173f604
Show file tree
Hide file tree
Showing 10 changed files with 326 additions and 639 deletions.
42 changes: 23 additions & 19 deletions .github/workflows/readme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- master

jobs:
readme-create:
name: 'readme-create'
Expand All @@ -16,34 +17,37 @@ jobs:
with:
python-version: '3.x'

- name: 'Install test dependencies.'
run: pip install yamllint
- name: 'create readme'
uses: 'clouddrove/github-actions@v4.0'
with:
actions_subcommand: 'readme'
github_token: '${{ secrets.GITHUB}}'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}


- name: Run yamllint.
run: yamllint ./README.yaml
- name: pre-commit check errors
uses: pre-commit/action@v2.0.0
continue-on-error: true

- name: clone Genie repo
run: |
export GITHUB_ACCESS_TOKEN=${{ secrets.GITHUB }}
cd .. && cd .. && cd ..
git clone https://${{ secrets.GITHUB }}@github.com/clouddrove/genie.git
cd /home/runner/work/terraform-aws-ec2/terraform-aws-ec2
make packages/install/gomplate
make readme
- name: pre-commit fix erros
uses: pre-commit/action@v2.0.0
continue-on-error: true

- name: push to repo back
run: |
git config --global user.email "anmol@clouddrove.com"
git config --global user.name "Anmol nagpal"
git add . && git commit -m "upload"
git push origin master
- name: 'push readme'
uses: 'clouddrove/github-actions@v4.0'
continue-on-error: true
with:
actions_subcommand: 'push'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN}}

- name: 'Slack Notification'
uses: clouddrove/action-slack@v2
with:
status: ${{ job.status }}
fields: repo,author
author_name: 'Clouddrove'
author_name: 'CloudDrove'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TERRAFORM }} # required
Expand Down
94 changes: 36 additions & 58 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
@@ -1,93 +1,71 @@
name: 'Terraform GitHub Actions'
on:
- push
pull_request:
branches:
- master

jobs:
terraform:
name: 'Terraform'
runs-on: ubuntu-latest
steps:

- name: 'Checkout'
uses: actions/checkout@master

- name: 'Terraform Format fmt'
uses: hashicorp/terraform-github-actions@master
with:
tf_actions_version: 0.13.4
tf_actions_subcommand: 'fmt'
tf_actions_working_dir: "./_example/basic_example"
tf_actions_comment: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: 'Terraform Format fmt'
uses: hashicorp/terraform-github-actions@master
with:
tf_actions_version: 0.13.4
tf_actions_subcommand: 'fmt'
tf_actions_working_dir: "./_example/secure_example"
tf_actions_comment: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}


- 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: Set up Go 1.13
uses: actions/setup-go@v1
- name: 'Terraform Format'
uses: 'clouddrove/github-actions@v4.0'
with:
go-version: 1.13
id: go
actions_subcommand: 'fmt'

- name: Get dependencies
run: |
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
else
go get -v -t -d ./...
fi
- name: 'Terraform init Basic'
uses: 'clouddrove/github-actions@v4.0'
with:
actions_subcommand: 'init'
tf_actions_working_dir: ./_example/basic_example

- name: Test Basic Example
working-directory: ./_test/basic_example
run: go test
- name: 'Terraform validate Basic'
uses: 'clouddrove/github-actions@v4.0'
with:
actions_subcommand: 'validate'
tf_actions_working_dir: ./_example/basic_example

- name: Test Secure Example
working-directory: ./_test/secure_example
run: go test
- name: 'Terraform plan Basic'
uses: 'clouddrove/github-actions@v4.0'
with:
actions_subcommand: 'plan'
tf_actions_working_dir: ./_example/basic_example

- name: 'Terraform Init Baic Example'
uses: hashicorp/terraform-github-actions@master
- name: 'Terraform init Secure'
uses: 'clouddrove/github-actions@v4.0'
with:
tf_actions_version: 0.13.4
tf_actions_subcommand: 'init'
tf_actions_working_dir: "./_example/basic_example"
tf_actions_comment: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
actions_subcommand: 'init'
tf_actions_working_dir: ./_example/secure_example

- name: 'Terraform Init Secure Example'
uses: hashicorp/terraform-github-actions@master
- name: 'Terraform validate Secure'
uses: 'clouddrove/github-actions@v4.0'
with:
tf_actions_version: 0.13.4
tf_actions_subcommand: 'init'
tf_actions_working_dir: "./_example/secure_example"
tf_actions_comment: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
actions_subcommand: 'validate'
tf_actions_working_dir: ./_example/secure_example

- name: 'Terraform plan Secure'
uses: 'clouddrove/github-actions@v4.0'
with:
actions_subcommand: 'plan'
tf_actions_working_dir: ./_example/secure_example

- name: 'Slack Notification'
uses: clouddrove/action-slack@v2
with:
status: ${{ job.status }}
fields: repo,author
author_name: 'Clouddrove'
author_name: 'CloudDrove'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # required
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_TERRAFORM }} # required
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/terratest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: 'Terratest GitHub Actions'
on:
pull_request:
branches:
- master
types: [labeled]

jobs:
terraform:
name: 'Terraform'
runs-on: ubuntu-latest
steps:

- name: 'Checkout'
uses: actions/checkout@master

- 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 Basic'
if: ${{ github.event.label.name == 'terratest' }}
uses: 'clouddrove/github-actions@v4.0'
with:
actions_subcommand: 'terratest'
tf_actions_working_dir: '_test/basic_example'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: 'Terratest Secure'
if: ${{ github.event.label.name == 'terratest' }}
uses: 'clouddrove/github-actions@v4.0'
with:
actions_subcommand: 'terratest'
tf_actions_working_dir: '_test/secure_example'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- 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 .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
repos:
- repo: git://github.com/antonbabenko/pre-commit-terraform
rev: v1.12.0
rev: v1.43.0
hooks:
- id: terraform_fmt

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.0.0
rev: v3.2.0
hooks:
- id: check-merge-conflict
- id: check-yaml
Expand Down
Loading

0 comments on commit 173f604

Please sign in to comment.