From 2c856c6d2766e8b88f4e1ed2b29ceeb3dcbe790b Mon Sep 17 00:00:00 2001 From: Alison Shao <54658187+alisonshao@users.noreply.github.com> Date: Fri, 27 Feb 2026 10:14:57 -0800 Subject: [PATCH] Allow PR authors to use /rerun-failed-ci on their own PRs (#19496) Co-authored-by: Alison Shao --- docs/developer_guide/contribution_guide.md | 4 +++- scripts/ci/utils/slash_command_handler.py | 26 +++++++++++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/docs/developer_guide/contribution_guide.md b/docs/developer_guide/contribution_guide.md index dde033771..5f78456a2 100644 --- a/docs/developer_guide/contribution_guide.md +++ b/docs/developer_guide/contribution_guide.md @@ -73,6 +73,8 @@ Then your PR can be merged. We have a lot of open PRs but limited CI machines, so only top and trusted contributors have permission to trigger CI tests. Users with permission are listed in the [CI_PERMISSIONS.json](https://github.com/sgl-project/sglang/blob/main/.github/CI_PERMISSIONS.json) +**PR authors** can always use `/rerun-failed-ci` on their own PRs, even if they are not listed in `CI_PERMISSIONS.json`. + For CI to run on a pull request, it must have the "run-ci" label. Authorized users can add the label or rerun failed tests by commenting on the PR with one of these commands: - `/tag-run-ci-label`: Adds the "run-ci" label. Every future commit will trigger CI. @@ -86,7 +88,7 @@ To avoid spamming a PR with too many `/rerun-failed-ci` comments, you can also t Example of rerunning a single test stage: `/rerun-stage unit-test-backend-4-gpu`. -If you don’t have permission, please ask maintainers to trigger CI for you. +If you don’t have permission and you’re not the PR author, please ask maintainers to trigger CI for you. ### CI rate limits diff --git a/scripts/ci/utils/slash_command_handler.py b/scripts/ci/utils/slash_command_handler.py index 9e7f98f87..d06b541d2 100644 --- a/scripts/ci/utils/slash_command_handler.py +++ b/scripts/ci/utils/slash_command_handler.py @@ -415,13 +415,9 @@ def main(): comment_body = get_env_var("COMMENT_BODY").strip() user_login = get_env_var("USER_LOGIN") - # 2. Load Permissions (Local Check) + # 2. Load Permissions (local file check first to avoid unnecessary API calls) user_perms = load_permissions(user_login) - if not user_perms: - print(f"User {user_login} does not have any configured permissions. Exiting.") - return - # 3. Initialize GitHub API with Auth auth = Auth.Token(token) g = Github(auth=auth) @@ -430,6 +426,26 @@ def main(): pr = repo.get_pull(pr_number) comment = repo.get_issue(pr_number).get_comment(comment_id) + # PR authors can always rerun failed CI on their own PRs, + # even if they are not listed in CI_PERMISSIONS.json. + # Note: /tag-run-ci-label and /rerun-stage still require CI_PERMISSIONS.json. + if pr.user.login == user_login: + if user_perms is None: + print( + f"User {user_login} is the PR author (not in CI_PERMISSIONS.json). " + "Granting CI rerun permissions." + ) + user_perms = {} + else: + print( + f"User {user_login} is the PR author and has existing CI permissions." + ) + user_perms["can_rerun_failed_ci"] = True + + if not user_perms: + print(f"User {user_login} does not have any configured permissions. Exiting.") + return + # 4. Parse Command and Execute first_line = comment_body.split("\n")[0].strip()