Skip to content

Allow approval comments to include reasons - #234

Merged
snskArora merged 4 commits into
trstringer:mainfrom
CAOShurong:codex/21-comment-reasons
Nov 19, 2026
Merged

snskArora merged 4 commits into
trstringer:mainfrom
CAOShurong:codex/21-comment-reasons

Conversation

@CAOShurong

@CAOShurong CAOShurong commented Aug 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add an opt-in allow-comment-reasons input.
  • When enabled, the decision keyword must be alone on the first line (with optional punctuation). An explanation can follow on later lines.
  • Keep the input disabled by default, preserving v1's exact-comment behavior.

Closes #21.

Requested test coverage

This update addresses the request to test both values explicitly. The same 11 parser scenarios each run with false and true (22 cases), covering reasons, CRLF, exact keywords, later/empty first lines, same-line prose, unauthorized users, and distinct versus duplicate approvers.

Four httptest polling cases cover approval and denial in both modes. They verify whether the reason-bearing comment completes immediately or waits for an exact keyword, as well as the terminal comment, issue closure and exit code. This revision adds tests only; a normal merge retains the two current upstream polling fixes.

Verification for 0d4edbd

On Go 1.26.7 / Windows amd64, including a clean archive byte-matched to commit 0d4edbd3a233d304a3e91230c88e70bc64e872ae:

  • go test -json -count=20 -p=2 ./...: all 76 leaf cases pass in each repetition.
  • go vet -p=2 ./... and go build -p=2 -buildvcs=false -trimpath ... .: pass.
  • CI's exact golangci-lint v2.10.1 run -v: zero issues.
  • Gofmt/diff checks and the secret, EOF and whitespace hooks: pass.
  • The compiled program passes 16 localhost fake-GitHub API scenarios, checking outputs, exits and requests: both modes, omitted/empty defaults, invalid input without issue writes, unauthorized/exact comments, denial continuation, custom words, distinct approvals, and an API error.
  • Four isolated fixed-boolean mutations of parsing/polling each fail the appropriate newly added tests, demonstrating that wrong-mode wiring is detected.

The fork CI run also passed on exact head 0d4edbd3a233d304a3e91230c88e70bc64e872ae: the unchanged upstream workflow's Linux Docker build, full Go tests (including the explicit false/true cases), and Docker-based golangci-lint v2.10.1 with zero issues. The completed run, job steps and logs were checked. This is fork execution, not upstream maintainer approval.

Limitations: Windows is not a supported Action runner; the local program/API checks are synthetic, not deployed workflow proof. Race, ARM and a real approval/deployment workflow are not tested. The pinned pre-commit lint v1.52.2 panics with unsupported version: 2 on both this revision and the untouched pre-test baseline; the complete configured hook set is not claimed green. Its initial environment-install timeout is also retained. The old August run is not evidence for this revision. No container image or release is published by this update.

Final review updates

  • Exclude comments created from the issue body by their IDs.
  • Log the comment that meets the approval threshold and expose it as approval-comment. Comments exceeding 64 KiB are logged with an empty output.
  • Fork QA passed a Linux build, Go race tests, and five Action scenarios on 1c531d7, including raw multiline output and the oversized-comment fallback.

Provenance correction

Prepared with OpenAI Codex: AI-generated code, tests and PR text. The previous sentence suggesting personal review was not substantiated by the available records and has been removed. No personal or independent human review, production adoption, or maintainer acceptance is asserted.

Keep exact-comment behavior as the default and add an opt-in first-line decision mode for explanatory follow-up text.

Assisted-by: OpenAI Codex
@snskArora snskArora added the enhancement New feature or request label Aug 28, 2026
@snskArora

Copy link
Copy Markdown
Collaborator

Hi @CAOShurong

Can you please test these changes and produce tests with both possible values for your new variable?

…asons

Signed-off-by: CAOShurong <170531907+CAOShurong@users.noreply.github.com>
Signed-off-by: CAOShurong <170531907+CAOShurong@users.noreply.github.com>
@CAOShurong

Copy link
Copy Markdown
Contributor Author

Added the requested explicit coverage in 0d4edbd3: the same 11 parser scenarios run with both false and true, and four HTTP polling tests exercise approval/denial in both modes, including poll counts, closing comments, issue closure and exit codes. Default exact-comment behavior remains unchanged.

The full suite passed 20 repetitions on the byte-verified committed source. The exact-head fork CI also passed the upstream Linux Docker build, tests and v2.10.1 lint (zero issues). No production code was added in this test revision; the merge preserves the current upstream polling fixes.

Prepared with OpenAI Codex (AI-generated code/tests/text). The PR description now corrects the earlier unsupported personal-review wording and records the local pinned-lint compatibility failure and untested race/ARM/deployment paths. Fork CI success is not maintainer approval or deployment evidence.

@snskArora

snskArora commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

Hi @CAOShurong

Apologies for the delay in getting this resolved.

Thanks a lot for adding in the test cases, but what I meant was that if you could publish a docker image from your branch to your own ghcr registry, then use that image to run the action and complete the end to end qa process.

I am asking for this because the changes touch the core logic of these scripts, and I would like to make sure that multiple scenarios are validated before merging so we dont introduce any regressions.

@CAOShurong

Copy link
Copy Markdown
Contributor Author

Built the exact PR revision (0d4edbd) and pushed it to the fork’s GHCR package in the image build job. All four jobs in the end-to-end run pulled the same digest and invoked the Docker Action against real issues in the fork.

With allow-comment-reasons: true, a multiline approval and denial each took the decision from the first line. With it set to false, both multiline comments left the issue pending until the exact keyword arrived. All four cases checked the step outcome, approval-status, issue URL, terminal comment, and issue closure. Denial failed the action step as expected. The four test issues were closed, and the fork’s original issues setting was restored.

@snskArora

Copy link
Copy Markdown
Collaborator

Thanks for adding the tests, @CAOShurong, that helps a lot.

I have three small comments:

  1. There is a potential race condition: if the issue body is too long, it is split into the issue body and additional overflow comments. In that case, the approval comment could potentially match the issue body as well (though this is a low-probability event). Could we add a check to prevent that?
  2. Could you also add the approving comment to the outputs and log it? If the comment is too long to fit in the outputs, please log it and leave the corresponding output empty.
  3. The documentation says that the keyword must be “on the first line,” but it should actually be the only content on that line. Could we update the Markdown documentation to clarify this?

That is the last change,otherwise, the PR looks great!!

@CAOShurong

Copy link
Copy Markdown
Contributor Author

Updated in 1c531d7. The action skips its own issue-body comments, logs the comment that meets the approval threshold, and leaves approval-comment empty above 64 KiB. The docs now say the keyword must be alone on the first line. Five fork QA scenarios passed.

@snskArora

Copy link
Copy Markdown
Collaborator

Great!
LGTM

@snskArora
snskArora merged commit 15f5cc5 into trstringer:main Nov 19, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow additional information on the comment that approves/denies

2 participants