diff --git a/.github/workflows/pr-checklist.yml b/.github/workflows/pr-checklist.yml new file mode 100644 index 0000000..34f5540 --- /dev/null +++ b/.github/workflows/pr-checklist.yml @@ -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."