IntegrationsCI/CD Pipelines

CI/CD Pipelines

Integrate Mesrai directly into your CI/CD pipeline to automate code reviews as part of your build process.

Currently, Mesrai supports GitHub Actions for CI/CD integration. Support for other platforms is coming soon.

Overview

Running Mesrai in your CI/CD pipeline enables:

  • Automated reviews on every PR
  • Quality gates that block merges for critical issues
  • Consistent standards across all code changes
  • Detailed reports as build artifacts

GitHub Actions

Basic Setup

# .github/workflows/mesrai.yml
name: Mesrai Code Review
 
on:
  pull_request:
    types: [opened, synchronize]
 
jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0  # Full history for better context
 
      - name: Run Mesrai Review
        uses: mesrai/action@v2
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          mesrai-token: ${{ secrets.MESRAI_TOKEN }}

With Quality Gates

name: Mesrai Code Review
 
on:
  pull_request:
    types: [opened, synchronize, reopened]
 
jobs:
  review:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write
 
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
 
      - name: Run Mesrai Review
        uses: mesrai/action@v2
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          mesrai-token: ${{ secrets.MESRAI_TOKEN }}
          fail-on-critical: true
 
      - name: Upload Report
        uses: actions/upload-artifact@v3
        if: always()
        with:
          name: mesrai-report
          path: mesrai-report.json

Setting Up GitHub Actions

Step 1: Get Your API Token

  1. Go to app.mesrai.com
  2. Navigate to Settings β†’ API Tokens
  3. Click Generate New Token
  4. Copy the token

Step 2: Add Repository Secret

  1. Go to your GitHub repository
  2. Navigate to Settings β†’ Secrets and variables β†’ Actions
  3. Click New repository secret
  4. Name: MESRAI_TOKEN
  5. Value: Paste your API token

Step 3: Create Workflow File

Create .github/workflows/mesrai.yml with the configuration above.


Configuration

Review settings are configured through the Mesrai Dashboard, not in the workflow file.

Available Action Inputs

InputDescriptionRequired
github-tokenGitHub token for PR accessYes
mesrai-tokenYour Mesrai API tokenYes
fail-on-criticalFail the action if critical issues foundNo

Quality Gates

Quality gates can block merges until issues are resolved. Configure them in the Mesrai dashboard:

  1. Go to app.mesrai.com
  2. Select your Repository
  3. Navigate to Settings β†’ Quality Gates
  4. Configure your rules

Example Gate Results

Quality Gate Results
━━━━━━━━━━━━━━━━━━━━━
βœ… No Critical Issues      PASSED
βœ… Security Check          PASSED
⚠️ Coverage Threshold      WARNING (75% < 80%)

Overall: βœ… PASSED

Coming Soon

We’re working on support for additional CI/CD platforms:

PlatformStatus
GitHub Actionsβœ… Available
GitLab CI🚧 Coming Soon
Bitbucket Pipelines🚧 Coming Soon
CircleCIπŸ“… Planned
JenkinsπŸ“… Planned
Azure DevOpsπŸ“… Planned

Troubleshooting

Action Not Running

  1. Verify the workflow file is in .github/workflows/
  2. Check that the trigger events match your PR actions
  3. Ensure secrets are correctly configured

Authentication Errors

  1. Verify MESRAI_TOKEN is set correctly
  2. Check the token hasn’t expired
  3. Ensure the token has the required permissions

Reviews Not Appearing

  1. Check the action logs for errors
  2. Verify the repository is connected in Mesrai dashboard
  3. Ensure the PR has code changes (not just config files)

Next Steps