Commit 9b5d2753 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'improve-ci-graphs'

parents 8ecc6f94 802b8fce
...@@ -28,6 +28,7 @@ v 8.2.0 (unreleased) ...@@ -28,6 +28,7 @@ v 8.2.0 (unreleased)
- New design for project graphs page - New design for project graphs page
- Fix incoming email config defaults - Fix incoming email config defaults
- MR target branch is now visible on a list view when it is different from project's default one - MR target branch is now visible on a list view when it is different from project's default one
- Improve Continuous Integration graphs page
v 8.1.4 v 8.1.4
- Fix bug where manually merged branches in a MR would end up with an empty diff (Stan Hu) - Fix bug where manually merged branches in a MR would end up with an empty diff (Stan Hu)
......
- page_title "Continuous Integration", "Graphs" - page_title "Continuous Integration", "Graphs"
= render "header_title" = render "header_title"
= render 'head' = render 'head'
.gray-content-block .gray-content-block.append-bottom-default
%ul.breadcrumb.repo-breadcrumb .oneline
= commits_breadcrumbs A collection of graphs for Continuous Integration
#charts.ci-charts #charts.ci-charts
= render 'projects/graphs/ci/builds' .row
.col-md-6
= render 'projects/graphs/ci/overall'
.col-md-6
= render 'projects/graphs/ci/build_times' = render 'projects/graphs/ci/build_times'
= render 'projects/graphs/ci/overall'
%hr
= render 'projects/graphs/ci/builds'
%fieldset %div
%legend %p.light
Commit duration in minutes for last 30 commits Commit duration in minutes for last 30 commits
%canvas#build_timesChart.padded{width: 800, height: 300} %canvas#build_timesChart{height: 200}
:javascript :javascript
var data = { var data = {
labels : #{@charts[:build_times].labels.to_json}, labels : #{@charts[:build_times].labels.to_json},
datasets : [ datasets : [
{ {
fillColor : "#4A3", fillColor : "rgba(220,220,220,0.5)",
strokeColor : "rgba(151,187,205,1)", strokeColor : "rgba(220,220,220,1)",
pointColor : "rgba(151,187,205,1)", barStrokeWidth: 1,
pointStrokeColor : "#fff", barValueSpacing: 1,
barDatasetSpacing: 1,
data : #{@charts[:build_times].build_times.to_json} data : #{@charts[:build_times].build_times.to_json}
} }
] ]
} }
var ctx = $("#build_timesChart").get(0).getContext("2d"); var ctx = $("#build_timesChart").get(0).getContext("2d");
new Chart(ctx).Line(data,{"scaleOverlay": true}); new Chart(ctx).Bar(data,{"scaleOverlay": true, responsive: true, maintainAspectRatio: false});
%fieldset %h4 Build charts
%legend %p
Builds chart for last week  
(#{date_from_to(Date.today - 7.days, Date.today)}) %span.cgreen
= icon("circle")
success
 
%span.cgray
= icon("circle")
all
%canvas#weekChart.padded{width: 800, height: 200} .prepend-top-default
%p.light
Builds for last week
(#{date_from_to(Date.today - 7.days, Date.today)})
%canvas#weekChart{height: 200}
%fieldset .prepend-top-default
%legend %p.light
Builds chart for last month Builds for last month
(#{date_from_to(Date.today - 30.days, Date.today)}) (#{date_from_to(Date.today - 30.days, Date.today)})
%canvas#monthChart{height: 200}
%canvas#monthChart.padded{width: 800, height: 300} .prepend-top-default
%p.light
%fieldset Builds for last year
%legend Builds chart for last year %canvas#yearChart.padded{height: 250}
%canvas#yearChart.padded{width: 800, height: 400}
- [:week, :month, :year].each do |scope| - [:week, :month, :year].each do |scope|
:javascript :javascript
...@@ -22,20 +32,20 @@ ...@@ -22,20 +32,20 @@
labels : #{@charts[scope].labels.to_json}, labels : #{@charts[scope].labels.to_json},
datasets : [ datasets : [
{ {
fillColor : "rgba(220,220,220,0.5)", fillColor : "#7f8fa4",
strokeColor : "rgba(220,220,220,1)", strokeColor : "#7f8fa4",
pointColor : "rgba(220,220,220,1)", pointColor : "#7f8fa4",
pointStrokeColor : "#EEE", pointStrokeColor : "#EEE",
data : #{@charts[scope].total.to_json} data : #{@charts[scope].total.to_json}
}, },
{ {
fillColor : "#4A3", fillColor : "#44aa22",
strokeColor : "rgba(151,187,205,1)", strokeColor : "#44aa22",
pointColor : "rgba(151,187,205,1)", pointColor : "#44aa22",
pointStrokeColor : "#fff", pointStrokeColor : "#fff",
data : #{@charts[scope].success.to_json} data : #{@charts[scope].success.to_json}
} }
] ]
} }
var ctx = $("##{scope}Chart").get(0).getContext("2d"); var ctx = $("##{scope}Chart").get(0).getContext("2d");
new Chart(ctx).Line(data,{"scaleOverlay": true}); new Chart(ctx).Line(data,{"scaleOverlay": true, responsive: true, maintainAspectRatio: false});
- ci_project = @project.gitlab_ci_project - ci_project = @project.gitlab_ci_project
%fieldset %h4 Overall stats
%legend Overall %ul
%p %li
Total: Total:
%strong= pluralize ci_project.builds.count(:all), 'build' %strong= pluralize ci_project.builds.count(:all), 'build'
%p %li
Successful: Successful:
%strong= pluralize ci_project.builds.success.count(:all), 'build' %strong= pluralize ci_project.builds.success.count(:all), 'build'
%p %li
Failed: Failed:
%strong= pluralize ci_project.builds.failed.count(:all), 'build' %strong= pluralize ci_project.builds.failed.count(:all), 'build'
%li
%p
Success ratio: Success ratio:
%strong %strong
#{success_ratio(ci_project.builds.success, ci_project.builds.failed)}% #{success_ratio(ci_project.builds.success, ci_project.builds.failed)}%
%li
%p
Commits covered: Commits covered:
%strong %strong
= ci_project.commits.count(:all) = ci_project.commits.count(:all)
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
= render "header_title" = render "header_title"
= render 'head' = render 'head'
.gray-content-block .gray-content-block.append-bottom-default
.tree-ref-holder .tree-ref-holder
= render 'shared/ref_switcher', destination: 'graphs_commits' = render 'shared/ref_switcher', destination: 'graphs_commits'
%ul.breadcrumb.repo-breadcrumb %ul.breadcrumb.repo-breadcrumb
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
= render "header_title" = render "header_title"
= render 'head' = render 'head'
.gray-content-block .gray-content-block.append-bottom-default
.tree-ref-holder .tree-ref-holder
= render 'shared/ref_switcher', destination: 'graphs' = render 'shared/ref_switcher', destination: 'graphs'
%ul.breadcrumb.repo-breadcrumb %ul.breadcrumb.repo-breadcrumb
......
...@@ -25,9 +25,9 @@ class Spinach::Features::ProjectGraph < Spinach::FeatureSteps ...@@ -25,9 +25,9 @@ class Spinach::Features::ProjectGraph < Spinach::FeatureSteps
step 'page should have CI graphs' do step 'page should have CI graphs' do
expect(page).to have_content 'Overall' expect(page).to have_content 'Overall'
expect(page).to have_content 'Builds chart for last week' expect(page).to have_content 'Builds for last week'
expect(page).to have_content 'Builds chart for last month' expect(page).to have_content 'Builds for last month'
expect(page).to have_content 'Builds chart for last year' expect(page).to have_content 'Builds for last year'
expect(page).to have_content 'Commit duration in minutes for last 30 commits' expect(page).to have_content 'Commit duration in minutes for last 30 commits'
end end
......
...@@ -60,7 +60,8 @@ module Ci ...@@ -60,7 +60,8 @@ module Ci
class BuildTime < Chart class BuildTime < Chart
def collect def collect
commits = project.commits.joins(:builds).where("#{Ci::Build.table_name}.finished_at is NOT NULL AND #{Ci::Build.table_name}.started_at is NOT NULL").last(30) commits = project.commits.last(30)
commits.each do |commit| commits.each do |commit|
@labels << commit.short_sha @labels << commit.short_sha
@build_times << (commit.duration / 60) @build_times << (commit.duration / 60)
......
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