Github messages for voidlinux
 help / color / mirror / Atom feed
From: 0x5c <0x5c@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: [PR PATCH] common/travis/xlint.sh: print Github annotations
Date: Mon, 02 May 2022 10:33:17 +0200	[thread overview]
Message-ID: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-36950@inbox.vuxu.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 1405 bytes --]

There is a new pull request by 0x5c against master on the void-packages repository

https://github.com/0x5c/void-packages ci-xlint
https://github.com/void-linux/void-packages/pull/36950

common/travis/xlint.sh: print Github annotations
This turns xlint, version lint, and commit lint messages into warning or error annotations.

Only annotations from the last CI run will show, except on the summary and logs of a run, where they are visible as long as the run exist.

A showcase of the changes can be seen [here](https://github.com/0x5c/void-packages/pull/3).

Ping @the-maldridge since you were interested in this

#### Screenshots
Inline lints (xlint and version lint)
![image](https://user-images.githubusercontent.com/5877043/166205591-4720208d-4bce-479c-aa4c-37d11e5f6151.png)
Lints without line number show at line 1
![image](https://user-images.githubusercontent.com/5877043/166206105-65ece722-1204-4e3c-8ac1-bc618be74f9d.png)
All lints show on the action run summary
![image](https://user-images.githubusercontent.com/5877043/166206252-701f983c-a92a-4930-ae97-ddd560ef5ff9.png)
and in the log
![image](https://user-images.githubusercontent.com/5877043/166206369-65f05aca-d35b-47c3-b3c5-12ca732eede1.png)

#### Testing the changes
- I tested the changes in this PR: **YES**

[ci skip]

A patch file from https://github.com/void-linux/void-packages/pull/36950.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ci-xlint-36950.patch --]
[-- Type: text/x-diff, Size: 3434 bytes --]

From 2622aa9f7c8dff7384ce64e5f373fa74787f2184 Mon Sep 17 00:00:00 2001
From: 0x5c <dev@0x5c.io>
Date: Mon, 2 May 2022 00:58:34 -0400
Subject: [PATCH] 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.
---
 common/scripts/lint-commits         | 10 +++++-----
 common/scripts/lint2annotations.awk | 12 ++++++++++++
 common/travis/xlint.sh              |  5 +++--
 3 files changed, 20 insertions(+), 7 deletions(-)
 create mode 100644 common/scripts/lint2annotations.awk

diff --git a/common/scripts/lint-commits b/common/scripts/lint-commits
index 01c4eda17007..7207ed81d5aa 100755
--- a/common/scripts/lint-commits
+++ b/common/scripts/lint-commits
@@ -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
diff --git a/common/scripts/lint2annotations.awk b/common/scripts/lint2annotations.awk
new file mode 100644
index 000000000000..d74bcc15f961
--- /dev/null
+++ b/common/scripts/lint2annotations.awk
@@ -0,0 +1,12 @@
+# 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]
+	}
+	print $0
+	printf "::error title=Template Lint,file=%s%s::%s\n", b[1], line, msg
+}
diff --git a/common/travis/xlint.sh b/common/travis/xlint.sh
index 6b3d9e91c90a..327417c1c327 100755
--- a/common/travis/xlint.sh
+++ b/common/travis/xlint.sh
@@ -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

             reply	other threads:[~2022-05-02  8:33 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-02  8:33 0x5c [this message]
2022-05-04 21:25 ` [PR REVIEW] " Chocimier
2022-05-05  2:09 ` 0x5c
2022-05-05 15:41 ` Chocimier
2022-05-05 15:51 ` 0x5c
2022-05-05 16:02 ` [PR PATCH] [Updated] " 0x5c
2022-05-05 16:07 ` [PR REVIEW] " 0x5c
2022-05-05 19:34 ` [PR PATCH] [Merged]: " Chocimier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-36950@inbox.vuxu.org \
    --to=0x5c@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).