Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ Continuously inspect automatic E2E results for `main`. Coordinate ownership and
2. Keep release operations out of scope. Never change, retag, publish, or otherwise touch a release, tag, or release artifact during this workflow. Route release work to the existing release workflow.
3. Confirm maintainer authorization. Merge only when the request grants it. Otherwise, leave the PR `approval-ready` and continue the loop.
4. Check Git and GitHub access. Follow [Git and GitHub Access Hard Stop](../_shared/git-github-hard-stop.md) on access failure.
5. Fetch trusted `origin/main`. Read its PR-limit policy with `git show origin/main:.github/workflows/pr-limit.yaml`. For a non-exempt author, do not create a claim that would exceed that limit.

Do not declare success or end the loop because the queue is empty or the newest run passes. Wait for the next automatic `main` result.

Expand Down
45 changes: 24 additions & 21 deletions .github/workflows/pr-limit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@

name: Automation / PR Limit

# pull_request_target runs in the base repo context, giving the token write
# access even for fork PRs. This is safe here because this workflow never
# checks out or executes code from the PR — it only counts open PRs and
# closes excess ones. Do NOT add a checkout step or run PR-sourced code
# in this workflow to prevent injection attacks.
# pull_request_target runs in the base repository context. This workflow never
# checks out or executes pull request code.
on:
pull_request_target:
types: [opened, reopened]
Expand All @@ -19,33 +16,39 @@ jobs:
check-pr-limit:
runs-on: ubuntu-latest
timeout-minutes: 5
concurrency:
group: pr-limit-${{ github.repository }}-${{ github.event.pull_request.user.login }}
queue: max
cancel-in-progress: false
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
steps:
- name: Check open PR count for author
env:
GH_TOKEN: ${{ github.token }}
ACTION: ${{ github.event.action }}
AUTHOR: ${{ github.event.pull_request.user.login }}
PR_NUMBER: ${{ github.event.pull_request.number }}
REPO: ${{ github.repository }}
run: |
LIMIT=5

# Core maintainers are exempt from the PR limit.
EXEMPT="ericksoa kjw3 jacobtomlinson cv jyaunches"
for user in $EXEMPT; do
if [ "$AUTHOR" = "$user" ]; then
echo "Author $AUTHOR is a core maintainer — exempt from PR limit"
exit 0
fi
done

OPEN_COUNT=$(gh pr list --repo "$REPO" --author "$AUTHOR" --state open --json number --jq 'length')

echo "Author $AUTHOR has $OPEN_COUNT open PR(s)"
case "${AUTHOR,,}" in
apurvvkumaria|chengjiew|cjagwani|cv|dongni-yang|ericksoa|jyaunches|laitingsheng|prekshivyas|rluo8|rsliter|sandl99|senthilr-nv|tedy-y|tonyluo-nv|wscurran|yimoj)
LIMIT=10
;;
*)
LIMIT=5
;;
esac

OPEN_COUNT=$(gh api --paginate \
"repos/$REPO/issues?state=open&creator=$AUTHOR&sort=created&direction=asc&per_page=100" \
| jq --slurp --arg action "$ACTION" --argjson pr "$PR_NUMBER" \
'[.[][] | select(.pull_request and ($action == "reopened" or .number <= $pr))] | length')

echo "Author $AUTHOR has $OPEN_COUNT open PR(s); limit is $LIMIT"

if [ "$OPEN_COUNT" -gt "$LIMIT" ]; then
gh pr comment "$PR_NUMBER" --repo "$REPO" --body \
"This repository limits contributors to $LIMIT open pull requests. Please close or merge existing PRs before opening new ones."
"This repository limits you to $LIMIT open pull requests. Please close or merge an existing PR before opening another one."
gh pr close "$PR_NUMBER" --repo "$REPO"
Comment thread
cv marked this conversation as resolved.
Resolved
echo "::error::PR closed — author $AUTHOR exceeds the $LIMIT open PR limit"
echo "::error::PR closed because $AUTHOR exceeds the $LIMIT-open-PR limit"
exit 1
fi
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -344,4 +344,4 @@ If the command trace contains no reviewer-request write, report the event as an
- Direct PRs follow `.github/PULL_REQUEST_TEMPLATE.md`; the managed documentation workflow uses its generated body
- PRs that change `scripts/prepare-dgx-station-host.sh` must include reviewable DGX Station test evidence identifying the tested commit, Station profile or scenario, result, and a supporting link. Any maintainer may review the evidence; without acceptable evidence, the PR is not ready to approve or merge. Treat the evidence as human-reviewed, not authenticated hardware provenance. Exceptional bypasses use existing repository governance and must document the reason on the PR.
- No secrets, API keys, or credentials committed
- Apply the open PR limit from `.github/workflows/pr-limit.yaml` only to accounts that the workflow does not exempt
- Check `.github/workflows/pr-limit.yaml` for the contributor's open PR limit.
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,7 @@ For Markdown docs routing, user-skill guidance, and release-prep documentation w

## Pull Requests

We welcome contributions. Every PR requires maintainer review before merge. Contributors may have up to 5 open PRs at one time.
Core maintainers listed in `.github/workflows/pr-limit.yaml` are exempt from this limit.
We welcome contributions. Every PR requires maintainer review before merge. The default limit is 5 open PRs at one time.
Maintainers review pull requests according to project priority, security impact, release readiness, and reviewer availability.
PRs that solve issues with Priority set to Urgent or High are more likely to receive earlier review when maintainers have capacity.
For substantial features or behavior changes, start with a GitHub Discussion before opening a large implementation PR.
Expand Down Expand Up @@ -561,8 +560,9 @@ If the PR description is missing the DCO declaration, update the PR description
If any commit is missing GitHub verification, fix the branch before opening a PR.
If force-push is not allowed after an unverified commit is published, open a fresh branch and fresh PR with a clean compliant history.

> [!WARNING]
> Non-exempt accounts that repeatedly exceed this limit or submit automated bulk PRs may have their PRs closed or their access restricted.
When an opened or reopened PR exceeds the account's limit, automation comments on and closes that PR.

> Accounts that submit automated bulk PRs may have their PRs closed or their access restricted.

### No External Project Links

Expand Down
Loading