Skip to content
Merged
Changes from 3 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
43 changes: 43 additions & 0 deletions .github/workflows/pr-checklist.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: PR Checklist

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

jobs:
check-pr-template:
runs-on: ubuntu-latest
steps:
Comment thread
freakboy3742 marked this conversation as resolved.
- name: Check PR body
env:
PR_BODY: ${{ github.event.pull_request.body }}
run: |
require() {
if ! grep -qE -- "$1" <<< "$PR_BODY"; then
echo "::error::$2"
exit 1
fi
}

require "^[[:space:]]*## PR Checklist:" \
"Could not find the BeeWare PR checklist in the pull request comment. This probably means you've used a tool to submit your PR, rather than the GitHub UI. The BeeWare project provides, and requires the use of a standard template for all PRs. Your PR will be ignored until/unless you add the required components of the template. See https://beeware.org/contributing/guide/how/submit-pr/ for details."

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This link isn't helpful, because it doesn't mention the template anywhere. And even if it did, the user still doesn't have any easy way to restore the template if they deleted it before submitting the PR.

Can we include a link to the template content in the .github repository, along with instructions for how to edit the PR's top comment to include it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Would we like an edit to that page or another? CONTRIBUTING.md in the repo has the template I believe.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, we should probably update the contribution guide to make it clear that you must keep the template and follow its instructions, and to provide a link to its source in case they've already deleted it. But I don't think the guide should go into any detail about the template content, because the template should be self-explanatory, and we want to keep the flexibility to update it whenever we want.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've just pushed beeware/beeware-docs-tools#231 to address this need.


require "^[[:space:]]*- \[\s*[xX]\s*\] I will abide by the BeeWare Code of Conduct" \
"The 'Code of Conduct' checkbox in the PR checklist must be checked."

require "^[[:space:]]*- \[\s*[xX]\s*\] I have read and have followed the \*\*CONTRIBUTING.md\*\* file" \
"The 'CONTRIBUTING.md' checkbox in the PR checklist must be checked."

if grep -qE -- "^[[:space:]]*- \[\s*[xX]\s*\] This PR was generated or assisted using an AI tool" <<< "$PR_BODY"; then
require "^[[:space:]]*(-\s+)?Assisted-by:" "'Assisted-by:' line is missing."

# Extract the value, strip HTML comments and whitespace
ASSISTED_BY_VAL=$(grep -E "^[[:space:]]*(-\s+)?Assisted-by:" <<< "$PR_BODY" | sed -r -e 's/^[[:space:]]*(-\s+)?Assisted-by://' -e 's/<!--.*-->//' | tr -d '[:space:]')
if [ -z "$ASSISTED_BY_VAL" ]; then
echo "::error::You checked the AI tool checkbox in the PR template, but did not specify the tool that was used in 'Assisted-by:'."
exit 1
fi
fi

echo "PR Checklist verification passed."
Loading