머지 가능성 프레임워크
GitLab 백엔드의 머지 리퀘스트 머지 가능성 검사 프레임워크의 구조, 새 검사 추가 방법 및 관련 고려사항을 설명합니다.
초기 작업은 더 잘 정의된 머지 가능성 프레임워크 에서 시작되었습니다. 원래 머지 가능성에 관한 지식은 백엔드와 프론트엔드 전반에 분산되어 있었습니다. 이 작업은 머지 가능성 기준 일부를 백엔드의 동일한 위치로 통합하기 위한 것입니다. 이를 통해 프론트엔드는 단순히 API를 소비하고 오류를 표시하기만 하면 됩니다. 새 검사 추가 # 새로운 머지 검사를 추가할 때는 몇 가지 사항을 결정해야 합니다: 이 검사를 건너뛸 수 있는지, 그리고 검사 통과 시 머지 기능의 일부인지 여부 이 검사를 캐시할 수 있는지 여부 그렇다면, 적절한 캐시 키는 무엇인지 결정해야 합니다. 이 검사에 검사를 켜거나 끌 수 있는 설정이 있는지 여부 이 질문들에 답한 후 새 검사를 생성할 수 있습니다. 머지 가능성 검사는 app/services/merge_requests/mergeability/ 아래에 있습니다. 새 검사를 생성하기 위해 다음을 기반으로 사용할 수 있습니다: # frozen_string_literal: true module MergeRequests module Mergeability class CheckCiStatusService < CheckBaseService identifier :ci_must_pass # Identifier used to state which check failed description 'Checks whether CI has passed' # Description of the check returned through GraphQL def execute # If the merge check is behind a setting, we return inactive if the setting is false return inactive unless merge_request.only_allow_merge_if_pipeline_succeeds? if merge_request.mergeable_ci_state? success else failure end end def skip? # Here we can check for the param or return false if it's not skippable # Skippability of an MR is related to merge when checks pass functionality params[:skip_ci_check].present? end # If we return true here, we need to create the method def cache_key and provide # an appropriate cache key that will invalidate correctly. def cacheable? false end end end end def mergeable_state_checks 메서드에 새 검사를 추가합니다. GraphQL enum app/graphql/types/merge_requests/detailed_merge_status_enum.rb 에 새