feat: add PR draft explainer workflow #1907
feat: add PR draft explainer workflow #1907parvninama wants to merge 14 commits intohiero-ledger:mainfrom
Conversation
Signed-off-by: Parv Ninama <ninamaparv@gmail.com>
Signed-off-by: Parv Ninama <ninamaparv@gmail.com>
|
Hi @parvninama, this is **LinkBot** 👋
Linking pull requests to issues helps us significantly with reviewing pull requests and keeping the repository healthy. 🚨 This pull request does not have an issue linked. Please link an issue using the following format: 📖 Guide: If no issue exists yet, please create one: Thanks! |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #1907 +/- ##
=======================================
Coverage 93.53% 93.53%
=======================================
Files 141 141
Lines 9146 9146
=======================================
Hits 8555 8555
Misses 591 591 🚀 New features to boost your workflow:
|
Signed-off-by: Parv <ninamaparv@gmail.com>
Signed-off-by: Parv <ninamaparv@gmail.com>
|
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:
WalkthroughAdds a GitHub Actions workflow and a companion script that runs when a PR is converted to draft (or manually). The script paginates comments to avoid duplicates, checks for CHANGES_REQUESTED reviews, supports DRY_RUN, and posts a formatted explainer comment or skips with safe logging. Changes
Sequence Diagram(s)sequenceDiagram
participant GHA as GitHub Actions
participant Script as Bot Script
participant CommentsAPI as PR Comments API
participant ReviewsAPI as PR Reviews API
GHA->>Script: Trigger (converted_to_draft or manual)
activate Script
Script->>Script: Resolve PR number & validate payload/env
Script->>CommentsAPI: List comments (paginated)
activate CommentsAPI
CommentsAPI-->>Script: Return comments
deactivate CommentsAPI
Script->>Script: Check for duplicate marker
alt Duplicate found
Script-->>GHA: Exit (skip posting)
else No duplicate
Script->>ReviewsAPI: List PR reviews
activate ReviewsAPI
ReviewsAPI-->>Script: Return reviews
deactivate ReviewsAPI
Script->>Script: Check for CHANGES_REQUESTED
alt CHANGES_REQUESTED exists
Script->>CommentsAPI: Create explanation comment (or simulate in DRY_RUN)
activate CommentsAPI
CommentsAPI-->>Script: Comment created
deactivate CommentsAPI
Script-->>GHA: Log success
else No CHANGES_REQUESTED
Script-->>GHA: Skip posting
end
end
deactivate Script
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: b1d0cf0b-f2f9-4c7b-9731-4096255aba42
📒 Files selected for processing (3)
.github/scripts/bot-pr-draft-explainer.js.github/workflows/bot-pr-draft-explainer.yamlCHANGELOG.md
Signed-off-by: Parv <ninamaparv@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 0dc19081-d61e-4017-94ca-8eb9cae9211a
📒 Files selected for processing (1)
.github/scripts/bot-pr-draft-explainer.js
Co-authored-by: Manish Dait <90558243+manishdait@users.noreply.github.com> Signed-off-by: Parv <ninamaparv@gmail.com>
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (1)
.github/scripts/bot-pr-draft-explainer.js (1)
13-15: 🧹 Nitpick | 🔵 TrivialConsider parsing
manualPRNumberfor type safety.When
prNumbercomes frompr?.numberit's a number, but fromprocess.env.PR_NUMBERit's a string. While GitHub's API coerces strings, explicit parsing catches invalid input early.♻️ Suggested improvement
const COMMENT_MARKER = "<!-- pr-draft-explainer -->"; const DRY_RUN = process.env.DRY_RUN === "true"; -const manualPRNumber = process.env.PR_NUMBER; +const manualPRNumber = process.env.PR_NUMBER ? parseInt(process.env.PR_NUMBER, 10) : undefined;Then update validation in main function:
let prNumber = pr?.number || manualPRNumber; const { owner, repo } = context.repo; - if (!prNumber) { + if (!prNumber || Number.isNaN(prNumber)) { console.log("No PR number found in payload or environment. Exiting."); return; }
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 49e123db-095e-4dca-887e-f499d85958c6
📒 Files selected for processing (1)
.github/scripts/bot-pr-draft-explainer.js
…xplainer bot Signed-off-by: Parv <ninamaparv@gmail.com>
|
Hi, this is WorkflowBot.
|
|
@manishdait Thanks for the review! I've addressed the requested changes :) |
|
Hi, this is MergeConflictBot. Please resolve these conflicts locally and push the changes. Quick Fix for CHANGELOG.md ConflictsIf your conflict is only in CHANGELOG.md, you can resolve it easily using the GitHub web editor:
For all other merge conflicts, please read: Thank you for contributing! |
Signed-off-by: Parv <ninamaparv@gmail.com>
Signed-off-by: Parv <ninamaparv@gmail.com>
|
Hello, this is the OfficeHourBot. This is a reminder that the Hiero Python SDK Office Hours are scheduled in approximately 4 hours (14:00 UTC). This session provides an opportunity to ask questions regarding this Pull Request. Details:
Disclaimer: This is an automated reminder. Please verify the schedule here for any changes. From, |
Added :
pull_request: converted_to_draftbot-pr-draft-explainer.jsto handle the automation logicCHANGES_REQUESTEDreview existsworkflow_dispatchwithdry_runsupport for manual testingTesting :
The workflow was tested using
workflow_dispatchwithDRY_RUN=true.PR not draft
https://github.com/parvninama/hiero-sdk-python/actions/runs/22733624043/job/65929092608
Draft PR without
CHANGES_REQUESTEDhttps://github.com/parvninama/hiero-sdk-python/actions/runs/22734149228/job/65930898806
Draft PR with
CHANGES_REQUESTEDhttps://github.com/parvninama/hiero-sdk-python/actions/runs/22733854438/job/65929873543
Linked Issue :