Skip to content

Commit

Permalink
BBL-440 | updating circleci config to run pre-commit format + tf-docs…
Browse files Browse the repository at this point in the history
… - slack notif updated
  • Loading branch information
exequielrafaela committed Nov 13, 2020
1 parent 49fc58e commit f1124d0
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 9 deletions.
34 changes: 29 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,30 @@ jobs:
git update-index --assume-unchanged "Makefile"
- run:
name: Validate Terraform format
command: make format-check
name: test-dependencies
command: |
#
# Install pre-commit
pip install pre-commit
#
# Install terraform
sudo apt-get install unzip
wget https://releases.hashicorp.com/terraform/${TERRAFORM_VER}/terraform_${TERRAFORM_VER}_linux_amd64.zip
unzip terraform_${TERRAFORM_VER}_linux_amd64.zip
sudo mv terraform /usr/local/bin/
terraform --version
#
# Install terraform-docs
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
curl -Lo ./terraform-docs https://github.com/terraform-docs/terraform-docs/releases/download/v0.10.1/terraform-docs-v0.10.1-$(uname | tr '[:upper:]' '[:lower:]')-amd64
chmod +x ./terraform-docs
sudo mv ./terraform-docs /usr/local/bin/terraform-docs
- run:
name: test1-terraform-format-and-docs
command: |
cd modules/delegated-admin && make pre-commit && cd ..
cd modules/multiaccount-setup && make pre-commit
- run:
name: Install awscli
Expand Down Expand Up @@ -55,9 +77,10 @@ jobs:
cp /home/circleci/.aws/config /home/circleci/.aws/bb/config
- run:
name: Lint Terraform code
command: make tflint-deep

name: test2-terraform-linting
command: |
cd modules/delegated-admin && make tflint-deep && cd ..
cd modules/multiaccount-setup && make tflint-deep
#
# Release
Expand Down Expand Up @@ -107,6 +130,7 @@ jobs:
#
orbs:
sumologic: circleci/sumologic@1.0.6
slack: circleci/slack@4.1.1

#
# Jobs workflow
Expand Down
48 changes: 48 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# EditorConfig is awesome: https://EditorConfig.org

# we have to set line endings to LF for all bash scripts, otherwise, if you save
# a script on Windows, it would have CRLF line breaks, which doesn’t work on
# Linux. This is achieved by a combination of ‘.editorconfig’ defining how the
# code is displayed in a text editor, and ‘.gitatttributes’, which controls how
# the file is saved in source control.

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file && 2 space indentation
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = 80
trim_trailing_whitespace = true

# Unix-style newlines with a newline ending every file && 2 space indentation
[*.sh]
end_of_line = lf
indent_style = space
indent_size = 2

# Unix-style newlines with a newline ending every file && 2 space indentation
[*.py]
end_of_line = lf
indent_style = space
indent_size = 2

[*.{tf,tfvars}]
indent_size = 2
indent_style = space

[*.md]
max_line_length = 0
trim_trailing_whitespace = false

# Tab indentation && 2 space indentation
[Makefile]
tab_width = 2
indent_style = tab

[COMMIT_EDITMSG]
max_line_length = 0
5 changes: 2 additions & 3 deletions .gitallowed
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# https://github.com/awslabs/git-secrets
README.md
/modules/delegated-admin/README.md
/modules/multiaccount-setup/README.md
*README.md
examples/*/main.tf
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
!/.github
!*.gitkeep
!*.editorconfig
!*.pre-commit-config.yaml

# SSH keys #
############
Expand Down
24 changes: 24 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
default_language_version:
# force all unspecified python hooks to run python3
python: python3

repos:
- repo: git://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: check-json
- id: check-merge-conflict
- id: check-yaml
- id: detect-private-key
- id: pretty-format-json
args:
- --autofix
- id: trailing-whitespace
args:
- --markdown-linebreak-ext=md

- repo: git://github.com/antonbabenko/pre-commit-terraform
rev: v1.43.0
hooks:
- id: terraform_fmt
- id: terraform_docs
2 changes: 1 addition & 1 deletion examples/configure-guardduty/main.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Configure GuardDuty: this is intended to be done from an account that has
# been designated to be a GuardDuty delegated admin.
#
#
# Important: since designating a GuardDuty delegated admin account automatically
# enables GuardDuty in that account, you will need to import
# "module.guardduty.aws_guardduty_detector.this" before you can properly use
Expand Down
1 change: 1 addition & 0 deletions modules/delegated-admin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ No requirements.
## Outputs

No output.

<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
3 changes: 3 additions & 0 deletions modules/delegated-admin/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MAKEFILES_DIR := ../../@bin/makefiles

-include ${MAKEFILES_DIR}/terratest13/terratest13.mk
1 change: 1 addition & 0 deletions modules/multiaccount-setup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ No requirements.
## Outputs

No output.

<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
3 changes: 3 additions & 0 deletions modules/multiaccount-setup/makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MAKEFILES_DIR := ../../@bin/makefiles

-include ${MAKEFILES_DIR}/terratest13/terratest13.mk

0 comments on commit f1124d0

Please sign in to comment.