Skip to content

Lint topic_map yml files and fail the Travis build if errors are found #53168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -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
32 changes: 32 additions & 0 deletions scripts/lint-topicmaps.sh
Original file line number Diff line number Diff line change
@@ -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