Enabling AI code reviews
Problem
As a CKI collaborator I want to get automatic AI code reviews to improve our Quality
Chosen Tool
Several options are available in the market, but we have chosen ai-code-review for the following reasons:
- It is not tied to any specific technology or vendor, making it technology-agnostic.
- It allows easy customization for each repository
- It supports global configuration
- It is written by a former CKI member who is always willing to help us (Thank you Juanje)
Steps
-
Create a project access token (PAT) in GitLab with
Reporterpermissions and API access. This option is currently located in “Settings -> Access Tokens”. -
Add the created token as a secret in
deployment-all. For more information, refer to handling-secrets. -
Enable the CI job by using the template defined in cki-lib, specifically in the templates file. Below is an example of a
.gitlab-ci.yamlfile:--- include: - project: cki-project/cki-lib ref: production file: .gitlab/ci_templates/cki-common.yml ... ai_code_review: extends: .cki_ai_code_review -
This step is optional, but if you want greater precision, you can generate a custom file for your project as described in the context-generator section.
Here is an example.
-
Additionally, you can also create a
config.ymlfile to customize the CI execution.Here is an example.
Note
In the future, we may change the strategy and use a service user with appropriate permissions across all projects to simplify its usage.
We are using Gemini as the model to review our merge requests.