Commit b64bcf98 authored by Mike Greiling's avatar Mike Greiling

add performance artifacts to the merge request widget

parent b78705f4
......@@ -9,6 +9,7 @@ module EE
included do
scope :codequality, ->() { where(name: %w[codequality codeclimate]) }
scope :performance, ->() { where(name: %w[performance deploy]) }
scope :sast, ->() { where(name: 'sast') }
after_save :stick_build_if_status_changed
......@@ -30,6 +31,11 @@ module EE
artifacts_metadata?
end
def has_performance_json?
options.dig(:artifacts, :paths) == ['performance.json'] &&
artifacts_metadata?
end
def has_sast_json?
options.dig(:artifacts, :paths) == ['gl-sast-report.json'] &&
artifacts_metadata?
......
......@@ -17,6 +17,10 @@ module EE
artifacts.codequality.find(&:has_codeclimate_json?)
end
def performance_artifact
artifacts.performance.find(&:has_performance_json?)
end
def sast_artifact
artifacts.sast.find(&:has_sast_json?)
end
......
......@@ -11,6 +11,8 @@ module EE
delegate :codeclimate_artifact, to: :head_pipeline, prefix: :head, allow_nil: true
delegate :codeclimate_artifact, to: :base_pipeline, prefix: :base, allow_nil: true
delegate :performance_artifact, to: :head_pipeline, prefix: :head, allow_nil: true
delegate :performance_artifact, to: :base_pipeline, prefix: :base, allow_nil: true
delegate :sast_artifact, to: :head_pipeline, allow_nil: true
delegate :sha, to: :head_pipeline, prefix: :head_pipeline, allow_nil: true
delegate :sha, to: :base_pipeline, prefix: :base_pipeline, allow_nil: true
......@@ -44,6 +46,11 @@ module EE
base_codeclimate_artifact&.success?)
end
def has_performance_data?
!!(head_performance_artifact&.success? &&
base_performance_artifact&.success?)
end
def has_sast_data?
sast_artifact&.success?
end
......
......@@ -25,6 +25,20 @@ module EE
end
end
expose :performance, if: -> (mr, _) { mr.has_performance_data? } do
expose :head_path, if: -> (mr, _) { can?(current_user, :read_build, mr.head_performance_artifact) } do |merge_request|
raw_project_build_artifacts_url(merge_request.source_project,
merge_request.head_performance_artifact,
path: 'performance.json')
end
expose :base_path, if: -> (mr, _) { can?(current_user, :read_build, mr.base_performance_artifact) } do |merge_request|
raw_project_build_artifacts_url(merge_request.target_project,
merge_request.base_performance_artifact,
path: 'performance.json')
end
end
expose :sast, if: -> (mr, _) { expose_sast_data?(mr, current_user) } do
expose :path do |merge_request|
raw_project_build_artifacts_url(merge_request.source_project,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment