Github messages for voidlinux
 help / color / mirror / Atom feed
From: classabbyamp <classabbyamp@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: [PR PATCH] common/scripts/lint-commits: check commit author github account
Date: Wed, 09 Nov 2022 01:16:43 +0100	[thread overview]
Message-ID: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-40399@inbox.vuxu.org> (raw)

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

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

https://github.com/classabbyamp/void-packages ci/committer-gh-check
https://github.com/void-linux/void-packages/pull/40399

common/scripts/lint-commits: check commit author github account
Recently, CONTRIBUTING.md added a line about ensuring the email used to commit is associated with a github account. This should be able to lint all commits in a PR to ensure that condition.

While it is using API calls, it should only cost 1 call per CI run.

Will test this soon and refine the implementation.

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



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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-ci/committer-gh-check-40399.patch --]
[-- Type: text/x-diff, Size: 2437 bytes --]

From a1feb79e88e3d43d7f1ed341a74fd4896a87aba1 Mon Sep 17 00:00:00 2001
From: classabbyamp <void@placeviolette.net>
Date: Tue, 8 Nov 2022 19:12:45 -0500
Subject: [PATCH] common/scripts/lint-commits: check commit author github
 account

---
 .github/workflows/build.yaml |  1 +
 common/scripts/lint-commits  | 12 +++++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml
index 95f1cd88e338..454ffbaf2680 100644
--- a/.github/workflows/build.yaml
+++ b/.github/workflows/build.yaml
@@ -24,6 +24,7 @@ jobs:
       PATH: '/usr/libexec/chroot-git:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin:/usr/local/bin:/tmp/bin'
       XLINT: '1'
       LICENSE_LIST: common/travis/license.lst
+      GH_PR_NUM: ${{ github.event.number }}
 
     steps:
       - uses: actions/checkout@v1
diff --git a/common/scripts/lint-commits b/common/scripts/lint-commits
index 6aea99d51154..582d44c79ca1 100755
--- a/common/scripts/lint-commits
+++ b/common/scripts/lint-commits
@@ -37,7 +37,7 @@ do
 	(NF > 2) && (length > 80) { print "::error title=Commit Lint::" C ": long line: " $0; exit 1 }
 	!subject {
 		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 }
+		if (!($0 ~ ":" || $0 ~ "^Take over maintainership " || $0 ~ "^Orphan ")) { print "::error title=Commit Lint::" C ": subject does not follow CONTRIBUTING.md guidelines"; exit 1 }
 		# Below check is too noisy?
 		# if (!($0 ~ "^New package:" || $0 ~ ".*: update to")) {
 		# 	print "::warning title=Commit Lint::" C ": not new package/update/removal?"
@@ -48,4 +48,14 @@ do
 	!body { print "::error title=Commit Lint::" C ": second line must be blank"; exit 1 }
 	' || status=1
 done
+
+if [ "$GITHUB_ACTIONS" = "true" ] && [ "$GH_PR_NUM" ]; then
+	gh api repos/void-linux/void-packages/pulls/$GH_PR_NUM/commits -t "{{range .}}{{slice .sha 0 8}}:{{.committer.login}}:{{.author.login}}{{end}}" |
+		awk -F: '
+		BEGIN { E=0 }
+		($1 ~ /^$/) { print "::error title=Commit Lint::" $0 ": no GitHub account associated with committer"; E=1 }
+		($2 ~ /^$/) { print "::error title=Commit Lint::" $0 ": no GitHub account associated with commit author"; E=1 }
+		END { exit $E }' || status=1
+fi
+
 exit $status

             reply	other threads:[~2022-11-09  0:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-09  0:16 classabbyamp [this message]
2023-02-07  2:27 ` github-actions
2023-05-09  1:52 ` github-actions
2023-06-14  7:24 ` [PR PATCH] [Closed]: " classabbyamp

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-40399@inbox.vuxu.org \
    --to=classabbyamp@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).