Skip to content

fix(ci): auto-run bonk for pull requests#357

Closed
geoquant wants to merge 7 commits intocloudflare:mainfrom
geoquant:geoquant/auto-bonk-pr
Closed

fix(ci): auto-run bonk for pull requests#357
geoquant wants to merge 7 commits intocloudflare:mainfrom
geoquant:geoquant/auto-bonk-pr

Conversation

@geoquant
Copy link
Copy Markdown
Collaborator

@geoquant geoquant commented Apr 2, 2026

Fixes the manual /bonk workflow gap for pull requests.

This PR is the real auto-Bonk fix. It replaces the current human-triggered Bonk gate with an automatic Bonk review flow on PR open/update while keeping the existing bonk-check context compatible with the current repository ruleset.

Specifically, this PR:

  • changes bonk-check from a manual /bonk gate into a pull_request_target wrapper that auto-runs for PR opens/updates
  • posts a visible automatic /bonk review comment on the PR for transparency
  • dispatches bonk.yml automatically so Bonk reviews the PR without a human typing /bonk
  • adds workflow_dispatch support to bonk.yml so the wrapper can invoke Bonk directly
  • keeps manual /bonk comments working for issue comments and PR review comments
  • removes the noisy pull_request_review triggers from bonk.yml and bigbonk.yml
  • checks out the repo for automatic Bonk runs so the workflow-dispatch path has a valid git workspace
  • explicitly instructs the automatic Bonk path to submit a real PR review, not just print output to stdout
  • uses token_permissions: NO_PUSH for the automatic Bonk path so the auto-run stays review-only
  • includes a dispatch_ref override in bonk-check.yml for pre-merge smoke tests; normal post-merge behavior dispatches against the PR base ref

Notes:

  • This PR supersedes the previously closed PR fix(ci): stop bonk-check from failing on status writes #356, which only fixed part of the old manual bonk-check behavior.
  • The repo ruleset currently requires the bonk-check context. This PR keeps that context alive by having bonk-check act as the automatic wrapper instead of enforcing a human collaborator comment.
  • If the team wants to remove bonk-check as a required check entirely after this merges, that still requires a GitHub ruleset/settings change outside the repo.
  • Smoke-test PR test: verify visible automatic bonk wrapper #360 demonstrates the intended UX: a visible automatic /bonk review comment plus an automatic Bonk review on a PR targeting main, while remaining blocked by the current legacy main protections until this PR lands.

  • Reviews
    • bonk has reviewed the change
    • automated review not possible because: this PR changes the Bonk workflows themselves, so the pre-merge smoke test had to validate the wrapper/review flow on a separate PR instead
  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because: this PR only changes GitHub Actions workflow definitions, YAML parses successfully, and smoke-test PR test: verify visible automatic bonk wrapper #360 demonstrated the visible wrapper comment + automatic Bonk review flow

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 2, 2026

npm i https://pkg.pr.new/@cloudflare/kumo@357

commit: 4fbf884

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

Docs Preview

View docs preview

Commit: 4fbf884

@geoquant
Copy link
Copy Markdown
Collaborator Author

geoquant commented Apr 2, 2026

/bonk review

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk bot commented Apr 2, 2026

@geoquant Bonk workflow was cancelled.

View workflow run · To retry, trigger Bonk again.

@geoquant
Copy link
Copy Markdown
Collaborator Author

geoquant commented Apr 2, 2026

/bonk review again

Copy link
Copy Markdown
Contributor

@ask-bonk ask-bonk bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR implements a well-designed auto-Bonk system that removes the manual /bonk requirement while maintaining backward compatibility. Overall this is a solid approach.

What works well:

  • Clean separation between bonk-check.yml (orchestrator) and bonk.yml (executor)
  • Using pull_request_target properly avoids exposing secrets to untrusted code
  • The comment-deduplication logic prevents noise on PR updates
  • token_permissions: NO_PUSH is the right call for automatic runs
  • Preserving manual /bonk commands for human-triggered reviews

Minor observations (non-blocking):

  1. Concurrency group edge case: When a PR is opened and quickly updated, both opened and synchronize events could fire and dispatch two separate Bonk runs since concurrency is managed within bonk.yml, not across the dispatch boundary. This is probably fine given Bonk idempotency, but worth noting.

  2. Hardcoded workflow filename: The dispatch in bonk-check.yml references bonk.yml directly. If this file is ever renamed, the dispatch will fail silently. Consider whether this needs to be more resilient.

  3. Missing checkout comment: The PR description mentions "checks out the repo for automatic Bonk runs" but bonk-check.yml doesn't actually checkout code - it only dispatches. The checkout happens in bonk.yml which is correct since pull_request_target checkout behavior has security implications. The description is slightly misleading but the implementation is correct.

One clarification question:

The bonk-check job no longer posts a commit status. If the repo ruleset currently requires the bonk-check context, won't this break branch protection? Or is the plan to update the ruleset when this merges? The PR description says it "keeps that context alive" but I don't see a status being posted anymore.

pull_request_review:
types: [submitted]
pull_request_target:
types: [opened, synchronize, reopened, ready_for_review]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pull_request_target is the right choice here since this workflow only dispatches another workflow and doesn't execute untrusted code. This maintains access to GITHUB_TOKEN for the dispatch API call.

fi
fi
done <<< "$COMMENTS"
existing_comment_id=$(gh api "repos/${{ github.repository }}/issues/$PR_NUMBER/comments" --paginate \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice approach for comment deduplication - using the HTML comment as a marker allows updating the same comment on PR updates instead of creating noise with new comments each time.

fetch-depth: 1

- name: Setup pnpm
if: github.event_name != 'workflow_dispatch'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good conditional skipping here. The workflow_dispatch path doesn't need pnpm/node setup since it relies on the ask-bonk action to handle its own environment.

model: "cloudflare-ai-gateway/workers-ai/@cf/moonshotai/kimi-k2.5"
agent: kumo
permissions: any
token_permissions: NO_PUSH
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using NO_PUSH for automatic reviews is the correct security posture. This ensures the auto-triggered review can only submit PR reviews, not push commits or make code changes.

agent: kumo
permissions: any
token_permissions: NO_PUSH
prompt: |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The prompt explicitly instructs submitting a real PR review rather than just outputting to stdout - this addresses a key gap in automated AI review workflows where the review often just prints and doesn't actually submit back to GitHub.

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk bot commented Apr 2, 2026

I've submitted a review on PR #357. Here's a summary of my findings:

Review Summary

Overall Assessment: This is a well-designed implementation of automatic Bonk reviews. The architecture is clean with proper separation of concerns between the orchestrator (bonk-check.yml) and the executor (bonk.yml).

✅ What Works Well

  • Proper use of pull_request_target for secure access to dispatch APIs
  • Smart comment deduplication using HTML comment markers
  • Correct security posture with NO_PUSH permissions for automatic runs
  • Preserves backward compatibility with manual /bonk commands
  • Explicit prompt instruction to submit actual PR reviews (not just stdout output)

⚠️ Minor Observations (Non-blocking)

  1. Concurrency edge case: Rapid PR events could dispatch multiple Bonk runs since concurrency is managed inside bonk.yml, not across dispatches
  2. Hardcoded workflow path: The dispatch references .github/workflows/bonk.yml directly - renaming would break it
  3. Implementation vs description: The PR mentions checking out the repo, but bonk-check.yml correctly doesn't checkout (it happens in bonk.yml instead)

❓ One Question for the Author

The bonk-check context was previously a required status check, but this PR removes the status posting logic. The PR description says it "keeps that context alive," but I don't see where the status is being posted anymore. This could break branch protection rules that require the bonk-check context.

The review is available at: #357 (review)

github run

@geoquant
Copy link
Copy Markdown
Collaborator Author

geoquant commented Apr 3, 2026

/bonk review again

@geoquant geoquant closed this Apr 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant