Skip to content

Commit

Permalink
chore: add docs and lint targets
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneswuerbach committed Jan 2, 2024
1 parent 3388456 commit 136d050
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,10 @@ jobs:

- name: Terraform Validate
run: make validate

- uses: terraform-linters/setup-tflint@v4
with:
tflint_version: v0.49.0

- name: Lint
run: make lint
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.idea
.terraform
.terraform.lock.hcl
*.tfstate
*.tfstate.*
*.tfplan
*.terraformrc
*.tfvars
terraform.rc
*.json
.DS_Store
*.bkp
*.dtmp
.source
10 changes: 10 additions & 0 deletions .tflint.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
plugin "terraform" {
enabled = true
preset = "recommended"
}

plugin "google" {
enabled = true
version = "0.26.0"
source = "github.com/terraform-linters/tflint-ruleset-google"
}
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
TF_DIRS = $(patsubst %/main.tf, %, $(shell find . -type d -name .terraform -prune -o -name 'main.tf' -print))
VALIDATE_TF_DIRS = $(addprefix validate-,$(TF_DIRS))
LINT_TF_DIRS = $(addprefix lint-,$(TF_DIRS))
DOCS_TF_DIRS = $(addprefix docs-,$(TF_DIRS))

# Generate docs for a terraform directories
Expand Down Expand Up @@ -30,3 +31,16 @@ $(VALIDATE_TF_DIRS): validate-%:
# Validate all terraform directories
validate: $(VALIDATE_TF_DIRS)
@echo "All validated"

# Lint a terraform directories
$(LINT_TF_DIRS): lint-%:
@echo "Lint $*"
tflint --config "$(PWD)/.tflint.hcl" --chdir="$*"

# Initialize tflint
lint-init:
tflint --init

# Lint all terraform directories
lint: lint-init $(LINT_TF_DIRS)
@echo "All linted"

0 comments on commit 136d050

Please sign in to comment.