Add project settings for Duo Code Review depth

What does this MR do and why?

Project maintainers need a way to block deep reviews, so projects that don't want to pay for them can turn them off. They also need a way to choose the default review depth for Code Review Flow.

This MR adds those controls to the project merge request settings, using the design from !262996 (comment 4109666703):

  • An Allow deep reviews checkbox.
  • A Depth level option with Standard (Default) and Deep. When Allow deep reviews is cleared, Deep is disabled and Standard (Default) is selected.

The settings appear only when duo_code_review_deep_flow is enabled for the top-level group, and only for projects with GitLab Duo and foundational flows turned on.

References

Screenshots or screen recordings

Project settings
Project settings

How to set up and validate locally

Prerequisites: a project with GitLab Duo and foundational flows turned on. These steps use the gitlab-duo/test project.

  1. Check out this branch and enable the feature flag for the top-level group in a Rails console:

    Feature.enable(:duo_code_review_deep_flow, Group.find_by_full_path('gitlab-duo'))
  2. As a project maintainer, go to http://gdk.test:3000/gitlab-duo/test/-/settings/merge_requests#merge-request-duo-code-review-settings. Under GitLab Duo Code Review, the Allow deep reviews checkbox and the Depth level options appear.

  3. Clear Allow deep reviews. Deep becomes disabled. Select Allow deep reviews again, select Deep, then clear Allow deep reviews. Standard (Default) becomes selected.

  4. Select Allow deep reviews and Deep, then select Save changes. After the page reloads, Deep is still selected.

  5. Go to the project's audit events page (http://gdk.test:3000/gitlab-duo/test/-/audit_events). The duo_code_review_depth_allowed_updated or duo_code_review_default_depth_updated event is listed.

  6. Disable the feature flag for the group and reload the project settings page. The depth settings are gone.

    Feature.disable(:duo_code_review_deep_flow, Group.find_by_full_path('gitlab-duo'))
  7. To undo, enable the flag again, select Allow deep reviews and Standard (Default), and save.

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Wanderson Policarpo

Merge request reports

Loading
Loading