Updated lint commands for CI

This commit is contained in:
Bastian de Byl
2020-09-25 14:22:54 -04:00
parent 86b6f02b96
commit f97ab7e6f3
3 changed files with 13 additions and 9 deletions

View File

@@ -8,8 +8,9 @@ platform:
steps:
- name: lint
image: cytopia/ansible-lint
image: bdebyl/yamllint
command:
- export YML_FILES="$(find ansible/ -name '*.yml' -not -name '*vault*')"
- ansible-lint -x 701 "$YML_FILES"
- . .lint-vars.sh
- ansible-lint -x "$ANSIBLE_LINT_SKIP_LIST" "$YML_FILES"
- yamllint "$YML_FILES"

6
.lint-vars.sh Executable file
View File

@@ -0,0 +1,6 @@
#/bin/sh
# Ansible Lint skip list (https://ansible-lint.readthedocs.io/en/latest/default_rules.html)
# [701] - "No 'galaxy_info' found (in role)"
export ANSIBLE_LINT_SKIP_LIST=701

View File

@@ -43,10 +43,7 @@ ${VAULT_FILE}: ${VAULT_PASS_FILE}
# Linting
YAML_FILES=$(shell find ansible/ -name '*.yml' -not -name '*vault*')
# Ansible Lint skip list (https://ansible-lint.readthedocs.io/en/latest/default_rules.html)
# [701] - "No 'galaxy_info' found (in role)"
ANSIBLE_LINT_SKIP_LIST=701
SKIP_FILE=./.lint-vars.sh
# Targets
deploy: ${ANSIBLE} ${VAULT_FILE}
@@ -58,8 +55,8 @@ check: ${ANSIBLE} ${VAULT_FILE}
vault: ${ANSIBLE_VAULT} ${VAULT_FILE}
${ANSIBLE_VAULT} edit --vault-password-file ${VAULT_PASS_FILE} ${VAULT_FILE}
lint: ${LINT_YAML} ${LINT_ANSIBLE}
lint: ${LINT_YAML} ${LINT_ANSIBLE} ${SKIP_FILE}
@printf "Running yamllint...\n"
-@${LINT_YAML} ${YAML_FILES}
@printf "Running ansible-lint with SKIP_LIST: [%s]...\n" "${ANSIBLE_LINT_SKIP_LIST}"
-@${LINT_ANSIBLE} -x ${ANSIBLE_LINT_SKIP_LIST} ${YAML_FILES}
@. ${SKIP_FILE}; printf "Running ansible-lint with SKIP_LIST: [%s]...\n" "$$ANSIBLE_LINT_SKIP_LIST"
-@. ${SKIP_FILE}; ${LINT_ANSIBLE} -x $$ANSIBLE_LINT_SKIP_LIST ${YAML_FILES}