diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 000000000..e1375fdce --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,25 @@ + + +### Rationale for this change + +### What changes are included in this PR? + +### Are these changes tested? + +### Are there any user-facing changes? + +### Was AI used for this PR? + + + +**Reviewed by:** + +- [ ] Human +- [ ] AI +- [ ] Not reviewed diff --git a/.github/workflows/pr-description.yml b/.github/workflows/pr-description.yml new file mode 100644 index 000000000..d1429358a --- /dev/null +++ b/.github/workflows/pr-description.yml @@ -0,0 +1,79 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +name: PR description + +on: + pull_request: + types: [opened, edited, reopened, synchronize, ready_for_review] + +permissions: {} + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + check-description: + if: ${{ !github.event.pull_request.draft && github.event.pull_request.user.login != 'dependabot[bot]' }} + runs-on: ubuntu-slim + steps: + - name: Check required sections + shell: python + run: | + import json + import os + import re + import sys + + with open(os.environ["GITHUB_EVENT_PATH"]) as event: + body = json.load(event)["pull_request"]["body"] or "" + body = re.sub(r"|\Z)", "", body, flags=re.DOTALL) + + filled = set() + review_section = "Who reviewed this PR before submission (including self-review)?" + reviewed_by = set() + section = None + fence = "" + for line in body.splitlines(): + marker = re.match(r"^ {0,3}(`{3,}|~{3,})(.*)$", line) + if marker and not fence: + fence = marker[1] + elif marker and marker[1].startswith(fence) and not marker[2].strip(): + fence = "" + elif not fence and (heading := re.fullmatch(r" {0,3}##[ \t]+(.+)", line)): + section = re.sub(r"[ \t]+#+$", "", heading[1].strip()) + elif section == review_section: + choice = re.fullmatch(r" {0,3}[-*+] +\[[xX]\] +(Human|AI|Not reviewed)[ \t]*", line) + if not fence and choice: + reviewed_by.add(choice[1]) + elif section and line.strip(): + filled.add(section) + + required = [ + "What problem does this PR solve, and who is affected?", + "What changed, including any breaking API changes or critical fixes?", + "How did you test this change?", + "Was AI used for this PR? If so, how?", + ] + missing = [section for section in required if section not in filled] + if not reviewed_by: + missing.append(f"{review_section} (check at least one option)") + if missing: + sys.exit("Please fill in these sections in the PR description: " + ", ".join(missing)) + if "Not reviewed" in reviewed_by and len(reviewed_by) > 1: + sys.exit('Select "Not reviewed" only when neither Human nor AI is checked.')