Repository navigation
YETUS-1280. Support updating or hiding prior GitHub PR comments - #405
Conversation
--github-update-comment[=<key>] implies --github-write-comment, and updates the comment the token's user previously wrote with the same key instead of adding a new one on every run. The report is skipped when the PR head moved past the tested commit. Assisted-by: Claude Opus 5.5
|
Tested end to end against real GitHub on pan3793/yetus-comment-test#1, running
The marker does not show in the rendered comment. The stale-build skip is covered by |
|
cc @aw-was-here @ndimiduk, could you please take a look? The current Yetus report (post a new comment for each report) keeps spamming the PR and makes it too hard for reviewers to find the real review comment ... |
|
ACK. I'll make time to take a look in the next couple days, if Allen doesn't beat me to it. |
|
friendly ping @ndimiduk ~ |
|
So my preference is against editing an existing comment in place. I would rather than the automation hides the out-of-date comment and posts a new one. That way everyone gets a notification about the new activity and the history of results is available for those who are interested. All that said, I'm not opposed to the plugin supporting either mode. I think there's good arguments for each depending on what checks are managed via Yetus. |
|
Jogging my memory... I implemented the hide-and-post behavior in https://issues.apache.org/jira/browse/HBASE-28642 . It would be excellent if we could get both behaviors into Yetus as variants on a feature. |
Replace --github-update-comment with --github-comment-mode=<append|update|hide> and --github-comment-key=<key>. In hide mode, post a new comment and minimize prior visible comments written by the same GitHub user with the same key via GraphQL minimizeComment (classifier: OUTDATED). Assisted-by: Gemini 4 Neon
|
Thanks for the feedback and the pointer to HBASE-28642. Added both modes in 006c3b2 via
Verified both modes end to end on pan3793/yetus-comment-test#1 ( |
Assisted-by: Gemini 4 Neon
|
also cc @cxzl25 |
ndimiduk
left a comment
There was a problem hiding this comment.
A few smaller items:
-
Token identity.
GET /userisn't available to GitHub App installation tokens. Plain/useris missing from https://docs.github.com/en/rest/authentication/endpoints-available-for-github-app-installation-access-tokens. Outside GitHub Actions, an App token makesupdateandhidebehave asappend, with one warning per run. Under GitHub Actions with an App token passed as--github-token, the login silently becomesgithub-actions[bot], nothing matches, and nothing is logged (L985-988). Nothing gets written to the wrong comment. But "the mode isn't working" is invisible in this case, so a log line when the fallback login is assumed would help. -
Silent list failure. A failed comment-list GET (L1020-1029) returns 1 with no log line. In
updatemode this is the quietest route to the duplicate described on L1167, and the run log looks the same as a first run. -
Tests. A few behavior-changing mutations pass
github_comment_mode.bats:- Making the
idlookup print every match instead of only the oldest. The PATCH URL becomescomments/2<newline>3, which real curl rejects, butoutcome()still reportsPATCH:2. - Applying the
github-actions[bot]fallback for every robot rather than onlygithubactions. - Treating a missing
github-pull.json(empty tested sha) as superseded.
Asserting exactly one PATCH to the expected id, a jenkins fixture with a
github-actions[bot]comment that expects a POST, and a finalreport case withoutgithub-pull.jsonwould cover these. - Making the
(LLM assisted)
| rm "${restfile}" | ||
| return 0 | ||
| fi | ||
| yetus_error "WARNING: Cannot update GitHub comment ${commentid}. Writing a new one." |
There was a problem hiding this comment.
In update mode, a single failed write leaves a second keyed comment that no later run touches. The trigger is any of: the PATCH failing (here), the comment-list GET failing (L1020-1029), or GET /user failing (L1014-1016). Each of these falls through to the POST. On the next run github_find_comments ... id again returns the oldest match (the awk print id; exit at L1047-1048 and the early return at L1057-1058), so the older comment keeps getting PATCHed. The newer one sits below it in the thread with a stale result for the rest of the PR's life. Nothing in the update branch looks at the other matches.
Reproduced with a stub curl: run 1 PATCHes comment 2, the PATCH fails, and it POSTs comment 3. Run 2, with comments 2 and 3 both visible, PATCHes comment 2 and leaves comment 3 as it was.
The hide branch already collects every visible match and minimizes it. Running that over the other matches after a successful PATCH would let update converge back to one visible report.
(LLM assisted)
There was a problem hiding this comment.
Fixed in 45b08fd. github_find_comments collects all visible matching <id> <node_id> pairs across pages, and github_write_report_comment minimizes extra visible duplicates as OUTDATED after a successful PATCH in update mode.
| return 0 | ||
| fi | ||
|
|
||
| if github_comment_mode_active; then |
There was a problem hiding this comment.
The marker is added for every caller of github_write_comment, not only the final report. write_comment in test-patch.sh sends the "(!) A patch to the testing environment has been detected. Re-executing..." note through this hook:
yetus/precommit/src/main/shell/test-patch.sh
Lines 1603 to 1608 in 8e12479
That fires under --robot when the PR touches the personality or the Dockerfile. In update mode the note replaces the previous report. If the re-executed run is aborted, or its final report is skipped because the head moved, the 3-line note stays as the only visible report until the next completed run. The interim path also bypasses the superseded check and the Tested commit row, both of which live in github_finalreport_as_comment. The docs (github.html.md L64) say only that "the report" carries the marker.
github_write_comment is @audience public / @stability stable. Keeping it append-only and applying the modes from github_finalreport_as_comment would avoid changing what other callers get.
(LLM assisted)
There was a problem hiding this comment.
Fixed in 45b08fd. github_write_comment stays append-only for public callers, and update/hide handling lives in private github_write_report_comment invoked only by github_finalreport_as_comment.
| append) | ||
| GITHUB_COMMENT_MODE=append | ||
| ;; | ||
| update|hide) | ||
| GITHUB_COMMENT_MODE=${i#*=} | ||
| GITHUB_WRITE_COMMENT=true | ||
| ;; | ||
| *) | ||
| yetus_error "WARNING: Unknown --github-comment-mode '${i#*=}'. Using 'append'." | ||
| GITHUB_COMMENT_MODE=append |
There was a problem hiding this comment.
--github-comment-mode=append doesn't set GITHUB_WRITE_COMMENT, so on its own it posts nothing. Only update and hide turn commenting on. An unrecognized value, e.g. --github-comment-mode=Hide, logs "Using 'append'." and then also posts nothing, because the gate at L1493 is still false. The docs at github.html.md L52 pair --github-write-comment with (--github-comment-mode=append), which reads as if the two are equivalent.
Related: when only --github-comment-key is invalid (no mode given), the warning at L117 says "Writing a new comment instead." even though no comment is written unless --github-write-comment is also set.
(LLM assisted)
There was a problem hiding this comment.
Fixed in 45b08fd. Every --github-comment-mode value (including append and unknown-mode fallback) enables GITHUB_WRITE_COMMENT, and the invalid --github-comment-key warning no longer assumes commenting is enabled.
1. Keep public github_write_comment append-only; apply update/hide modes only to final reports via github_write_report_comment. 2. Minimize duplicate visible comments after a successful PATCH in update mode so transient write failures converge back to one visible report. 3. Have all --github-comment-mode values (including append and fallback) enable GITHUB_WRITE_COMMENT, and clarify invalid key warning text. 4. Log warnings on comment-list GET failures and when assuming github-actions[bot] after /user lookup fails under GitHub Actions. 5. Tighten bats assertions and add tests for duplicate cleanup, non-report writes, missing github-pull.json, and non-GHA bot fallback. Assisted-by: Gemini 4 Neon
|
Addressed all items in 45b08fd:
|
|
I'm not sure what's up with CI here. I assigned the Jira to you, set it as "patch available", and re-triggered the GHA run. |
|
the ci seems broken for a while and irrelevant to this change |
|
I think you're right. Let me file that as a separate issue. Thanks for the contribution @pan3793 ! |
https://issues.apache.org/jira/browse/YETUS-1280
--github-write-commentappends a new PR comment on every run. Add--github-comment-mode=<append|update|hide>(implies--github-write-comment) and--github-comment-key=<key>to avoid comment spam across rebuilds (applied to final report comments only; publicgithub_write_commentcallers remain append-only):append(default): appends a new PR comment on every run.update: edits the oldest visible report comment previously written by the token's user with the same key (PATCH /repos/{owner}/{repo}/issues/comments/{id}), and minimizes any extra visible duplicates asOUTDATED. Lookup or PATCH failures fall back to POST.hide: posts a new report comment and minimizes prior visible report comments written by the token's user with the same key asOUTDATEDvia GraphQLminimizeComment. Lookup or minimize failures log a warning without failing the run.updateandhidetag reports with<!-- yetus-report:<key> -->, add aTested commitrow, identify the author viaGET /user(orgithub-actions[bot]with a warning under GitHub Actions), ignore already-minimized comments, and skip commenting when the PR head has moved past the tested commit.Tested with
github_comment_mode.batsand end to end against real GitHub.Assisted-by: Gemini 4 Neon