---
# Install terraform
before_install:
    - >
      curl -sLo /tmp/terraform.zip
      https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip
    - unzip /tmp/terraform.zip -d /tmp
    - mkdir -p "${HOME}"/bin
    - mv /tmp/terraform "${HOME}"/bin
    - export PATH="${HOME}/bin:$PATH"

env:
    global:
        - TF_INPUT=false
        - TERRAFORM_VERSION=0.12.20

language: node_js

install:
    - sudo pip install -r requirements.txt
    - npm install

node_js:
    - node

os: linux

services:
    - docker

script:
    - yamllint --strict $(git ls-files '*.yaml' '*.yml') || exit 1
    - >
        find -name "*.md" -not -path "*/node_modules/*"
        | xargs markdownlint
        || exit 1
    - >
        find . -type f -iname "*.sh"
        | while read -r line; do
        echo "Linting $line";
        docker run -v "$(pwd)":/mnt --rm koalaman/shellcheck:v0.7.0 "$line"
        || exit 1;
        done;
    - >
        cd provisioning/terraform
        && terraform validate

jobs:
    fast_finish: true

---
# Install terraform
before_install:
    - >
      curl -sLo /tmp/terraform.zip
      https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip
    - unzip /tmp/terraform.zip -d /tmp
    - mkdir -p "${HOME}"/bin
    - mv /tmp/terraform "${HOME}"/bin
    - export PATH="${HOME}/bin:$PATH"

env:
    global:
        - TF_INPUT=false
        - TERRAFORM_VERSION=0.12.20

language: node_js

install:
    - sudo pip install -r requirements.txt
    - npm install

node_js:
    - node

os: linux

services:
    - docker

script:
    - yamllint --strict $(git ls-files '*.yaml' '*.yml') || exit 1
    - >
        find -name "*.md" -not -path "*/node_modules/*"
        | xargs markdownlint
        || exit 1
    - >
        find . -type f -iname "*.sh"
        | while read -r line; do
        echo "Linting $line";
        docker run -v "$(pwd)":/mnt --rm koalaman/shellcheck:v0.7.0 "$line"
        || exit 1;
        done;
    - >
        cd provisioning/terraform
        && terraform validate
        || exit 1

jobs:
    fast_finish: true

Exit 1 if Terraform finds validation errors
Exit 1 if Terraform finds validation errors
