Repository navigation
Ignore review markers posted by non-bot accounts #487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -216,7 +216,10 @@ test('expired EGM_TRIAGE_BOT_TOKEN (HTTP 401) falls back to GITHUB_TOKEN via get | |
|
|
||
| test('concurrent trigger race skips duplicate review when SHA marker already exists', async () => { | ||
| const state = createHarness({ | ||
| existingReviews: [{ body: '<!-- egm-triage-review:sha=abc12345 -->\nClean pass.' }], | ||
| existingReviews: [{ | ||
| user: { login: 'egm-triage-bot', type: 'User' }, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non-blocking suggestion: updating this case to
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added tests for |
||
| body: '<!-- egm-triage-review:sha=abc12345 -->\nClean pass.', | ||
| }], | ||
| }) | ||
| await state.run({ | ||
| action: 'clean_handoff', | ||
|
|
@@ -237,3 +240,67 @@ test('concurrent trigger race skips duplicate review when SHA marker already exi | |
| assert.equal(state.labels.size, 0) | ||
| assert.ok(state.infos.some(msg => /already present/.test(msg))) | ||
| }) | ||
|
|
||
| test('SHA marker from the GITHUB_TOKEN fallback bot skips duplicate review', async () => { | ||
| const state = createHarness({ | ||
| existingReviews: [{ | ||
| user: { login: 'github-actions[bot]', type: 'Bot' }, | ||
| body: '<!-- egm-triage-review:sha=abc12345 -->\nClean pass.', | ||
| }], | ||
| }) | ||
| await state.run({ | ||
| action: 'clean_handoff', | ||
| pr_number: 42, | ||
| head_sha: 'abc12345', | ||
| add_labels: ['triage: passed'], | ||
| remove_labels: [], | ||
| team_reviewers: ['egm-maintainers'], | ||
| review_payload: { commit_id: 'abc12345', body: 'Clean pass.', comments: [] }, | ||
| }) | ||
| assert.equal(state.failed, null) | ||
| assert.equal(state.reviews.length, 1) | ||
| assert.equal(state.labels.size, 0) | ||
| }) | ||
|
|
||
| test('SHA marker from a deleted reviewer does not suppress the bot review', async () => { | ||
| const state = createHarness({ | ||
| existingReviews: [{ user: null, body: '<!-- egm-triage-review:sha=abc12345 -->' }], | ||
| }) | ||
| await state.run({ | ||
| action: 'clean_handoff', | ||
| pr_number: 42, | ||
| head_sha: 'abc12345', | ||
| add_labels: ['triage: passed'], | ||
| remove_labels: [], | ||
| team_reviewers: ['egm-maintainers'], | ||
| review_payload: { commit_id: 'abc12345', body: 'Clean pass.', comments: [] }, | ||
| }) | ||
| assert.equal(state.failed, null) | ||
| assert.equal(state.reviews.length, 2) | ||
| assert.deepEqual([...state.labels], ['triage: passed']) | ||
| }) | ||
|
|
||
| test('SHA marker in a human review does not suppress the bot review', async () => { | ||
| const state = createHarness({ | ||
| existingReviews: [{ | ||
| user: { login: 'alice', type: 'User' }, | ||
| body: '<!-- egm-triage-review:sha=abc12345 -->', | ||
| }], | ||
| }) | ||
| await state.run({ | ||
| action: 'clean_handoff', | ||
| pr_number: 42, | ||
| head_sha: 'abc12345', | ||
| add_labels: ['triage: passed'], | ||
| remove_labels: [], | ||
| team_reviewers: ['egm-maintainers'], | ||
| review_payload: { | ||
| commit_id: 'abc12345', | ||
| body: '<!-- egm-triage-review:sha=abc12345 -->\nClean pass.', | ||
| comments: [], | ||
| }, | ||
| }) | ||
| assert.equal(state.failed, null) | ||
| assert.equal(state.reviews.length, 2) | ||
| assert.deepEqual([...state.labels], ['triage: passed']) | ||
| }) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -259,6 +259,46 @@ def test_evaluate_sweep_gate_uses_author_association_dynamically() -> None: | |
| assert not same_sha.should_review | ||
| assert same_sha.reason == "SKIP_SHA_ALREADY_REVIEWED:deadbeef" | ||
|
|
||
| triage_bot = { | ||
| "user": {"login": "egm-triage-bot", "type": "User"}, | ||
| "author_association": "MEMBER", | ||
| "body": "<!-- egm-triage-review:sha=deadbeef -->", | ||
| } | ||
| for reviews, issue_comments in (([triage_bot], []), ([], [triage_bot])): | ||
| bot_marker = review_pr.evaluate_sweep_gate( | ||
| { | ||
| "state": "open", | ||
| "draft": False, | ||
| "body": VALID_PR_BODY, | ||
| "user": {"login": "alice"}, | ||
| "head": {"sha": "deadbeef"}, | ||
| }, | ||
| reviews=reviews, | ||
| issue_comments=issue_comments, | ||
| files=[{"filename": "README.md", "changes": 4}], | ||
| ) | ||
| assert bot_marker.reason == "SKIP_SHA_ALREADY_REVIEWED:deadbeef" | ||
|
|
||
| spoofed = { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Non-blocking suggestion:
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added cases for an |
||
| "user": {"login": "alice", "type": "User"}, | ||
| "author_association": "CONTRIBUTOR", | ||
| "body": "<!-- egm-triage-review:sha=deadbeef -->", | ||
| } | ||
| for reviews, issue_comments in (([spoofed], []), ([], [spoofed])): | ||
| human_marker = review_pr.evaluate_sweep_gate( | ||
| { | ||
| "state": "open", | ||
| "draft": False, | ||
| "body": VALID_PR_BODY, | ||
| "user": {"login": "alice"}, | ||
| "head": {"sha": "deadbeef"}, | ||
| }, | ||
| reviews=reviews, | ||
| issue_comments=issue_comments, | ||
| files=[{"filename": "README.md", "changes": 4}], | ||
| ) | ||
| assert human_marker.should_review | ||
|
|
||
|
|
||
| def test_sanitization_nonce_boundary_and_source_first_diff_packing() -> None: | ||
| # Strips duplicate [High]: prefixes, BLUF labels, and neutralizes @mentions | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.