Skip to content

Commit a2956d6

Browse files
authored
Merge pull request #68663 from openshift-cherrypick-robot/cherry-pick-53168-to-enterprise-4.15
[enterprise-4.15] Lint topic_map yml files and fail the Travis build if errors are found
2 parents 1ccd360 + fbd2179 commit a2956d6

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

.yamllint

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
extends: relaxed
3+
rules:
4+
indentation: { spaces: 2, indent-sequences: false }
5+
line-length: disable
6+
colons:
7+
max-spaces-before: 0
8+
max-spaces-after: 1
9+
empty-lines: disable
10+
trailing-spaces: enable
11+
new-line-at-end-of-file: enable

scripts/lint-topicmaps.sh

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
# Use yamllint to lint and report errors for modified topic_map.yml files
4+
5+
# Ensure yamllint is installed
6+
if ! command -v yamllint &>/dev/null; then
7+
echo "yamllint is not installed. Please install it and try again 👻"
8+
exit 127
9+
fi
10+
11+
# List of modified topic_map files
12+
FILES=$(git diff --name-only HEAD~1 HEAD --diff-filter=d "./_topic_maps/*.yml")
13+
14+
if [ -n "${FILES}" ]; then
15+
has_errors=0
16+
for FILE in ${FILES[@]}; do
17+
if ! yamllint "$FILE"; then
18+
echo "YAML error(s) found in $FILE 😥"
19+
has_errors=1
20+
fi
21+
done
22+
23+
if [ $has_errors -eq 1 ]; then
24+
exit 1
25+
else
26+
echo "No YAML errors found 🥳"
27+
exit 0
28+
fi
29+
else
30+
echo "No updated topic_maps... 😙"
31+
exit 0
32+
fi

0 commit comments

Comments
 (0)