Skip to content

Commit 31276fe

Browse files
authored
Merge branch 'master' into fix-outputs
2 parents 7c95954 + 5d8f94b commit 31276fe

File tree

10 files changed

+344
-23
lines changed

10 files changed

+344
-23
lines changed

.chglog/config.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
style: github
23
template: CHANGELOG.tpl.md
34
info:

.github/workflows/linting.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
3+
###
4+
### Checks terraform-fmt coding style in terraform/ and terragrunt/
5+
###
6+
7+
name: linting
8+
on:
9+
pull_request:
10+
push:
11+
branches:
12+
- master
13+
tags:
14+
15+
jobs:
16+
lint:
17+
runs-on: ubuntu-latest
18+
strategy:
19+
fail-fast: False
20+
matrix:
21+
target:
22+
- terraform-fmt
23+
- lint-files
24+
25+
name: "[ ${{ matrix.target }} ]"
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@master
29+
30+
- name: Lint
31+
run: |
32+
make ${target} _WRITE=false
33+
env:
34+
target: ${{ matrix.target }}

Makefile

+89-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,95 @@
1-
.PHONY: changelog release
1+
ifneq (,)
2+
.error This Makefile requires GNU Make.
3+
endif
4+
5+
.PHONY: changelog release lint lint-files terraform-fmt _pull-tf _pull-fl
6+
CURRENT_DIR = $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
7+
8+
# -------------------------------------------------------------------------------------------------
9+
# Docker image versions
10+
# -------------------------------------------------------------------------------------------------
11+
TF_VERSION = 0.12.31
12+
FL_VERSION = 0.4
13+
14+
FL_IGNORES = .git/,.github/,*/.terraform/,.idea/,.chglog/
15+
16+
17+
# -------------------------------------------------------------------------------------------------
18+
# Read-only Targets
19+
# -------------------------------------------------------------------------------------------------
20+
21+
lint:
22+
@$(MAKE) --no-print-directory terraform-fmt-tf _WRITE=false
23+
@$(MAKE) --no-print-directory lint-files
24+
25+
lint-files: _pull-fl
26+
@echo "################################################################################"
27+
@echo "# file-lint"
28+
@echo "################################################################################"
29+
@docker run --rm $$(tty -s && echo "-it" || echo) -v $(CURRENT_DIR):/data cytopia/file-lint:$(FL_VERSION) file-cr --text --ignore '$(FL_IGNORES)' --path .
30+
@docker run --rm $$(tty -s && echo "-it" || echo) -v $(CURRENT_DIR):/data cytopia/file-lint:$(FL_VERSION) file-crlf --text --ignore '$(FL_IGNORES)' --path .
31+
@docker run --rm $$(tty -s && echo "-it" || echo) -v $(CURRENT_DIR):/data cytopia/file-lint:$(FL_VERSION) file-trailing-single-newline --text --ignore '$(FL_IGNORES)' --path .
32+
@docker run --rm $$(tty -s && echo "-it" || echo) -v $(CURRENT_DIR):/data cytopia/file-lint:$(FL_VERSION) file-trailing-space --text --ignore '$(FL_IGNORES)' --path .
33+
@docker run --rm $$(tty -s && echo "-it" || echo) -v $(CURRENT_DIR):/data cytopia/file-lint:$(FL_VERSION) file-utf8 --text --ignore '$(FL_IGNORES)' --path .
34+
@docker run --rm $$(tty -s && echo "-it" || echo) -v $(CURRENT_DIR):/data cytopia/file-lint:$(FL_VERSION) file-utf8-bom --text --ignore '$(FL_IGNORES)' --path .
35+
36+
37+
terraform-fmt:
38+
@$(MAKE) --no-print-directory terraform-fmt-tf _WRITE=true
39+
40+
terraform-fmt-tf: _WRITE=true
41+
terraform-fmt-tf: _pull-tf
42+
@# Lint all Terraform files
43+
@echo "################################################################################"
44+
@echo "# Terraform fmt"
45+
@echo "################################################################################"
46+
@echo
47+
@echo "------------------------------------------------------------"
48+
@echo "# *.tf files"
49+
@echo "------------------------------------------------------------"
50+
@if docker run $$(tty -s && echo "-it" || echo) --rm \
51+
-v "$(PWD):/data" hashicorp/terraform:$(TF_VERSION) fmt \
52+
$$(test "$(_WRITE)" = "false" && echo "-check" || echo "-write=true") \
53+
-diff \
54+
-list=true \
55+
-recursive \
56+
/data; then \
57+
echo "OK"; \
58+
else \
59+
echo "Failed"; \
60+
exit 1; \
61+
fi;
62+
@echo
63+
@echo "------------------------------------------------------------"
64+
@echo "# *.tfvars files"
65+
@echo "------------------------------------------------------------"
66+
@if docker run $$(tty -s && echo "-it" || echo) --rm --entrypoint=/bin/sh \
67+
-v "$(PWD):/data" hashicorp/terraform:$(TF_VERSION) \
68+
-c "find . -not \( -path './*/.terragrunt-cache/*' -o -path './*/.terraform/*' \) \
69+
-name '*.tfvars' -type f -print0 \
70+
| xargs -0 -n1 terraform fmt \
71+
$$(test '$(_WRITE)' = 'false' && echo '-check' || echo '-write=true') \
72+
-diff \
73+
-list=true"; then \
74+
echo "OK"; \
75+
else \
76+
echo "Failed"; \
77+
exit 1; \
78+
fi;
79+
@echo
280

381
changelog:
482
git-chglog -o CHANGELOG.md --next-tag `semtag final -s minor -o`
583

684
release:
785
semtag final -s minor
86+
87+
# -------------------------------------------------------------------------------------------------
88+
# Helper Targets
89+
# -------------------------------------------------------------------------------------------------
90+
91+
_pull-tf:
92+
docker pull hashicorp/terraform:$(TF_VERSION)
93+
94+
_pull-fl:
95+
docker pull cytopia/file-lint:$(FL_VERSION)

0 commit comments

Comments
 (0)