Add AutoAssignReviewersWorker and reviewer-preserving assign logic (3b/3)
Summary
Introduces the Sidekiq worker that performs automatic reviewer assignment and refactors ReviewerAssignment::AssignService so the worker can invoke it cleanly.
Worker (MergeRequests::AutoAssignReviewersWorker):
idempotent!,data_consistency :sticky,urgency :lowfeature_category :code_review_workflowdefer_on_database_health_signal :gitlab_main- Resolves the
automation_botfor the project's organization and passes it into the service ascurrent_user
AssignService refactor:
- Resolves the strategy from
StrategyFactoryrather than taking it as a required arg, so the worker can call.new(merge_request:, current_user:) - Takes
current_user:ininitializelike every otherBaseProjectServicesubclass — no more nil-then-reassign insideexecute - Preserves existing reviewers when assigning (append rather than overwrite)
- Duo Code Review compatible: a solo Duo bot reviewer is treated as "no human reviewers" so code owners are still added alongside
No callers invoke the worker yet; the trigger points arrive in Part 3c.
Part 3b of 3 for CODEOWNERS automatic reviewer assignment. This MR can merge independently of 3a (the service still reads reviewer_auto_assignment_enabled?, which exists on master).
Related
- Parent issue: #589700
- Previously combined in: !224178 (closed) (now split)
- Part 1 (DB): !224175 (merged)
- Part 2 (Service): !224176 (merged)
- Part 3a (Settings toggle): !232619 (merged)
- Part 3c (Trigger wiring): !232621 (merged)
Test plan
-
bundle exec rspec ee/spec/workers/merge_requests/auto_assign_reviewers_worker_spec.rb -
bundle exec rspec ee/spec/services/merge_requests/reviewer_assignment/assign_service_spec.rb - Enqueue worker manually for an MR with existing human reviewer: reviewers remain unchanged (skip path)
- Enqueue worker for an MR with solo Duo bot reviewer: code owners added alongside Duo bot
- Enqueue worker for an MR with no reviewers: code owners assigned, author is
automation_bot
Edited by Marc Shaw