mirror of
https://github.com/frappe/erpnext.git
synced 2026-10-29 22:57:42 +00:00
ci(post-review): reply only where the PR author or a maintainer asked
This commit is contained in:
@@ -28,7 +28,7 @@ Text after a command is passed to the review as an extra instruction.
|
||||
|
||||
## Question a finding
|
||||
|
||||
If you are the PR author or a maintainer, reply in any of the bot's review threads, no mention needed. For example: "how can I reproduce this?" or "I think this is already handled in validate". The bot runs it on the bench, on develop and on your branch, and replies with the steps and what it saw. If the finding turns out to be wrong, it says so and resolves the thread.
|
||||
If you are the PR author or a maintainer, reply in any of the bot's review threads, no mention needed. For example: "how can I reproduce this?" or "I think this is already handled in validate". The bot runs it on the bench, on develop and on your branch, and replies with the steps and what it saw. If the finding turns out to be wrong, it says so and resolves the thread. In any other thread, such as a Greptile one, mention `@frappe-pr-bot`; it does not answer other bots.
|
||||
|
||||
## What to expect
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ on:
|
||||
required: true
|
||||
type: number
|
||||
review:
|
||||
description: base64 of a review JSON ({event, body, comments, replies, discussion, resolve, dismiss}); event must be COMMENT or REQUEST_CHANGES; replies are [{in_reply_to, body}] posted into existing threads; discussion is [body] posted as conversation comments; resolve is [thread node id] and only the bot's own unresolved threads on this PR are closed; dismiss is {reviews, message}, allowed only with COMMENT; reviews are [review id] and only the bot's own open change requests on this PR are dismissed
|
||||
description: base64 of a review JSON ({event, body, comments, replies, discussion, resolve, dismiss}); event must be COMMENT or REQUEST_CHANGES; replies are [{in_reply_to, body}] posted into existing threads where the PR author or a maintainer asked since the bot's last comment there, in the bot's own threads or where they mention @frappe-pr-bot; discussion is [body] posted as conversation comments; resolve is [thread node id] and only the bot's own unresolved threads on this PR are closed; dismiss is {reviews, message}, allowed only with COMMENT; reviews are [review id] and only the bot's own open change requests on this PR are dismissed
|
||||
required: false
|
||||
type: string
|
||||
default: ""
|
||||
@@ -88,10 +88,22 @@ jobs:
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
gh api --paginate "repos/${{ github.repository }}/pulls/$PR/comments" --jq '.[] | select(.user.login == "frappe-pr-bot" and .in_reply_to_id != null) | {body, in_reply_to: .in_reply_to_id}' > posted-replies.json
|
||||
jq -c --slurpfile posted posted-replies.json '(.replies // [])[] | {body, in_reply_to} | select(. as $reply | $posted | any(. == $reply) | not)' review.json | while read -r reply; do
|
||||
PR_AUTHOR=$(gh api "repos/${{ github.repository }}/pulls/$PR" --jq '.user.login')
|
||||
gh api --paginate "repos/${{ github.repository }}/pulls/$PR/comments" --jq '.[] | {id, thread: (.in_reply_to_id // .id), user: .user.login, type: .user.type, association: .author_association, body}' > pr-comments.json
|
||||
jq -c --slurpfile comments pr-comments.json '(.replies // [])[] | {body, in_reply_to} | select(. as $reply | $comments | any(.user == "frappe-pr-bot" and .id != .thread and .thread == $reply.in_reply_to and .body == $reply.body) | not)' review.json | while read -r reply; do
|
||||
printf '%s' "$reply" > reply.json
|
||||
gh api -X POST "repos/${{ github.repository }}/pulls/$PR/comments" --input reply.json --jq '.html_url'
|
||||
if jq -e --slurpfile comments pr-comments.json --arg author "$PR_AUTHOR" '
|
||||
.in_reply_to as $id | ($comments[] | select(.id == $id) | .thread) as $thread
|
||||
| [$comments[] | select(.thread == $thread)] as $thread_comments
|
||||
| ($thread_comments | any(.id == $thread and .user == "frappe-pr-bot")) as $own_thread
|
||||
| ([$thread_comments[] | select(.user == "frappe-pr-bot") | .id] | max // 0) as $last_bot_comment
|
||||
| $thread_comments | any(.id > $last_bot_comment and .type == "User"
|
||||
and (.user == $author or (.association | IN("OWNER", "MEMBER", "COLLABORATOR")))
|
||||
and ($own_thread or (.body | ascii_downcase | contains("@frappe-pr-bot"))))' reply.json > /dev/null; then
|
||||
gh api -X POST "repos/${{ github.repository }}/pulls/$PR/comments" --input reply.json --jq '.html_url'
|
||||
else
|
||||
echo "skipped the reply to $(jq -r '.in_reply_to' reply.json): not a thread on this PR with a new ask from the PR author or a maintainer" >&2
|
||||
fi
|
||||
done
|
||||
gh api --paginate "repos/${{ github.repository }}/issues/$PR/comments" --jq '.[] | select(.user.login == "frappe-pr-bot") | {body}' > posted-notes.json
|
||||
jq -c --slurpfile posted posted-notes.json '(.discussion // [])[] | {body: .} | select(. as $note | $posted | any(. == $note) | not)' review.json | while read -r note; do
|
||||
|
||||
Reference in New Issue
Block a user