Enabling AI code reviews

How to enabled CKI repositories to get 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

  1. Create a project access token (PAT) in GitLab with Reporter permissions and API access. This option is currently located in “Settings -> Access Tokens”.

  2. Add the created token as a secret in deployment-all. For more information, refer to handling-secrets.

  3. 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.yaml file:

    ---
    include:
      - project: cki-project/cki-lib
        ref: production
        file: .gitlab/ci_templates/cki-common.yml
    
    ...
    
    ai_code_review:
      extends: .cki_ai_code_review
    
  4. 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.

  5. Additionally, you can also create a config.yml file 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.

Enabled Projects