mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-05-08 14:23:11 +00:00
Make ansible-lint and yamllint use more strict rules.
This patch modifies configuration of both ansible-lint and yamllint to check for more rules, resulting in a more strict verification. For ansible-lint verification of errors 301, 305 and 505 are skipped, due to false positives. For the same reason, 'experimental' rules are skipped. ansible-lint error 306 is skipped since the fix is to set pipefail, which is not available in all shells (for example dash, which runs ansible-freeipa CI). Yamllint disabled rules (comments, and indentation) would introduce a huge amount of small changes, and are left for future changes, it deemed necessary.
This commit is contained in:
@@ -1,29 +1,41 @@
|
||||
#!/bin/bash
|
||||
|
||||
topdir="`dirname $(dirname $0)`"
|
||||
INFO="\033[37;1m"
|
||||
WARN="\033[33;1m"
|
||||
RST="\033[0m"
|
||||
|
||||
flake8 .
|
||||
pydocstyle .
|
||||
pylint plugins
|
||||
pushd "`dirname $0`/.." >/dev/null 2>&1
|
||||
|
||||
ANSIBLE_LIBRARY=${ANSIBLE_LIBRARY:-"${topdir}/plugins/modules"}
|
||||
ANSIBLE_MODULE_UTILS=${ANSIBLE_MODULE_UTILS:-"${topdir}/plugins/module_utils"}
|
||||
echo -e "${INFO}Running 'flake8'...${RST}"
|
||||
flake8 plugins utils roles *.py
|
||||
echo -e "${INFO}Running 'pydocstyle'...${RST}"
|
||||
pydocstyle plugins utils roles *.py
|
||||
echo -e "${INFO}Running 'pylint'...${RST}"
|
||||
pylint plugins *.py
|
||||
|
||||
export ANSIBLE_LIBRARY ANSIBLE_MODULE_UTILS
|
||||
ANSIBLE_LIBRARY="${ANSIBLE_LIBRARY:-plugins/modules}"
|
||||
ANSIBLE_MODULE_UTILS="${ANSIBLE_MODULE_UTILS:-plugins/module_utils}"
|
||||
ANSIBLE_DOC_FRAGMENT_PLUGINS="${ANSIBLE_DOC_FRAGMENT_PLUGINS:-plugins/doc_fragments}"
|
||||
export ANSIBLE_LIBRARY ANSIBLE_MODULE_UTILS ANSIBLE_DOC_FRAGMENT_PLUGINS
|
||||
|
||||
yaml_dirs=(
|
||||
"${topdir}/tests"
|
||||
"${topdir}/playbooks"
|
||||
"${topdir}/molecule"
|
||||
echo -e "${WARN}Missing file warnings are expected and can be ignored.${RST}"
|
||||
echo -e "${INFO}Running 'ansible-lint'...${RST}"
|
||||
playbook_dirs=(
|
||||
"tests"
|
||||
"playbooks"
|
||||
)
|
||||
ansible-lint --force-color "${playbook_dirs[@]}"
|
||||
|
||||
for dir in "${yaml_dirs[@]}"
|
||||
do
|
||||
find "${dir}" -type f -name "*.yml" | xargs ansible-lint --force-color
|
||||
done
|
||||
echo -e "${INFO}Running 'ansible-doc-test'...${RST}"
|
||||
python "`dirname $0`/ansible-doc-test" -v roles plugins
|
||||
|
||||
echo -e "${INFO}Running 'yamllint'...${RST}"
|
||||
yaml_dirs=(
|
||||
"tests"
|
||||
"playbooks"
|
||||
"molecule"
|
||||
"roles"
|
||||
)
|
||||
yamllint -f colored "${yaml_dirs[@]}"
|
||||
|
||||
for dir in "${yaml_dirs[@]}"
|
||||
do
|
||||
find "${dir}" -type f -name "*.yml" | xargs yamllint
|
||||
done
|
||||
popd >/dev/null 2>&1
|
||||
|
||||
Reference in New Issue
Block a user