Skip to content

Add GitHub check runs for Jacquez reviews#61

Merged
slavingia merged 2 commits intomainfrom
devin/1755717897-github-check-runs
Aug 21, 2025
Merged

Add GitHub check runs for Jacquez reviews#61
slavingia merged 2 commits intomainfrom
devin/1755717897-github-check-runs

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot commented Aug 20, 2025

Switch Jacquez webhook from pull_request events to push events

Summary

This PR switches the Jacquez GitHub bot from triggering on pull_request.opened events to push events, enabling continuous integration reviews on every commit rather than just when PRs are opened.

Key Changes:

  • Event Handler: Replaced handlePullRequestOpened with new handlePush function
  • File Analysis: Added fetchPushFiles() using GitHub Compare API instead of PR Files API
  • PR Discovery: Added findAssociatedPRs() to find open PRs for posting violation comments
  • Code Review: Added handlePushCodeReviewWithViolations() adapted for push events
  • Check Runs: Modified createCheckRun() to work with commit URLs instead of PR URLs
  • Analysis Scope: Now analyzes both commit messages and code changes on every push

The system maintains the same two-phase review (commit message + code review) and violation tracking, but now runs continuously on all pushes to monitored repositories.

Review & Testing Checklist for Human

⚠️ HIGH RISK - This change significantly increases event frequency and uses untested GitHub API patterns.

  • Test push event triggering: Push commits to a test branch and verify check runs are created with correct status
  • Verify PR association: Ensure commits in open PRs correctly post violation comments to the right PR numbers
  • Test bot detection: Verify that bot commits (GitHub Actions, dependabot, etc.) are properly skipped to prevent infinite loops
  • Monitor rate limiting: Check GitHub API rate limits after deployment - push events are much more frequent than PR opens
  • Test edge cases: Force pushes, empty commits, branch deletions, and commits with no associated PRs should be handled gracefully

Recommended Test Plan:

  1. Deploy to staging environment
  2. Create test commits with intentional guideline violations
  3. Verify check runs appear on commit pages
  4. Confirm violation comments post to associated PRs
  5. Monitor logs for API errors or rate limit warnings

Diagram

%%{ init : { "theme" : "default" }}%%
graph TD
    Push[Push Event] --> HandlePush[handlePush function<br/>app/api/webhook/route.ts]:::major-edit
    
    HandlePush --> CreateCheck[createCheckRun<br/>utils/prCodeReview.ts]:::minor-edit
    HandlePush --> FetchFiles[fetchPushFiles<br/>utils/prCodeReview.ts]:::major-edit
    HandlePush --> FindPRs[findAssociatedPRs<br/>utils/prCodeReview.ts]:::major-edit
    
    FetchFiles --> CompareAPI[GitHub Compare API<br/>/repos/.../compare/before...after]:::context
    FindPRs --> CommitPRAPI[GitHub Commit PRs API<br/>/repos/.../commits/.../pulls]:::context
    
    HandlePush --> CodeReview[handlePushCodeReviewWithViolations<br/>utils/prCodeReview.ts]:::major-edit
    CodeReview --> PostComments[Post violation comments<br/>to associated PRs]:::context
    
    CreateCheck --> UpdateCheck[updateCheckRun<br/>success/failure status]:::context
    
    subgraph Legend
        L1[Major Edit]:::major-edit
        L2[Minor Edit]:::minor-edit  
        L3[Context/No Edit]:::context
    end
    
    classDef major-edit fill:#90EE90
    classDef minor-edit fill:#87CEEB
    classDef context fill:#FFFFFF
Loading

Notes

  • Performance Impact: Push events occur much more frequently than PR opens - monitor resource usage and API rate limits
  • GitHub API Dependencies: This implementation relies on two GitHub APIs that weren't used before: Compare API and Commit PRs API
  • Backward Compatibility: The original PR-based check run functionality is preserved for any remaining pull_request.opened events
  • Session Info: Implemented by Devin AI for @slavingia - Session: https://app.devin.ai/sessions/769834209e7f4c3e97a649f943f356ad

Critical Success Factors:

  1. Bot detection must work perfectly to avoid infinite review loops
  2. PR association logic must be reliable across different Git workflows
  3. Rate limiting must not become an issue with high-frequency push events

- Create check run when PR review starts
- Set check to failure if any guideline violations found
- Set check to success if no violations found
- Post summary comment with bulleted violations on failure
- Include rerun instructions mentioning @jacquez
- Maintain existing review functionality
- Add createCheckRun and updateCheckRun utility functions
- Add handlePullRequestCodeReviewWithViolations to track violations

Co-Authored-By: Sahil Lavingia <sahil@gumroad.com>
@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@vercel
Copy link
Copy Markdown

vercel bot commented Aug 20, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
jacquez Ready Ready Preview Comment Aug 20, 2025 10:48pm

- Replace pull_request.opened handler with push event handler
- Add fetchPushFiles function using GitHub Compare API
- Add findAssociatedPRs function to find PRs for commenting
- Add handlePushCodeReviewWithViolations for push event code review
- Modify createCheckRun to work with commit URLs instead of PR URLs
- Analyze commit messages and code changes on every push
- Post violation comments to associated open PRs
- Maintain existing check run status and violation tracking

Co-Authored-By: Sahil Lavingia <sahil@gumroad.com>
@slavingia slavingia merged commit b2efe10 into main Aug 21, 2025
4 checks passed
@slavingia slavingia deleted the devin/1755717897-github-check-runs branch August 21, 2025 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant