Skip to content
Open
Show file tree
Hide file tree
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
25 changes: 25 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!--
Thanks for opening a pull request!

If this is your first pull request you can find detailed information on how to contribute here: [Contributing Overview](https://cpp.iceberg.apache.org/contributing/)
-->

### 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?

<!--
In accordance to the [Guidelines for AI-assisted Contributions](https://iceberg.apache.org/contribute/#guidelines-for-ai-assisted-contributions), please disclose below whether and how AI was used in this PR.
-->

**Reviewed by:**

- [ ] Human
- [ ] AI
- [ ] Not reviewed
79 changes: 79 additions & 0 deletions .github/workflows/pr-description.yml
Original file line number Diff line number Diff line change
@@ -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.')
Loading