Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

github: add new checklist workflow #1570

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions .github/workflows/checklist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Checklist

# Produce a list of things that need to be changed
# for the submission to align with CONTRIBUTING.md

on:
pull_request:
types: [ opened, reopened, edited, synchronize ]

permissions:
pull-requests: write

jobs:
checklist:
name: commit
runs-on: ubuntu-latest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# XXX would prefer to run this on FreeBSD-latest :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, hopefully one day

steps:
- uses: actions/github-script@v7
with:
# An asynchronous javascript function
script: |
/*
* Github's API returns the results in pages of 30, so
* pass the function we want, along with it's arguments,
* to paginate() which will handle gathering all the results.
*/
const comments = await github.paginate(github.rest.issues.listComments, {
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});

const commits = await github.paginate(github.rest.pulls.listCommits, {
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});

let checklist = {};
let checklist_len = 0;
let comment_id = -1;

const msg_prefix = "Thank you for taking the time to contribute to FreeBSD!\n";
const addToChecklist = (msg, sha) => {
if (!checklist[msg]) {
checklist[msg] = [];
checklist_len++;
}
checklist[msg].push(sha);
}

for (const commit of commits) {
const sob_lines = commit.commit.message.match(/^[^\S\r\n]*signed-off-by:.*/gim);

if (sob_lines == null && !commit.commit.author.email.toLowerCase().endsWith("freebsd.org"))
addToChecklist("Missing Signed-off-by lines", commit.sha);
else if (sob_lines != null) {
let author_signed = false;
for (const line of sob_lines) {
if (!line.includes("Signed-off-by: "))
/* Only display the part we care about. */
addToChecklist("Expected `Signed-off-by: `, got `" + line.match(/^[^\S\r\n]*signed-off-by:./i) + "`", commit.sha);
if (line.includes(commit.commit.author.email))
author_signed = true;
}

if (!author_signed)
console.log("::warning title=Missing-Author-Signature::Missing Signed-off-by from author");
}

if (commit.commit.author.email.toLowerCase().includes("noreply"))
addToChecklist("Real email address is needed", commit.sha);
}

/* Check if we've commented before. */
for (const comment of comments) {
if (comment.user.login == "github-actions[bot]") {
comment_id = comment.id;
break;
}
}

if (checklist_len != 0) {
let msg = msg_prefix +
"There " + (checklist_len > 1 ? "are a few issues that need " : "is an issue that needs ") +
"to be fixed:\n";
let comment_func = comment_id == -1 ? github.rest.issues.createComment : github.rest.issues.updateComment;

/* Loop for each key in "checklist". */
for (const c in checklist)
msg += "- " + c + "<sup>" + checklist[c].join(", ") + "</sup>\n";

comment_func({
owner: context.repo.owner,
repo: context.repo.repo,
body: msg,
...(comment_id == -1 ? {issue_number: context.issue.number} : {comment_id: comment_id})
});
} else if (comment_id != -1) {
github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: comment_id,
body: msg_prefix + "All issues resolved."
});
}
33 changes: 0 additions & 33 deletions tools/build/checkstyle9.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1253,8 +1253,6 @@ sub process {

my $in_header_lines = $file ? 0 : 1;
my $in_commit_log = 0; #Scanning lines before patch
my $has_sob = 0;
my $author_is_committer = 0;
my $non_utf8_charset = 0;

our @report = ();
Expand Down Expand Up @@ -1450,33 +1448,6 @@ sub process {
$is_patch = 1;
}

# Filter out bad email addresses.
if ($line =~ /^(Author|From): .*noreply.*/) {
ERROR("Real email adress is needed\n" . $herecurr);
}

if ($line =~ /^Author: .*[a-z-0-9]\@freebsd\.org/i) {
$author_is_committer = 1
}

#check the patch for a signoff:
if ($line =~ /^\s*signed-off-by:/i) {
# This is a signoff, if ugly, so do not double report.
$in_commit_log = 0;
$has_sob = 1;

if (!($line =~ /^\s*Signed-off-by:/)) {
ERROR("The correct form is \"Signed-off-by\"\n" .
$herecurr);
$has_sob = 0;
}
if ($line =~ /^\s*signed-off-by:\S/i) {
ERROR("space required after Signed-off-by:\n" .
$herecurr);
$has_sob = 0;
}
}

# Check for wrappage within a valid hunk of the file
if ($realcnt != 0 && $line !~ m{^(?:\+|-| |\\ No newline|$)}) {
ERROR("patch seems to be corrupt (line wrapped?)\n" .
Expand Down Expand Up @@ -2659,10 +2630,6 @@ sub process {

}

if ($has_sob == 0 && $author_is_committer == 0) {
WARN("Missing Signed-off-by: line");
}

# If we have no input at all, then there is nothing to report on
# so just keep quiet.
if ($#rawlines == -1) {
Expand Down
Loading