From 992be92da3403ba8db0ad3124996673b7ae862db Mon Sep 17 00:00:00 2001
From: David Li
Date: Fri, 7 Feb 2025 15:22:33 +0900
Subject: [PATCH] GH-499: Require PR labels for changelog
---
.github/workflows/dev_pr.yml | 72 ++++++++++++++++++++++++++++++++++++
CONTRIBUTING.md | 34 ++++++++++++++++-
2 files changed, 104 insertions(+), 2 deletions(-)
create mode 100644 .github/workflows/dev_pr.yml
diff --git a/.github/workflows/dev_pr.yml b/.github/workflows/dev_pr.yml
new file mode 100644
index 000000000..b24ac26d9
--- /dev/null
+++ b/.github/workflows/dev_pr.yml
@@ -0,0 +1,72 @@
+# 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: Dev PR
+
+on:
+ pull_request_target:
+ types:
+ - labeled
+ - unlabeled
+ - opened
+ - edited
+ - reopened
+ - synchronize
+ - ready_for_review
+ - review_requested
+
+concurrency:
+ group: ${{ github.repository }}-${{ github.ref }}-${{ github.workflow }}
+ cancel-in-progress: true
+
+permissions:
+ contents: read
+
+jobs:
+ pr-label:
+ name: "Ensure PR format"
+ runs-on: ubuntu-latest
+ steps:
+ - name: Ensure PR is labeled
+ env:
+ LABELS: ${{ toJson(github.event.pull_request.labels) }}
+ run: |
+ if ! echo "$LABELS" | jq -e '.[] | select(.name | IN("bug-fix", "dependencies", "enhancement")) | .name'; then
+ echo "Label the PR with one or more of:"
+ echo "- bug-fix"
+ echo "- dependencies"
+ echo "- enhancement"
+ echo
+ echo "Also, add 'breaking-change' if appropriate."
+ exit 1
+ else
+ echo "Pull request is labeled properly!"
+ fi
+
+ - name: Ensure PR title format
+ env:
+ TITLE: ${{ toJson(github.event.pull_request.title) }}
+ run: |
+ set -x
+ if echo $TITLE | grep --extended-regexp "^MINOR: .*$" >/dev/null; then
+ echo "This is a MINOR PR."
+ elif echo $TITLE | grep --extended-regexp "^GH-[0-9]+: .*$" >/dev/null; then
+ echo "This is a normal PR."
+ else
+ echo "PR title format is incorrect. Please see CONTRIBUTING.md."
+ exit 1
+ fi
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 8388b1d6c..a1c3e9a95 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -30,8 +30,38 @@ existing Arrow issues in [GitHub](https://github.com/apache/arrow-java/issues).
## Did you write a patch that fixes a bug or brings an improvement?
-Create a GitHub issue and submit your changes as a GitHub Pull Request.
-Please make sure to [reference the issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword) in your PR description.
+- Create a GitHub issue and submit your changes as a GitHub Pull Request.
+- [Reference the issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/using-issues/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword) in your PR description.
+- Add one or more of the labels "bug-fix", "dependencies", and "enhancement" to your PR as appropriate.
+ - "bug-fix" is for PRs that fix a bug.
+ - "dependencies" is for PRs that upgrade a dependency or other administrative work (build system, release process, etc.).
+ - "enhancement" is for PRs that add new features.
+- Add the "breaking-change" label to your PR if there are breaking API changes.
+- Add the PR title. The PR title will be used as the eventual commit message, so please make it descriptive but succinct.
+
+Example #1:
+
+```
+GH-12345: Document the pull request process
+
+Explain how to open a pull request and what the title, body, and labels should be.
+
+Closes #12345.
+
+Labels: dependencies
+```
+
+Example #2:
+
+```
+GH-42424: Expose Netty server builder in Flight
+
+Allow direct usage of gRPC APIs for low-level control.
+
+Closes #42424.
+
+Labels: enhancement
+```
### Minor Fixes