Skip to content

Draft: Fix required approvals for unenforceable rules with policy check

What does this MR do and why?

Fix required approvals for unenforceable rules with policy check.

When policy_mergability_check FF is enabled, the required approvals are set to 0 after a commit because the expectation is that policy violation will reset these approvals.

If there's no CI configuration in the project, UnenforceablePolicyRulesNotificationService is triggering the bot comment but it's not resetting the approvals back.

It is also not scheduled for consecutive commits after MR is created, so the required approvals become optional in that case.

MR acceptance checklist

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

How to set up and validate locally

  1. In rails console enable the feature flag
    Feature.enable(:policy_mergability_check)
  2. Create a project without CI configuration
  3. Create a merge request approval policy with security scans
  4. Create MR in the project
  5. Verify that approvals are required
  6. Add another commit
  7. Verify that approvals are still required

Merge request reports