Unverified Commit 8e33f946 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets
Browse files

Show test coverage results in MR if available


Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 27ca59e01d8a
......@@ -40,6 +40,8 @@ class MergeRequest
if @opts.ci_enable
$.get @opts.url_to_ci_check, (data) =>
this.showCiState data.status
if data.coverage
this.showCiCoverage data.coverage
, 'json'
bindEvents: ->
......@@ -102,7 +104,11 @@ class MergeRequest
when "running", "pending"
$('.mr-state-widget').addClass("panel-warning")
showCiCoverage: (coverage) ->
cov_html = $('<span>')
cov_html.addClass('ci-coverage')
cov_html.text('Coverage ' + coverage + '%')
$('.ci_widget:visible').append(cov_html)
loadDiff: (event) ->
$.ajax
......
......@@ -113,6 +113,10 @@
margin-bottom: 0;
}
}
.ci-coverage {
float: right;
}
}
.merge-request-show-labels .label {
......
......@@ -150,8 +150,17 @@ def update_branches
end
def ci_status
status = @merge_request.source_project.ci_service.commit_status(merge_request.last_commit.sha)
response = {status: status}
ci_service = @merge_request.source_project.ci_service
status = ci_service.commit_status(merge_request.last_commit.sha)
if ci_service.respond_to?(:commit_coverage)
coverage = ci_service.commit_coverage(merge_request.last_commit.sha)
end
response = {
status: status,
coverage: coverage
}
render json: response
end
......
......@@ -31,8 +31,13 @@ def commit_status_path sha
project_url + "/builds/#{sha}/status.json?token=#{token}"
end
def commit_status sha
response = HTTParty.get(commit_status_path(sha), verify: false)
def get_ci_build(sha)
@ci_builds ||= {}
@ci_builds[sha] ||= HTTParty.get(commit_status_path(sha), verify: false)
end
def commit_status(sha)
response = get_ci_build(sha)
if response.code == 200 and response["status"]
response["status"]
......@@ -41,6 +46,14 @@ def commit_status sha
end
end
def commit_coverage(sha)
response = get_ci_build(sha)
if response.code == 200 and response["coverage"]
response["coverage"]
end
end
def build_page sha
project_url + "/builds/#{sha}"
end
......
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