From a5183ccf2687256c64af8bb306eac77e7eec6c31 Mon Sep 17 00:00:00 2001 From: Bill Wang Date: Sat, 12 Aug 2017 19:59:22 +1000 Subject: [PATCH] Add circle ci pipeline to validate the codes automatically --- .circleci/config.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 .circleci/config.yml diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 0000000..5e34079 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,29 @@ +version: 2 + +jobs: + build: + docker: + - image: hashicorp/terraform:0.10.0 + entrypoint: /bin/sh + steps: + - checkout + - run: + name: validate tf files (terraform validate) + 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 + - run: + name: check if all tf files are formatted (terraform fmt) + command: if [ `terraform fmt | wc -c` -ne 0 ]; then echo "Some terraform files need be formatted, run 'terraform fmt' to fix"; exit 1; fi + - run: + name: "get tflint" + command: apk add wget ; wget https://github.com/wata727/tflint/releases/download/v0.4.2/tflint_linux_amd64.zip ; unzip tflint_linux_amd64.zip + - run: + name: "install tflint" + command: mkdir -p /usr/local/tflint/bin ; export PATH=/usr/local/tflint/bin:$PATH ; install tflint /usr/local/tflint/bin + - run: + name: "tflint check" + command: /usr/local/tflint/bin/tflint +workflows: + version: 2 + build: + jobs: + - build