Gitlab AI Code Review is a JS script that leverages OpenAI's GPT-3.5-turbo to automatically review code changes in GitLab repositories. It listens for merge request and push events, fetches the associated code changes, and provides feedback on the changes in a Markdown format.
- Automatically reviews code changes in GitLab repositories
- Provides feedback on code clarity, simplicity, bugs, and security issues
- Generates Markdown-formatted responses for easy readability in GitLab
- Docker
- An OpenAI API key
- A GitLab access token (can be generated in your GitLab account settings)
- Clone the repository:
https://github.com/Evobaso-J/ai-gitlab-code-review
cd ai-code-reviewer
- Create a
.env
file by copying the.env.example
file and set the required environment variables:
OPENAI_API_KEY=<your OpenAI API key>
GITLAB_TOKEN=<your GitLab API token>
GITLAB_URL=https://gitlab.com/api/v4
AI_MODEL=<an AI model from the ones supported by OpenAI>
OPEN_API_KEY
is your ChatGPT account’s keyGITLAB_TOKEN
is a personal gitlab account token. You can create it here and it can be either be your own personal token or a token from a gitlab account created ad hocGITLAB_URL
it’s the latest gitlab’s api version url, currently https://gitlab.com/api/v4AI_MODEL
is the model you want to use from OpenAI. You can usegpt-3.5-turbo
or any other model supported by OpenAI.
You can use Docker to run the application:
- Build the Docker image:
docker compose build
- Run the Docker container:
docker compose up -d
-
Configure your GitLab repository to send webhook events to the AI Code Reviewer application by following GitLab's webhook documentation.
-
The AI Code Reviewer application will automatically review code changes in your GitLab repository and provide feedback as comments on merge requests and commit diffs.
In the project directory, you can run:
To start the app in dev mode.
Open http://localhost:3000 to view it in the browser.
For production mode
Run the test cases.
To learn Fastify, check out the Fastify documentation.