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

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

jobs:
check-pr-template:
name: Check PR template
runs-on: ubuntu-latest
steps:
- 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."

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