Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions .github/workflows/pr-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ jobs:
fi
printf '<!-- multi-ai-pr-review -->\n## Claude Code Review\n\n**Status: %s** — %s\n\nHEAD %s. [Bedrock review details](%s/%s/actions/runs/%s).\n' \
"$status" "$reason" "$HEAD" "$GITHUB_SERVER_URL" "$GITHUB_REPOSITORY" "$GITHUB_RUN_ID" > "$RUNNER_TEMP/review.md"
comment=$(gh api --paginate --slurp "repos/$GITHUB_REPOSITORY/issues/$PR/comments" \
--jq '[.[][] | select(.user.login == "github-actions[bot]" and (.body | startswith("<!-- multi-ai-pr-review -->")))] | last | .id // empty')
comment=$(gh api --paginate --slurp "repos/$GITHUB_REPOSITORY/issues/$PR/comments?per_page=100" |
jq -r '[.[][] | select(.user.login == "github-actions[bot]" and (.body | startswith("<!-- multi-ai-pr-review -->")))] | last | .id // empty')
if [[ -n "$comment" ]]; then
jq -Rs '{body: .}' "$RUNNER_TEMP/review.md" | \
gh api --silent -X PATCH "repos/$GITHUB_REPOSITORY/issues/comments/$comment" --input -
Expand Down
20 changes: 20 additions & 0 deletions scripts/v2/test_claude_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,26 @@ def git(*args):
validate(dict(result, **change), index, head)
self.assertEqual(paths, {"plain.ts", ":(glob)*.ts", "spaced ü.ts"})

def test_publisher_selects_the_last_bot_comment_across_pages(self):
workflow = yaml.safe_load((ROOT / ".github/workflows/pr-review.yml").read_text())
script = workflow["jobs"]["gate"]["steps"][0]["run"]
lookup = script.split("comment=$(", 1)[1].split(")\n", 1)[0]
# Validate the actual gh flag combination without authenticating or posting.
# gh rejects --slurp with --jq even when there are no comments.
self.assertIn("gh api --paginate --slurp", lookup)
self.assertNotIn("--jq", lookup)
jq = lookup.split("|\n", 1)[1].strip()
def select(pages):
return subprocess.run(["bash", "-euc", jq], input=json.dumps(pages),
text=True, capture_output=True, check=True).stdout.strip()
marker = "<!-- multi-ai-pr-review -->"
def comment(identifier, author, body):
return {"id": identifier, "user": {"login": author}, "body": body}
self.assertEqual(select([[]]), "")
self.assertEqual(select([[comment(1, "github-actions[bot]", marker)],
[comment(2, "reviewer", marker), comment(3, "github-actions[bot]", marker),
comment(4, "github-actions[bot]", "other check")]]), "3")

def test_action_uses_bedrock_and_all_results_gate_the_protected_check(self):
jobs = yaml.safe_load((ROOT / ".github/workflows/pr-review.yml").read_text())["jobs"]
model = jobs["claude"]
Expand Down
Loading