Skip to content
Snippets Groups Projects
Commit 231c3674 authored by Andrew Newdigate's avatar Andrew Newdigate
Browse files

Merge branch 'tflint-improvements' into 'main'

fix: improve terraform linting

See merge request gitlab-com/gl-infra/common-ci-tasks!16
parents 72b4c92b 274ae77c
No related branches found
No related tags found
No related merge requests found
Pipeline #13572416 passed
Loading
Loading
@@ -3,7 +3,7 @@ tflint:
needs: []
image:
name: hashicorp/terraform:${GL_ASDF_TERRAFORM_VERSION}
entrypoint: ['/bin/sh', '-c']
entrypoint: [""]
before_script:
- apk add --no-cache curl bash unzip
- export TFLINT_VERSION=v${GL_ASDF_TFLINT_VERSION}
Loading
Loading
@@ -12,6 +12,7 @@ tflint:
- mkdir -p "tflint-reports/"
# Find all TF files and lint the directories of those files
- tflint --init -c .tflint.hcl
# Loop through all the directories containing *.tf files and run tflint in them
- find . -type f -name '*.tf' -exec dirname {} \;|sort -u|grep -v "${TFLINT_EXCLUDE_REGEX:-__none__}" | while read -r dir; do
junit_file="$(echo "$dir"|sed -r 's/[^a-zA-Z0-9]+/-/g' | sed -r s/^-+\|-+$//g).xml";
echo "${dir} -------------------------------------------------------";
Loading
Loading
@@ -26,3 +27,6 @@ tflint:
when: always
reports:
junit: tflint-reports/**
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment