Skip to content

Commit

Permalink
Merge pull request #1 from rhythmictech/modernize
Browse files Browse the repository at this point in the history
total redo
  • Loading branch information
cdaniluk committed Jan 11, 2021
2 parents 99a27f8 + 1b43e47 commit def9598
Show file tree
Hide file tree
Showing 22 changed files with 851 additions and 203 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @rhythmictech/engineering
23 changes: 23 additions & 0 deletions .github/workflows/misspell.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: misspell
on:
push:
branches:
- main
- master
- prod
- develop

jobs:
misspell:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: misspell
uses: reviewdog/action-misspell@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
locale: "US"
reporter: github-check
filter_mode: nofilter
level: error
43 changes: 43 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
name: pre-commit-check
on:
push:
branches: -- main
- master
- prod
- develop

jobs:
pre-commit-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
- name: Install prerequisites
run: ./bin/install-ubuntu.sh
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: ~0.13.5
- name: initialize Terraform
run: terraform init --backend=false
- name: pre-commit
uses: pre-commit/action@v2.0.0
env:
AWS_DEFAULT_REGION: us-east-1
# many of these are covered by better reviewdog linters below
SKIP: >-
terraform_tflint_deep,
no-commit-to-branch,
terraform_tflint_nocreds,
terraform_tfsec
- uses: stefanzweifel/git-auto-commit-action@v4
if: ${{ failure() }}
with:
commit_message: Apply automatic changes
commit_options: "--no-verify"
# Optional commit user and author settings
commit_user_name: Linter Bot
commit_user_email: noreply@rhythmictech.com
commit_author: Linter Bot <actions@github.com>
98 changes: 98 additions & 0 deletions .github/workflows/pullRequest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
---
name: pull request
on:
pull_request:

jobs:
# TODO: #22 add job using https://github.com/reviewdog/action-alex
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
- name: Install prerequisites
run: ./bin/install-ubuntu.sh
- name: Setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: ~0.13.5
- name: initialize Terraform
run: terraform init --backend=false
- name: pre-commit
uses: pre-commit/action@v2.0.0
env:
AWS_DEFAULT_REGION: us-east-1
# many of these are covered by better reviewdog linters below
SKIP: >-
terraform_tflint_deep,
no-commit-to-branch,
terraform_tflint_nocreds,
terraform_tfsec
- uses: stefanzweifel/git-auto-commit-action@v4
if: ${{ failure() }}
with:
commit_message: Apply automatic changes
commit_options: "--no-verify"
# Optional commit user and author settings
commit_user_name: Linter Bot
commit_user_email: noreply@rhythmictech.com
commit_author: Linter Bot <actions@github.com>
tflint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: ~0.13.5
- name: Terraform init
run: terraform init --backend=false
- name: tflint
uses: reviewdog/action-tflint@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-check
filter_mode: added
flags: --module
level: error
tfsec:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: ~0.13.5
- name: Terraform init
run: terraform init --backend=false
- name: tfsec
uses: reviewdog/action-tfsec@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-check
filter_mode: added
level: warning
misspell:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: misspell
uses: reviewdog/action-misspell@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
locale: "US"
reporter: github-pr-check
filter_mode: added
level: error
yamllint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: yamllint
uses: reviewdog/action-yamllint@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-pr-check
filter_mode: added
level: error
29 changes: 29 additions & 0 deletions .github/workflows/tflint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: tflint
on:
push:
branches:
- main
- master
- prod
- develop

jobs:
tflint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: ~0.13.5
- name: Terraform init
run: terraform init --backend=false
- name: tflint
uses: reviewdog/action-tflint@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-check
filter_mode: nofilter
flags: --module
level: error
28 changes: 28 additions & 0 deletions .github/workflows/tfsec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
name: tfsec
on:
push:
branches:
- main
- master
- prod
- develop

jobs:
tfsec:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: setup Terraform
uses: hashicorp/setup-terraform@v1
with:
terraform_version: ~0.13.5
- name: Terraform init
run: terraform init --backend=false
- name: tfsec
uses: reviewdog/action-tfsec@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-check
filter_mode: nofilter
level: error
22 changes: 22 additions & 0 deletions .github/workflows/yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: yamllint
on:
push:
branches:
- main
- master
- prod
- develop

jobs:
yamllint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: yamllint
uses: reviewdog/action-yamllint@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
reporter: github-check
filter_mode: nofilter
level: error
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Local .terraform directories
**/.terraform/*

# .tfstate files
*.tfstate
*.tfstate.*

# .tfvars files
*.tfvars
72 changes: 72 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
repos:
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.45.0
hooks:
- id: terraform_docs
always_run: true
args:
- --args=--sort-by-required
- id: terraform_fmt
- id: terraform_tflint
alias: terraform_tflint_deep
name: terraform_tflint_deep
args:
- --args=--deep
- id: terraform_tflint
alias: terraform_tflint_nocreds
name: terraform_tflint_nocreds
- id: terraform_tfsec
- repo: local
hooks:
- id: terraform_validate
name: terraform_validate
entry: |
bash -c '
AWS_DEFAULT_REGION=us-east-1
declare -a DIRS
for FILE in "$@"
do
DIRS+=($(dirname "$FILE"))
done
for DIR in $(printf "%s\n" "${DIRS[@]}" | sort -u)
do
cd $(dirname "$FILE")
terraform init --backend=false
terraform validate .
cd ..
done
'
language: system
verbose: true
files: \.tf(vars)?$
exclude: examples
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.3.0
hooks:
- id: check-case-conflict
- id: check-json
- id: check-merge-conflict
- id: check-symlinks
- id: check-yaml
args:
- --unsafe
- id: end-of-file-fixer
- id: mixed-line-ending
args:
- --fix=lf
- id: no-commit-to-branch
args:
- --branch
- main
- --branch
- master
- --branch
- prod
- id: pretty-format-json
args:
- --autofix
- --top-keys=name,Name
- id: trailing-whitespace
args:
- --markdown-linebreak-ext=md
exclude: README.md
45 changes: 45 additions & 0 deletions .tflint.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
config {
module = true
deep_check = false
}

rule "terraform_deprecated_interpolation" {
enabled = true
}

rule "terraform_unused_declarations" {
enabled = true
}

rule "terraform_comment_syntax" {
enabled = true
}

rule "terraform_documented_outputs" {
enabled = true
}

rule "terraform_documented_variables" {
enabled = true
}

rule "terraform_typed_variables" {
enabled = true
}

rule "terraform_module_pinned_source" {
enabled = true
}

rule "terraform_naming_convention" {
enabled = true
format = "snake_case"
}

rule "terraform_required_version" {
enabled = true
}

rule "terraform_required_providers" {
enabled = true
}
2 changes: 2 additions & 0 deletions .yamllint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
truthy:
check-keys: false
Loading

0 comments on commit def9598

Please sign in to comment.