Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] common/travis/xlint.sh: print Github annotations
@ 2022-05-02  8:33 0x5c
  2022-05-04 21:25 ` [PR REVIEW] " Chocimier
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: 0x5c @ 2022-05-02  8:33 UTC (permalink / raw)
  To: ml

[-- 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PR REVIEW] common/travis/xlint.sh: print Github annotations
  2022-05-02  8:33 [PR PATCH] common/travis/xlint.sh: print Github annotations 0x5c
@ 2022-05-04 21:25 ` Chocimier
  2022-05-05  2:09 ` 0x5c
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Chocimier @ 2022-05-04 21:25 UTC (permalink / raw)
  To: ml

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

New review comment by Chocimier on void-packages repository

https://github.com/void-linux/void-packages/pull/36950#discussion_r865397014

Comment:
Printing error twice in logs is redundant, can we remove this?

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PR REVIEW] common/travis/xlint.sh: print Github annotations
  2022-05-02  8:33 [PR PATCH] common/travis/xlint.sh: print Github annotations 0x5c
  2022-05-04 21:25 ` [PR REVIEW] " Chocimier
@ 2022-05-05  2:09 ` 0x5c
  2022-05-05 15:41 ` Chocimier
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: 0x5c @ 2022-05-05  2:09 UTC (permalink / raw)
  To: ml

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

New review comment by 0x5c on void-packages repository

https://github.com/void-linux/void-packages/pull/36950#discussion_r865513293

Comment:
The current behaviour includes the file and line number in the log message, while the annotation would eat it (the file and line only being visible in the form of the inline annotation itself.

There's a couple of options
1. Remove the plain print and make the message of the annotation the same as the raw lint line (the annotation message would contain the filename [and line] even when inline)
2. Keep as is
3. Not change the annotation and remove the raw print (filename [and line] never shown anywhere)

In all 3 the inline annotations are correctly placed

Imo option 3 is fine but I essentially didn't want to "break" the current behaviour without input from reviewers. The duplicated print is easier to notice than the lack of filename[/line] in the log.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PR REVIEW] common/travis/xlint.sh: print Github annotations
  2022-05-02  8:33 [PR PATCH] common/travis/xlint.sh: print Github annotations 0x5c
  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
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Chocimier @ 2022-05-05 15:41 UTC (permalink / raw)
  To: ml

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

New review comment by Chocimier on void-packages repository

https://github.com/void-linux/void-packages/pull/36950#discussion_r866053872

Comment:
Filename is in header line `Linting srcpkgs/*/template`, so only line number disappears. I opt for 3.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PR REVIEW] common/travis/xlint.sh: print Github annotations
  2022-05-02  8:33 [PR PATCH] common/travis/xlint.sh: print Github annotations 0x5c
                   ` (2 preceding siblings ...)
  2022-05-05 15:41 ` Chocimier
@ 2022-05-05 15:51 ` 0x5c
  2022-05-05 16:02 ` [PR PATCH] [Updated] " 0x5c
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: 0x5c @ 2022-05-05 15:51 UTC (permalink / raw)
  To: ml

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

New review comment by 0x5c on void-packages repository

https://github.com/void-linux/void-packages/pull/36950#discussion_r866064529

Comment:
Wow I didn't even connect that "oh nice they print the filename in green" meant that it's essentially there


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PR PATCH] [Updated] common/travis/xlint.sh: print Github annotations
  2022-05-02  8:33 [PR PATCH] common/travis/xlint.sh: print Github annotations 0x5c
                   ` (3 preceding siblings ...)
  2022-05-05 15:51 ` 0x5c
@ 2022-05-05 16:02 ` 0x5c
  2022-05-05 16:07 ` [PR REVIEW] " 0x5c
  2022-05-05 19:34 ` [PR PATCH] [Merged]: " Chocimier
  6 siblings, 0 replies; 8+ messages in thread
From: 0x5c @ 2022-05-05 16:02 UTC (permalink / raw)
  To: ml

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

There is an updated 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: 3422 bytes --]

From bbecc62cf8754fb642025b6b803b0e40a170e8e6 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 | 11 +++++++++++
 common/travis/xlint.sh              |  5 +++--
 3 files changed, 19 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..5405d6971535
--- /dev/null
+++ b/common/scripts/lint2annotations.awk
@@ -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
+}
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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PR REVIEW] common/travis/xlint.sh: print Github annotations
  2022-05-02  8:33 [PR PATCH] common/travis/xlint.sh: print Github annotations 0x5c
                   ` (4 preceding siblings ...)
  2022-05-05 16:02 ` [PR PATCH] [Updated] " 0x5c
@ 2022-05-05 16:07 ` 0x5c
  2022-05-05 19:34 ` [PR PATCH] [Merged]: " Chocimier
  6 siblings, 0 replies; 8+ messages in thread
From: 0x5c @ 2022-05-05 16:07 UTC (permalink / raw)
  To: ml

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

New review comment by 0x5c on void-packages repository

https://github.com/void-linux/void-packages/pull/36950#discussion_r866079275

Comment:
Updated and tested, the demo pr on my fork is updated too

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PR PATCH] [Merged]: common/travis/xlint.sh: print Github annotations
  2022-05-02  8:33 [PR PATCH] common/travis/xlint.sh: print Github annotations 0x5c
                   ` (5 preceding siblings ...)
  2022-05-05 16:07 ` [PR REVIEW] " 0x5c
@ 2022-05-05 19:34 ` Chocimier
  6 siblings, 0 replies; 8+ messages in thread
From: Chocimier @ 2022-05-05 19:34 UTC (permalink / raw)
  To: ml

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

There's a merged pull request on the void-packages repository

common/travis/xlint.sh: print Github annotations
https://github.com/void-linux/void-packages/pull/36950

Description:
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 (misplaced variables now have a line number since https://github.com/leahneukirchen/xtools/pull/240)
![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/166975601-259bfc69-217d-4295-868f-8a87dcf72b39.png)


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

[ci skip]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-05-05 19:34 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-02  8:33 [PR PATCH] common/travis/xlint.sh: print Github annotations 0x5c
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

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).