The pull request review review process is a must for building stable products. However, if you have a small engineering team, review process is always the blocker. In a small team, everyone should try to contribute to pull requests reviews, but it is sometimes difficult to understand the context, especially if the PR description lacks the necessary explanations. Therefore, some AI tools might help you to explain your changes to your teammates, get feedbacks for improvements and more! In this article, I will be showing one of those examples, called CodiumAI, which has a very easy setup process with built-in OpenAI support.
What the CodiumAI PR agent does is simply sending your PR context to one of the selected GPT (or other) models and modifying your PR with comments and tags. Since it uses OpenAI as an infra, we should get our API key from OpenAI dashboard first. You can read the following official documentation of OpenAI to learn how you can get the API key very quickly:
After getting an API key, please make sure that your account has enough balance to run APIs.
CodiumAI uses gpt-4o-2024-05-13
model by default. Therefore, you need to whitelist that model on your OpenAI organization.
1 - Go to Project
→ Limits
2 - From the Model Usage
section, whitelist the models that you want to use (also visible in Figure 1
After getting an API key, you need to put it to your GitHub secrets to allow your GitHub actions to use it:
repository settings
Security
→ Secrets and Variables
→ Actions
New repository secret
OPENAI_KEY
and value as your API keyYour secret will be created and accessible for workflow usages.
There multiple ways of setting up CodiumAI for your pull requests review. One of the most easiest one is using GitHub actions. The only thing you need to do is setting up the action file on your repository. After that the CodiumAI PR agent will start doing its job.
You need to do the following steps to complete action setup:
1 - Under your repository’s root, create a directory called .github
. If it already exists, no action is required
2 - Under .github
directory, create another directory called workflows
3 - Create your configuration file with yaml
extension under workflows
folder. I will call it pr-agent.yaml
In summary, your file structure should be like below, described in Figure 1:
In the below, the workflow will run in the following cases:
Your PR is opened
Your PR is reopened
Your PR is ready to review
name: PR Agent
on:
pull_request:
types: [opened, reopened, ready_for_review]
issue_comment:
jobs:
pr_agent_job:
if: ${{ github.event.sender.type != 'Bot' }}
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
contents: write
name: Run pr agent on every pull request, respond to user comments
steps:
- name: PR Agent action step
id: pragent
uses: Codium-ai/pr-agent@main
env:
OPENAI_KEY: ${{ secrets.OPENAI_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
github_action_config.auto_review: 'true'
github_action_config.auto_describe: 'true'
github_action_config.auto_improve: 'true'
We are setting github_action_config.auto_review
, github_action_config.auto_describe
and github_action_config.auto_improve
settings to automatically run these commands when the PR is opened. Otherwise, you need to run these commands, by commenting to your PR with specific commands.
After opening a PR, you will see that action will run and update your PR’s description, labels and other fields.
You can read more on CodiumAI documentation and explore other ways to run your PR agent: