Skip to content

Commit 2c688ca

Browse files
authored
chore(repo): Add new contributing guidelines and auto-close outside PRs open in "ready to review" status (#3218)
1 parent 59ff68b commit 2c688ca

File tree

2 files changed

+40
-4
lines changed

2 files changed

+40
-4
lines changed

.github/workflows/vouch-check-pr.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ permissions:
1010
issues: read
1111

1212
jobs:
13-
check-pr:
13+
check-vouch:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- uses: mitchellh/vouch/action/check-pr@c6d80ead49839655b61b422700b7a3bc9d0804a9 # v1.4.2
@@ -20,3 +20,25 @@ jobs:
2020
require-vouch: true
2121
env:
2222
GH_TOKEN: ${{ github.token }}
23+
24+
require-draft:
25+
needs: check-vouch
26+
if: >
27+
github.event.pull_request.draft == false &&
28+
github.event.pull_request.author_association != 'MEMBER' &&
29+
github.event.pull_request.author_association != 'OWNER' &&
30+
github.event.pull_request.author_association != 'COLLABORATOR'
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Close non-draft PR
34+
env:
35+
GH_TOKEN: ${{ github.token }}
36+
run: |
37+
STATE=$(gh pr view ${{ github.event.pull_request.number }} --repo ${{ github.repository }} --json state -q '.state')
38+
if [ "$STATE" != "OPEN" ]; then
39+
echo "PR is already closed, skipping."
40+
exit 0
41+
fi
42+
gh pr close ${{ github.event.pull_request.number }} \
43+
--repo ${{ github.repository }} \
44+
--comment "Thanks for your contribution! We require all external PRs to be opened in **draft** status first so you can address CodeRabbit review comments and ensure CI passes before requesting a review. Please re-open this PR as a draft. See [CONTRIBUTING.md](https://github.com/${{ github.repository }}/blob/main/CONTRIBUTING.md#pr-workflow) for details."

CONTRIBUTING.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,23 @@ See the [Job Catalog](./references/job-catalog/README.md) file for more.
242242

243243
**If you get errors, be sure to fix them before committing.**
244244

245-
- Be sure to [check the "Allow edits from maintainers" option](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork) while creating you PR.
246-
- If your PR refers to or fixes an issue, be sure to add `refs #XXX` or `fixes #XXX` to the PR description. Replacing `XXX` with the respective issue number. See more about [Linking a pull request to an issue
247-
](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue).
245+
> **Note:** We may close PRs if we decide that the cost of integrating the change outweighs the benefits. To improve the chances of your PR getting accepted, follow the guidelines below.
246+
247+
### PR workflow
248+
249+
1. **Always open your PR in draft status first.** Do not mark it as "Ready for Review" until the steps below are complete.
250+
2. **Address all CodeRabbit code review comments.** Our CI runs an automated code review via CodeRabbit. Go through each comment and either fix the issue or resolve it with a comment explaining why no change is needed.
251+
3. **Wait for all CI checks to pass.** Do not mark the PR as "Ready for Review" until every check is green.
252+
4. **Then mark the PR as "Ready for Review"** so a maintainer can take a look.
253+
254+
### Cost/benefit analysis for risky changes
255+
256+
If your change touches core infrastructure, modifies widely-used code paths, or could introduce regressions, consider doing a brief cost/benefit analysis and including it in the PR description. Explain what the benefit is to users and why the risk is worth it. This goes a long way toward helping maintainers evaluate your contribution.
257+
258+
### General guidelines
259+
260+
- Be sure to [check the "Allow edits from maintainers" option](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork) while creating your PR.
261+
- If your PR refers to or fixes an issue, be sure to add `refs #XXX` or `fixes #XXX` to the PR description. Replacing `XXX` with the respective issue number. See more about [Linking a pull request to an issue](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue).
248262
- Be sure to fill the PR Template accordingly.
249263

250264
## Adding changesets

0 commit comments

Comments
 (0)