refactor: PR lifecycle bots#2363
Conversation
There was a problem hiding this comment.
Pull request overview
This PR consolidates multiple contributor/PR lifecycle scheduling bots into a single GitHub Actions workflow + Node script, aiming to reduce drift/bugs and make thresholds/skip-labels easier to configure while ensuring PRs are only auto-closed after human review.
Changes:
- Replaces three scheduled workflows and their scripts with a unified
bot-contributor-lifecycleworkflow +bot-contributor-lifecycle.js. - Adds Jest unit tests and a dedicated workflow to run them on PRs/pushes touching the bot code.
- Updates fork-testing documentation to describe configuring thresholds via workflow inputs instead of editing scripts.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/sdk_developers/training/testing_forks.md | Updates guidance for testing the new unified lifecycle bot via workflow inputs. |
| .github/workflows/test-bot-contributor-lifecycle.yml | Adds CI workflow to run Jest unit tests for the lifecycle bot. |
| .github/workflows/cron-reminder-pr-inactive.yml | Removes legacy PR inactivity reminder workflow. |
| .github/workflows/cron-reminder-issue-no-pr.yml | Removes legacy “issue assigned but no PR” reminder workflow. |
| .github/workflows/bot-inactivity-unassign.yml | Removes legacy inactivity unassign/close workflow. |
| .github/workflows/bot-contributor-lifecycle.yml | Adds unified scheduled + manually-triggerable lifecycle bot workflow. |
| .github/scripts/test-bot-inactivity-unassign.sh | Removes legacy bash test harness for the old bot. |
| .github/scripts/cron-reminder-pr-inactive.js | Removes legacy PR inactivity reminder script. |
| .github/scripts/cron-reminder-issue-no-pr.sh | Removes legacy issue reminder script. |
| .github/scripts/bot-inactivity-unassign.sh | Removes legacy inactivity unassign/close bash bot implementation. |
| .github/scripts/bot-contributor-lifecycle.js | Adds the consolidated lifecycle bot implementation (issues + linked PR logic). |
| .github/scripts/tests/bot-contributor-lifecycle.test.js | Adds unit tests validating reminder/unassign/close behavior and edge cases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughThis PR replaces three contributor automation scripts/workflows with a single JavaScript lifecycle bot, adds a scheduled/manual workflow and a matching test workflow, and updates the training docs for manual runs. ChangesContributor Lifecycle Bot Consolidation
Sequence Diagram(s)sequenceDiagram
participant bot_contributor_lifecycle_yml
participant actions_github_script
participant bot_contributor_lifecycle_js
participant github_rest_graphql_apis
bot_contributor_lifecycle_yml->>actions_github_script: pass thresholds, skip_pr_labels, DRY_RUN
actions_github_script->>bot_contributor_lifecycle_js: require(...) and invoke({ github, context })
bot_contributor_lifecycle_js->>github_rest_graphql_apis: list issues, comments, reviews, commits, and linkage
github_rest_graphql_apis-->>bot_contributor_lifecycle_js: issue and PR data
bot_contributor_lifecycle_js-->>actions_github_script: logs, counters, and failures
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📋 Issue PlannerLet us write the prompt for your AI agent so you can ship faster (with fewer bugs). View plan for ticket: ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 8
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: d240c32c-8ec1-4332-8fe0-0b698f5986c9
📒 Files selected for processing (12)
.github/scripts/__tests__/bot-contributor-lifecycle.test.js.github/scripts/bot-contributor-lifecycle.js.github/scripts/bot-inactivity-unassign.sh.github/scripts/cron-reminder-issue-no-pr.sh.github/scripts/cron-reminder-pr-inactive.js.github/scripts/test-bot-inactivity-unassign.sh.github/workflows/bot-contributor-lifecycle.yml.github/workflows/bot-inactivity-unassign.yml.github/workflows/cron-reminder-issue-no-pr.yml.github/workflows/cron-reminder-pr-inactive.yml.github/workflows/test-bot-contributor-lifecycle.ymldocs/sdk_developers/training/testing_forks.md
💤 Files with no reviewable changes (7)
- .github/workflows/bot-inactivity-unassign.yml
- .github/workflows/cron-reminder-pr-inactive.yml
- .github/scripts/bot-inactivity-unassign.sh
- .github/workflows/cron-reminder-issue-no-pr.yml
- .github/scripts/test-bot-inactivity-unassign.sh
- .github/scripts/cron-reminder-pr-inactive.js
- .github/scripts/cron-reminder-issue-no-pr.sh
d49373c to
a109278
Compare
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: aa9ea07b-0f4f-499e-8ca4-7686260f8240
📒 Files selected for processing (12)
.github/scripts/__tests__/bot-contributor-lifecycle.test.js.github/scripts/bot-contributor-lifecycle.js.github/scripts/bot-inactivity-unassign.sh.github/scripts/cron-reminder-issue-no-pr.sh.github/scripts/cron-reminder-pr-inactive.js.github/scripts/test-bot-inactivity-unassign.sh.github/workflows/bot-contributor-lifecycle.yml.github/workflows/bot-inactivity-unassign.yml.github/workflows/cron-reminder-issue-no-pr.yml.github/workflows/cron-reminder-pr-inactive.yml.github/workflows/test-bot-contributor-lifecycle.ymldocs/sdk_developers/training/testing_forks.md
💤 Files with no reviewable changes (7)
- .github/workflows/cron-reminder-pr-inactive.yml
- .github/workflows/cron-reminder-issue-no-pr.yml
- .github/scripts/cron-reminder-issue-no-pr.sh
- .github/workflows/bot-inactivity-unassign.yml
- .github/scripts/cron-reminder-pr-inactive.js
- .github/scripts/test-bot-inactivity-unassign.sh
- .github/scripts/bot-inactivity-unassign.sh
danielmarv
left a comment
There was a problem hiding this comment.
Thanks @exploreriii
One thing before merge i would like us to look into: handleNoPRStage and handlePRStage don't handle failures the same way.
In handleNoPRStage, users are unassigned before the reminder comment is posted, so even if commenting fails, the important action still happens.
In handlePRStage, it's the opposite: comments/PR closes happen first, and unassignment runs last. If a comment or close call throws, the function exits before anyone gets unassigned even if the comment already said they would be.
It'll recover on the next scheduled run, so it's not critical, but it weakens the main reliability guarantee of the bot on the PR path.
Left a note on the specific loop. Otherwise, the rest looks good.
danielmarv
left a comment
There was a problem hiding this comment.
Thanks @exploreriii
One thing before merge i would like us to look into: handleNoPRStage and handlePRStage don't handle failures the same way.
In handleNoPRStage, users are unassigned before the reminder comment is posted, so even if commenting fails, the important action still happens.
In handlePRStage, it's the opposite: comments/PR closes happen first, and unassignment runs last. If a comment or close call throws, the function exits before anyone gets unassigned even if the comment already said they would be.
It'll recover on the next scheduled run, so it's not critical, but it weakens the main reliability guarantee of the bot on the PR path.
Left a note on the specific loop. Otherwise, the rest looks good.
AntonioCeppellini
left a comment
There was a problem hiding this comment.
looking good to me, @danielmarv is a good point
Mounil2005
left a comment
There was a problem hiding this comment.
Thanks for letting me take a look at this! The consolidation looks good, and the test coverage is quite thorough.
+1 on what @danielmarv pointed out.
One small suggestion, unrelated to the above: right now the bot's === Summary === block only shows up in the raw Actions log, so you'd have to open the run and scroll through the console output to see what it did on a given day. We already have a precedent for surfacing this more visibly, pr-check-test-files.js writes to $GITHUB_STEP_SUMMARY (guarded behind if (process.env.GITHUB_STEP_SUMMARY), so it's a safe no-op outside CI). Might be worth doing the same here at the end of module.exports, turning the existing stats object into a small markdown table instead of just console output. Not blocking, just thought it'd be a nice quality-of-life improvement for visibility since this runs unattended every day.
Signed-off-by: exploreriii <133720349+exploreriii@users.noreply.github.com>
Signed-off-by: exploreriii <133720349+exploreriii@users.noreply.github.com>
|
👋 Hi @exploreriii! Great work completing a Advanced issue! 🎉 Thanks for your contribution! 🚀 Here are some issues you might want to explore next:
🌟 Stay connected: Happy coding! 🚀 |
Description:
Replaces three scheduling bots tackling contributor lifecycle with one github action.
Ensures configuration options are easy to change.
Changes auto close PR logic so it only auto closes after a review, and the stale time is met. It doesn't close on unreviewed PRs.
It also doesn't auto close on certain labels, which are now easier to handle (the label was changed previiously which is why it broke)
Bug fixes relating to pr linkage detection, jq over parsing and multiple assignees.
Keeps the new file as an isolated module, for now
Related issue(s):
Fixes #2362
Checklist