Skip to content

Commit 586c023

Browse files
committed
Improve CircleCI testing
1 parent 795d87b commit 586c023

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

.circleci/config.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,17 @@ jobs:
99
- checkout
1010
- run:
1111
name: Validate tf files (terraform validate)
12-
command: find . -type f -name "*.tf" -exec dirname {} \;|sort -u | while read m; do (terraform validate -check-variables=false "$m" && echo "√ $m") || exit 1 ; done
12+
command: |
13+
find . -type f -name "*.tf" -exec dirname {} \;|sort -u | while read m; do (terraform validate -check-variables=false "$m" && echo "√ $m") || exit 1 ; done
1314
- run:
1415
name: check if all tf files are formatted (terraform fmt)
15-
command: if [ `terraform fmt | wc -c` -ne 0 ]; then echo "Some terraform files need be formatted, run 'terraform fmt' to fix"; exit 1; fi
16+
command: |
17+
if [ `terraform fmt --list=true -diff=true -write=false | tee format-issues | wc -c` -ne 0 ]; then
18+
echo "Some terraform files need be formatted, run 'terraform fmt' to fix"
19+
echo "Formatting issues:"
20+
cat format-issues
21+
exit 1
22+
fi
1623
- run:
1724
name: "Install: tflint"
1825
command: |
@@ -24,7 +31,9 @@ jobs:
2431
install tflint /usr/local/tflint/bin
2532
- run:
2633
name: "tflint check"
27-
command: /usr/local/tflint/bin/tflint
34+
command: |
35+
terraform init
36+
/usr/local/tflint/bin/tflint
2837
2938
workflows:
3039
version: 2

0 commit comments

Comments
 (0)