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
- In rails console enable the feature flag
Feature.enable(:policy_mergability_check)
- Create a project without CI configuration
- Create a merge request approval policy with security scans
- Create MR in the project
- Verify that approvals are required
- Add another commit
- Verify that approvals are still required