common/travis/xlint.sh: print Github annotations

Turns xlint, version lint, and commit lint messages into warning or error
annotaions. All are printed with special highlighting in the action log and
summary. Xlint and version lint annotations are shown inline in the changes tab
and commit view. Annotations without line number are shown at line 1.
This commit is contained in:
0x5c 2022-05-02 00:58:34 -04:00 committed by Piotr
parent e900c63cf9
commit cc27e8e6f7
3 changed files with 19 additions and 7 deletions

View File

@ -35,18 +35,18 @@ do
/^$/ && !msg { msg = 1; next }
!msg { next }
# 3: long-line-is-banned-except-footnote-like-this-for-url
(NF > 2) && (length > 80) { print C ": long line: " $0; exit 1 }
(NF > 2) && (length > 80) { print "::error title=Commit Lint::" C ": long line: " $0; exit 1 }
!subject {
if (length > 50) { print C ": subject is a bit long" }
if (!($0 ~ ":" || $0 ~ "^Take over maintainership " || $0 ~ "^Orphan ")) { print C ": subject does not follow CONTRIBUTING.md guildelines"; exit 1 }
if (length > 50) { print "::warning title=Commit Lint::" C ": subject is a bit long" }
if (!($0 ~ ":" || $0 ~ "^Take over maintainership " || $0 ~ "^Orphan ")) { print "::error title=Commit Lint::" C ": subject does not follow CONTRIBUTING.md guildelines"; exit 1 }
# Below check is too noisy?
# if (!($0 ~ "^New package:" || $0 ~ ".*: update to")) {
# print C ": not new package/update/removal?"
# print "::warning title=Commit Lint::" C ": not new package/update/removal?"
# }
subject = 1; next
}
/^$/ { body = 1; next }
!body { print C ": second line must be blank"; exit 1 }
!body { print "::error title=Commit Lint::" C ": second line must be blank"; exit 1 }
' || status=1
done
exit $status

View File

@ -0,0 +1,11 @@
# Converts xlint/etc format lints into GH Actions annotations
# The original line is printed alongside the annotation command
{
split($0, a, ": ")
split(a[1], b, ":")
msg = substr($0, index($0, ": ") + 2)
if (b[2]) {
line = ",line=" b[2]
}
printf "::error title=Template Lint,file=%s%s::%s\n", b[1], line, msg
}

View File

@ -11,7 +11,8 @@ common/scripts/lint-commits $base $tip || EXITCODE=$?
for t in $(awk '{ print "srcpkgs/" $0 "/template" }' /tmp/templates); do
/bin/echo -e "\x1b[32mLinting $t...\x1b[0m"
xlint "$t" || EXITCODE=$?
common/scripts/lint-version-change "$t" $base $tip || EXITCODE=$?
xlint "$t" > /tmp/xlint_out || EXITCODE=$?
common/scripts/lint-version-change "$t" $base $tip > /tmp/vlint_out || EXITCODE=$?
awk -f common/scripts/lint2annotations.awk /tmp/xlint_out /tmp/vlint_out
done
exit $EXITCODE