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.jsonSetting Up GitHub Actions
Step 1: Get Your API Token
- Go to app.mesrai.com
- Navigate to Settings β API Tokens
- Click Generate New Token
- Copy the token
Step 2: Add Repository Secret
- Go to your GitHub repository
- Navigate to Settings β Secrets and variables β Actions
- Click New repository secret
- Name:
MESRAI_TOKEN - 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
| Input | Description | Required |
|---|---|---|
github-token | GitHub token for PR access | Yes |
mesrai-token | Your Mesrai API token | Yes |
fail-on-critical | Fail the action if critical issues found | No |
Quality Gates
Quality gates can block merges until issues are resolved. Configure them in the Mesrai dashboard:
- Go to app.mesrai.com
- Select your Repository
- Navigate to Settings β Quality Gates
- Configure your rules
Example Gate Results
Quality Gate Results
βββββββββββββββββββββ
β
No Critical Issues PASSED
β
Security Check PASSED
β οΈ Coverage Threshold WARNING (75% < 80%)
Overall: β
PASSEDComing Soon
Weβre working on support for additional CI/CD platforms:
| Platform | Status |
|---|---|
| GitHub Actions | β Available |
| GitLab CI | π§ Coming Soon |
| Bitbucket Pipelines | π§ Coming Soon |
| CircleCI | π Planned |
| Jenkins | π Planned |
| Azure DevOps | π Planned |
Troubleshooting
Action Not Running
- Verify the workflow file is in
.github/workflows/ - Check that the trigger events match your PR actions
- Ensure secrets are correctly configured
Authentication Errors
- Verify
MESRAI_TOKENis set correctly - Check the token hasnβt expired
- Ensure the token has the required permissions
Reviews Not Appearing
- Check the action logs for errors
- Verify the repository is connected in Mesrai dashboard
- Ensure the PR has code changes (not just config files)