CI: add CODEOWNERS file sanity check (MR 4662)
* Check for space indentation instead of tabs * Check that an entry actually exists * Check that a directory ends in a slash, otherwise GitLab seems to ignore it
This commit is contained in:
parent
2cb6b5e645
commit
e5c26d38f8
2 changed files with 44 additions and 0 deletions
43
.ci/codeowners.sh
Executable file
43
.ci/codeowners.sh
Executable file
|
@ -0,0 +1,43 @@
|
|||
#!/bin/sh -e
|
||||
# Description: verify CODEOWNERS file is sane
|
||||
# https://postmarketos.org/pmb-ci
|
||||
|
||||
# TODO Future improvements:
|
||||
# * Check that all devices in main/community have someone in CODEOWNERS
|
||||
# * Check that GitLab user actually exists (e.g. deleted account, account with
|
||||
# changed user name)
|
||||
|
||||
if grep -q " " CODEOWNERS; then
|
||||
echo
|
||||
echo "ERROR: Found space indentation in CODEOWNERS."
|
||||
echo "ERROR: Please indent with tab characters."
|
||||
grep " " CODEOWNERS
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
fail=0
|
||||
tmppipe=$(mktemp -u)
|
||||
mkfifo "$tmppipe"
|
||||
grep -v "^#" CODEOWNERS | cut -d' ' -f1 > "$tmppipe" &
|
||||
while IFS= read -r line; do
|
||||
[ -z "$line" ] && continue
|
||||
|
||||
# Check if entry generally exists
|
||||
# shellcheck disable=SC2086
|
||||
ls $line >/dev/null 2>&1 || { fail=1; echo "Non-existing: $line"; }
|
||||
|
||||
# Check that directories end with a slash
|
||||
# shellcheck disable=SC2086
|
||||
if test -d "$(ls -d $line)"; then
|
||||
echo "$line" | grep -q '/$' || { fail=1; echo "Missing trailing slash: $line"; }
|
||||
fi
|
||||
done < "$tmppipe"
|
||||
rm "$tmppipe"
|
||||
|
||||
if [ "$fail" = 1 ]; then
|
||||
echo
|
||||
echo "ERROR: Invalid CODEOWNERS entries, see above."
|
||||
echo
|
||||
exit 1
|
||||
fi
|
|
@ -60,6 +60,7 @@ shellcheck-grep:
|
|||
- .ci/lib/gitlab_prepare_ci.sh
|
||||
- .ci/shellcheck.sh
|
||||
- .ci/grep.sh
|
||||
- .ci/codeowners.sh
|
||||
|
||||
editor-config:
|
||||
stage: lint
|
||||
|
|
Loading…
Reference in a new issue