diff --git a/.yamllint b/.yamllint new file mode 100644 index 000000000000..db8d47ebf1ea --- /dev/null +++ b/.yamllint @@ -0,0 +1,11 @@ +--- +extends: relaxed +rules: + indentation: { spaces: 2, indent-sequences: false } + line-length: disable + colons: + max-spaces-before: 0 + max-spaces-after: 1 + empty-lines: disable + trailing-spaces: enable + new-line-at-end-of-file: enable diff --git a/scripts/lint-topicmaps.sh b/scripts/lint-topicmaps.sh new file mode 100755 index 000000000000..5cf6cdd0a9aa --- /dev/null +++ b/scripts/lint-topicmaps.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +# Use yamllint to lint and report errors for modified topic_map.yml files + +# Ensure yamllint is installed +if ! command -v yamllint &>/dev/null; then + echo "yamllint is not installed. Please install it and try again 👻" + exit 127 +fi + +# List of modified topic_map files +FILES=$(git diff --name-only HEAD~1 HEAD --diff-filter=d "./_topic_maps/*.yml") + +if [ -n "${FILES}" ]; then + has_errors=0 + for FILE in ${FILES[@]}; do + if ! yamllint "$FILE"; then + echo "YAML error(s) found in $FILE 😥" + has_errors=1 + fi + done + + if [ $has_errors -eq 1 ]; then + exit 1 + else + echo "No YAML errors found 🥳" + exit 0 + fi +else + echo "No updated topic_maps... 😙" + exit 0 +fi