From nobody Fri Jan 24 20:27:44 2025 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4YfqB924Z1z5lsRc; Fri, 24 Jan 2025 20:27:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YfqB91L52z3bfZ; Fri, 24 Jan 2025 20:27:45 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737750465; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=e96JOJ6CBQyGlCgjIAD0IBn1INHUrj/zPgIzP99IrxU=; b=JL3JeXnHf3h4epzJ2OM2jdbYFQBvHccOhUFU93arUyDd/Lq9oIwWzpqGukHuFv8ensxW11 pL9wHcJHn6E2hS0ASTaIuVi14DsbELd/Tu5mi4Du2jKYlc9HcfmX0zad8wHxOHsQEytyhm ot86LwEihcNLjMBb+x4JgFTyy5mVMFgZDLi5YJGr1iinurcWlOPHzc7txOKK9MpFwyISfC YdetNCh+VV8QWZvZm2B2xdQTE+IziW5oy7CbYLI9z8+eove3dhYL3WmLris3UwEMsCL5Pu 6XuTkj3l60YcVIHIcakAW83QH7PSP8Zt4f+1Zko1CzQS8uRJ6S/2hs89Ci1jyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1737750465; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=e96JOJ6CBQyGlCgjIAD0IBn1INHUrj/zPgIzP99IrxU=; b=lUQDj2pvG7NEM38JkliTyQ6jnGufu0CeLeO2B2yz5MB94ttBZkJbp9WWP8ysfAbByfwwXK yY147U0KU1WPwQhwGYlqE92UKW4s04sM80JP1uhxseljq+oFKJOBJzozgvgxGoGzeEaLwu 5FG2WkogKIU2U4Phj7XQQ2/jqL0++Y5tPMhqKihxspg0FfC7TZZqPfJP07l9NI5WgBkApl mAoPtrsEfot+osrYeDVQW4XXzk7xPcpaJxKp/g+XMG7BKdMry5M1Mblc/MKy9k9FUhDsda EMDXkzJL9AgnNe/p+vwOTYFbuTvPy0fScwL9jpyO2SDbKyB5SUmTog+E5kKcxA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1737750465; a=rsa-sha256; cv=none; b=haqMAa6wkFbv0lz/vr+BSArhU8eFtV06Yz92LqyoaQcwIPO0X+rLQpfet5Mm9yF5LAqi+F FDqT//3t2kyeE6JhWq9iU6X322TgBgN0S4qQ4W0nhkhpPZfPVjUussqnyn3LlNNc/0PSwe IwVJhJfKuZrdRS0l5JnPpSOKA0gkaD1Ooo7Qf5NVOXEmqQ21Qjb1y3lkjH1TB6e7pHS3A2 r4+giF4/kCnBLxh97InNN4gk60REMwKBxh2BOcjGFj81b5XHiWBZRuc2//7Pb9NIrDkva2 Sb6R+YNqz4QwYSbkv0QD28hZx0ORH/x/mFo8J/h47Otp/89Hbz1Ja1f83nMAzg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4YfqB90Ywkzh7Y; Fri, 24 Jan 2025 20:27:45 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 50OKRiU3064629; Fri, 24 Jan 2025 20:27:44 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 50OKRiIe064626; Fri, 24 Jan 2025 20:27:44 GMT (envelope-from git) Date: Fri, 24 Jan 2025 20:27:44 GMT Message-Id: <202501242027.50OKRiIe064626@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ed Maste Subject: git: a9a6a51edac1 - main - github: Add new checklist workflow List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: emaste X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a9a6a51edac13aaff5517dd602272152efa6d7bd Auto-Submitted: auto-generated The branch main has been updated by emaste: URL: https://cgit.FreeBSD.org/src/commit/?id=a9a6a51edac13aaff5517dd602272152efa6d7bd commit a9a6a51edac13aaff5517dd602272152efa6d7bd Author: Ahmad Khalifa AuthorDate: 2025-01-05 05:01:07 +0000 Commit: Ed Maste CommitDate: 2025-01-24 20:27:08 +0000 github: Add new checklist workflow Add a new 'checklist' workflow that checks the commit messages on pull requests. Currently, the workflow creates a comment on the pull request if any of these conditions are hit: - Missing Signed-off-by - Malformed Signed-off-by - Bad email (i.e *noreply*) Reviewed by: emaste, imp Pull request: https://github.com/freebsd/freebsd-src/pull/1570 Signed-off-by: Ahmad Khalifa --- .github/workflows/checklist.yml | 106 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/.github/workflows/checklist.yml b/.github/workflows/checklist.yml new file mode 100644 index 000000000000..9734af4a1a1d --- /dev/null +++ b/.github/workflows/checklist.yml @@ -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 + 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 + "" + checklist[c].join(", ") + "\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." + }); + }