DEV Community

Cover image for Integrating AI Code Review into your DevOps pipeline
Aravind Putrevu for CodeRabbit

Posted on • Originally published at coderabbit.ai

Integrating AI Code Review into your DevOps pipeline

GitHub is the central hub for countless Open-source projects. However, for repository maintainers, a steady flow of pull requests (PRs) can quickly turn into an overwhelming workload. Those managing popular OSS repositories with numerous stars are well aware of the challenges of keeping up with code reviews, maintaining quality, and keeping the project on track.

A quick search on “has this been abandoned” on Github shows a lot on what’s happening across various successful repositories.

Image description

A healthy Maintainer <> Contributor equation has a lot of pieces but Pull-requests plays a substantial role, as it is the biggest point of contact with the repo maintainers after finding an issue one could work on.

We at CodeRabbit have lived through this problem, and with the advent of Generative AI and code generation models, we realized we could help improve this. CodeRabbit is an AI code reviewer designed to ease the challenges of code review, supporting repository maintainers and teams. It not only reviews your PRs but also provides concise summaries, identifies potential issues, and offers insights that might be missed during manual reviews.

How CodeRabbit Works?

Curious about how CodeRabbit works? Here's a breakdown of the process:

CodeRabbit integrates with GitHub, automating the code review process from the moment a pull request is created. It preprocesses the PR content, builds context, leverages Large Language Models for analysis, and then post-processes the AI response before posting the review back to GitHub. This streamlined workflow ensures thorough AI-powered code reviews without manual intervention.

Image description

Integrating with GitHub

Accessing CodeRabbit

Navigate to the Code Rabbit login page. You'll be presented with various git options when you try to login. Choose the one, whether it's GitHub, GitLab, or Self hosted Github, or Gitlab

Image description

After selecting your Git platform, follow the specific configuration guide:

  • GitHub: Standard login (steps provided below)
  • GitLab: Follow standard login and authorization from below steps. For organization-wide use, consider creating a dedicated * GitLab user with a Personal Access Token.
  • Self-Hosted GitHub: Setup instructions
  • Self-Hosted GitLab: Setup instructions

Authorization

In you had chosen Login with GitHub& GitLab in step1 , you'll be prompted to authorize CodeRabbit. This step grants the necessary permissions for CodeRabbit to interact with your repositories and pull requests.

Image description

Selecting Your Organization

Upon Authorization, If you're part of multiple organizations, you'll have the opportunity to choose which one you want to associate with CodeRabbit. This ensures that you're setting up the tool for the correct team or project.

Image description

Exploring the CodeRabbit Dashboard

Upon successful authorization, you'll be logged into the CodeRabbit user interface. Here, you can add repositories and configure CodeRabbit config settings for each repository.

Image description

Note 💡 If you opt to authorize all repositories during setup, CodeRabbit will automatically include any new repositories you create on GitHub in the future. This saves you the hassle of manual additions down the line. 5. CodeRabbit Configuration
With your repositories added, it's time to configure CodeRabbit to your needs. You have three options for configuration:

  1. CodeRabbit Configuration You can configure CodeRabbit through a YAML file or using the App’s UI.

You can tailor CodeRabbit's functionality using the coderabbit.yaml file, which you place directly in your GitHub repository. This file mirrors the options available in the CodeRabbit user interface, with each setting in the YAML corresponding to a specific toggle in the UI. Configure CodeRabbit either through the coderabbit.yaml file or the interface, depending on your preference.

💡 If a coderabbit.yaml file exists in your GitHub repository, it takes precedence over any UI settings. Choose either the YAML file or UI configuration - you don't need to use both. The table below outlines key configuration options of the coderabbit.yaml :

Option Description Possible Values
'language' Sets the language for the review. "en-US", "fr-FR", etc.
'early_access' Enables early access to features. true, false
'reviews.profile' Selects the review style. "chill", "strict", etc.
'reviews.request_changes_workflow' Determines if a change request workflow is used. true, false
'reviews.high_level_summary' Generates a summary of the PR. true, false
'reviews.poem' Adds a creative touch with a poem review. true, false
'reviews.review_status' Includes review status in the output. true, false
'reviews.collapse_walkthrough' Collapses the review walkthrough. true, false
'reviews.auto_review.enabled' Enables auto review for PRs. true, false
'reviews.auto_review.drafts' Reviews draft PRs. true, false
'chat.auto_reply' Enables automatic replies in the chat. true, false

Once your coderabbit.yaml file is prepared according to your needs, simply place it in your GitHub repository, and you’re all set—CodeRabbit is now integrated!

When a pull request is created targeting the master branch, CodeRabbit automatically initiates its review process. It analyzes the changes and generates a summary and walkthrough of the modifications. The specific feedback and analysis provided by CodeRabbit are determined by the options you've configured in your YAML file.

Let's examine a few examples of CodeRabbit's review comments from a specific pull request in one of the projects. This particular PR involved in changing the language model from LLaMA 2 to LLaMA 3, for testing purposes. These examples will showcase how CodeRabbit analyzed and commented on this significant model switch.

Sample PR Review Workflow using CodeRabbit

For every PR reviewed, CodeRabbit provides a summary of changes to start with, like the below image.

Image description

This image shows CodeRabbit's review status for another pull request. It highlights that 12 actionable comments were generated, and the review also includes additional comments on specific files, demonstrating CodeRabbit's comprehensive analysis of the code changes.

Image description

You can also use CodeRabbit commands to chat with the AI code Reviewer.

Image description

CodeRabbit could generate a Code sequence diagram when you request a full review. The sequence diagram illustrates the precise flow of interactions between the objects in the system.

Image description

Also check out the response when i asked for what improvements can be done on the code level

Image description

In addition to providing reviews and summaries, CodeRabbit can also detect configuration issues. For example, I accidentally set up both CodeRabbit Pro (The process we've been discussing) and the open-source version (Refer to different config process) in my repository at the same time.

Interestingly, CodeRabbit noticed this mistake on its own and alerted me. You can see below how it pointed out this issue to me.

Image description

Check out for some of the stats and test plans generated by this AI code reviewer for another different project’s pull request.

Image description

Image description

CodeRabbit also allows you to configure custom review instructions based on your organization's needs, in case you want it to follow specific guidelines beyond the standard review, to learn more on adding custom review instructions

Whether you manage a popular repository or are working on a smaller project, whether it's hosted on GitLab, GitHub, or self-hosted GitHub or GitLab, CodeRabbit can help streamline your development process. This AI Code Review assistant is designed to save you time by automating code reviews and offering insightful feedback.

Explore! Experiment! Discover how CodeRabbit can streamline your code review process using AI!!!

Top comments (0)