BlogComplete Guide to GitHub Integration

Complete Guide to GitHub Integration with Mesrai

Setting up Mesrai’s GitHub integration is the first step to automating your code reviews and accelerating your development workflow. In this comprehensive guide, we’ll walk you through every step of the process, from installation to advanced configuration.

Why Integrate Mesrai with GitHub?

GitHub integration with Mesrai brings powerful automation to your development workflow:

  • Automatic PR Reviews: Every pull request gets reviewed by AI within seconds
  • Inline Comments: Get contextual feedback directly on your code
  • Real-time Notifications: Stay informed about code quality issues
  • Seamless Workflow: No disruption to your existing GitHub workflow
  • Team Collaboration: Share insights and track team performance

Prerequisites

Before you begin, ensure you have:

  1. GitHub Account: Admin access to the repositories you want to review
  2. Mesrai Account: Sign up at mesrai.com if you haven’t already
  3. Repository Access: Permissions to install GitHub Apps
  4. Active Plan: Free tier or paid subscription

Step 1: Install the Mesrai GitHub App

Installation Process

  1. Navigate to GitHub Marketplace

  2. Choose Installation Type

    • All Repositories: Install on all current and future repos
    • Selected Repositories: Choose specific repos to monitor
  3. Grant Permissions The Mesrai GitHub App requires:

    • Read access to repository code
    • Write access for PR comments
    • Webhook access for event notifications
    • Read access to pull requests
  4. Authorize the App

    • Click “Install” to authorize Mesrai
    • Authenticate with your GitHub credentials
    • Confirm the installation

What Happens After Installation?

Once installed, Mesrai:

  • Configures webhooks automatically
  • Starts monitoring new pull requests
  • Syncs existing open PRs (optional)
  • Sends a confirmation email

Step 2: Configure Repository Settings

After installation, configure your repository settings via the Mesrai Dashboard:

1. Review Triggers

Configure when Mesrai should review code:

  1. Go to app.mesrai.com → Select your repository
  2. Navigate to SettingsReview Triggers
  3. Enable/disable triggers for:
    • Pull request opened
    • Pull request synchronized
    • Pull request reopened
    • Auto-review enabled

2. Branch Protection Rules

Set up branch protection in GitHub to enforce reviews:

  1. Go to Repository SettingsBranches
  2. Add branch protection rule for main, develop, etc.
  3. Enable Require status checks to pass
  4. Select mesrai/review as a required check

3. File Exclusions

Exclude certain files from review via the dashboard:

  1. Go to app.mesrai.com → Repository Settings
  2. Navigate to File Exclusions
  3. Add patterns like *.md, package-lock.json, dist/**

Step 3: Test Your Integration

Create a Test Pull Request

  1. Create a New Branch
git checkout -b test/mesrai-integration
  1. Make a Simple Change
// Add a simple function
function greet(name) {
  return `Hello, ${name}!`
}
  1. Push and Create PR
git add .
git commit -m "Test Mesrai integration"
git push origin test/mesrai-integration
  1. Open Pull Request
    • Go to your repository on GitHub
    • Click “New Pull Request”
    • Select your test branch
    • Create the PR

Verify the Review

Within 30-60 seconds, you should see:

  • ✅ Mesrai bot comment on your PR
  • ✅ Review status check
  • ✅ Inline suggestions (if applicable)
  • ✅ Overall quality score

Advanced Configuration

Custom Review Rules

Create custom rules for your team’s coding standards via the dashboard:

  1. Go to app.mesrai.com → Repository SettingsCustom Rules
  2. Configure complexity thresholds (cyclomatic complexity, function length)
  3. Set naming conventions (camelCase, identifier length)
  4. Enable security checks (SQL injection, XSS, hardcoded secrets)

Webhook Configuration

Webhooks are configured automatically when you install the GitHub App:

  1. Go to Repository SettingsWebhooks to verify
  2. Find Mesrai Webhook (installed automatically)
  3. Verify Events:
    • ✅ Pull requests
    • ✅ Push
    • ✅ Pull request reviews

Environment-Specific Settings

Configure different strictness levels via the dashboard:

  1. Go to app.mesrai.com → Repository SettingsBranches
  2. Set strictness levels per branch:
    • Production (main): High strictness, require tests
    • Staging (develop): Medium strictness, require tests
    • Development (feature/*): Low strictness, tests optional

Troubleshooting Common Issues

Issue 1: Mesrai Not Commenting on PRs

Possible Causes:

  • GitHub App not installed correctly
  • Insufficient permissions
  • Repository not selected during installation
  • Webhooks not configured

Solutions:

  1. Verify installation in GitHub Settings
  2. Check repository access
  3. Reinstall the GitHub App
  4. Review webhook delivery logs

Issue 2: Delayed Reviews

Possible Causes:

  • Large pull request (1000+ lines)
  • High system load
  • Rate limiting

Solutions:

  1. Break large PRs into smaller chunks
  2. Check your plan’s rate limits
  3. Upgrade to higher tier for priority processing

Issue 3: Missing Inline Comments

Possible Causes:

  • File type not supported
  • No issues detected
  • Comments disabled in settings

Solutions:

  1. Check supported file types
  2. Verify configuration settings
  3. Review exclusion patterns

Issue 4: Permission Errors

Possible Causes:

  • Insufficient GitHub permissions
  • Organization restrictions
  • Repository access revoked

Solutions:

  1. Verify GitHub App permissions
  2. Check organization settings
  3. Contact your GitHub admin

Best Practices

1. Start Small

Begin with a few repositories to:

  • Test the integration
  • Train your team
  • Fine-tune settings
  • Gather feedback

2. Configure Thoughtfully

  • Set appropriate strictness levels
  • Exclude generated files
  • Define clear review thresholds
  • Document your configuration

3. Monitor Performance

Track key metrics:

  • Average review time
  • Issues detected per PR
  • False positive rate
  • Team adoption rate

4. Iterate and Improve

  • Review feedback regularly
  • Adjust rules based on learnings
  • Update exclusion patterns
  • Refine custom rules

5. Team Training

Ensure your team:

  • Understands how to interpret reviews
  • Knows how to request re-reviews
  • Can configure repository settings
  • Follows established workflows

Security Considerations

Data Privacy

Mesrai takes security seriously:

  • No Permanent Storage: Source code is never stored permanently
  • Encryption in Transit: All data encrypted via TLS 1.3
  • Isolated Processing: Each review runs in isolated sandbox environments
  • Secure Authentication: OAuth via GitHub with minimal permissions

Access Control

Configure proper access control:

  • Limit app installation to authorized users
  • Use organization-level settings
  • Review audit logs regularly
  • Implement principle of least privilege

Secret Detection

Enable secret scanning to prevent:

  • API key leaks
  • Password exposure
  • Token commits
  • Credential leaks

Integration with CI/CD

GitHub Actions Integration

Combine Mesrai with GitHub Actions:

name: Code Review Workflow
on: [pull_request]
 
jobs:
  mesrai-review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: Wait for Mesrai Review
        run: |
          # Wait for Mesrai to complete review
          sleep 30
      - name: Check Review Status
        run: |
          # Verify review passed
          gh pr checks ${{ github.event.pull_request.number }}

Jenkins Integration

For Jenkins pipelines:

pipeline {
  stage('Code Review') {
    steps {
      script {
        // Trigger Mesrai review
        sh 'curl -X POST https://api.mesrai.com/review'
 
        // Wait for completion
        timeout(time: 5, unit: 'MINUTES') {
          waitUntil {
            def status = sh(
              script: 'curl https://api.mesrai.com/status',
              returnStdout: true
            )
            return status.contains('completed')
          }
        }
      }
    }
  }
}

Next Steps

Now that your GitHub integration is set up:

  1. Explore Features: Check out Organizations and Teams
  2. Configure Billing: Set up billing and subscriptions
  3. Review Analytics: Monitor team performance

Conclusion

GitHub integration is the foundation of Mesrai’s automated code review system. By following this guide, you’ve set up a powerful workflow that will help your team ship code faster while maintaining high quality standards.

Need help? Check our FAQ or contact support at support@mesrai.com.


Related Articles: