Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Léo-Paul Géneau
gitlab-ce
Commits
8e33f946
Commit
8e33f946
authored
Oct 02, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Show test coverage results in MR if available
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
71fce0b2
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
37 additions
and
5 deletions
+37
-5
app/assets/javascripts/merge_request.js.coffee
app/assets/javascripts/merge_request.js.coffee
+7
-1
app/assets/stylesheets/sections/merge_requests.scss
app/assets/stylesheets/sections/merge_requests.scss
+4
-0
app/controllers/projects/merge_requests_controller.rb
app/controllers/projects/merge_requests_controller.rb
+11
-2
app/models/project_services/gitlab_ci_service.rb
app/models/project_services/gitlab_ci_service.rb
+15
-2
No files found.
app/assets/javascripts/merge_request.js.coffee
View file @
8e33f946
...
...
@@ -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
...
...
app/assets/stylesheets/sections/merge_requests.scss
View file @
8e33f946
...
...
@@ -113,6 +113,10 @@
margin-bottom
:
0
;
}
}
.ci-coverage
{
float
:
right
;
}
}
.merge-request-show-labels
.label
{
...
...
app/controllers/projects/merge_requests_controller.rb
View file @
8e33f946
...
...
@@ -150,8 +150,17 @@ class Projects::MergeRequestsController < Projects::ApplicationController
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
...
...
app/models/project_services/gitlab_ci_service.rb
View file @
8e33f946
...
...
@@ -31,8 +31,13 @@ class GitlabCiService < CiService
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 @@ class GitlabCiService < CiService
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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment