Commit eae27d1e authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Move CI charts to project graphs area

Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
parent 4bc1e040
module Ci
class ChartsController < Ci::ApplicationController
before_action :authenticate_user!
before_action :project
before_action :authorize_access_project!
before_action :authorize_manage_project!
layout 'ci/project'
def show
@charts = {}
@charts[:week] = Ci::Charts::WeekChart.new(@project)
@charts[:month] = Ci::Charts::MonthChart.new(@project)
@charts[:year] = Ci::Charts::YearChart.new(@project)
@charts[:build_times] = Ci::Charts::BuildTime.new(@project)
end
protected
def project
@project = Ci::Project.find(params[:project_id])
end
end
end
...@@ -23,6 +23,16 @@ class Projects::GraphsController < Projects::ApplicationController ...@@ -23,6 +23,16 @@ class Projects::GraphsController < Projects::ApplicationController
@commits_per_month = @commits_graph.commits_per_month @commits_per_month = @commits_graph.commits_per_month
end end
def ci
ci_project = @project.gitlab_ci_project
@charts = {}
@charts[:week] = Ci::Charts::WeekChart.new(ci_project)
@charts[:month] = Ci::Charts::MonthChart.new(ci_project)
@charts[:year] = Ci::Charts::YearChart.new(ci_project)
@charts[:build_times] = Ci::Charts::BuildTime.new(ci_project)
end
private private
def fetch_graph def fetch_graph
......
#charts.ci-charts
= render 'builds'
= render 'build_times'
= render 'overall'
...@@ -10,12 +10,6 @@ ...@@ -10,12 +10,6 @@
%span %span
Commits Commits
%span.count= @project.commits.count %span.count= @project.commits.count
- if can?(current_user, :admin_project, gl_project)
= nav_link path: 'charts#show' do
= link_to ci_project_charts_path(@project) do
= icon('bar-chart fw')
%span
Charts
= nav_link path: ['runners#index', 'runners#show', 'runners#edit'] do = nav_link path: ['runners#index', 'runners#show', 'runners#edit'] do
= link_to ci_project_runners_path(@project) do = link_to ci_project_runners_path(@project) do
= icon('cog fw') = icon('cog fw')
......
...@@ -3,3 +3,7 @@ ...@@ -3,3 +3,7 @@
= link_to 'Contributors', namespace_project_graph_path = link_to 'Contributors', namespace_project_graph_path
= nav_link(action: :commits) do = nav_link(action: :commits) do
= link_to 'Commits', commits_namespace_project_graph_path = link_to 'Commits', commits_namespace_project_graph_path
- if @project.gitlab_ci?
= nav_link(action: :ci) do
= link_to ci_namespace_project_graph_path do
Continuous Integration
- page_title "Continuous Integration", "Graphs"
= render 'head'
#charts.ci-charts
= render 'projects/graphs/ci/builds'
= render 'projects/graphs/ci/build_times'
= render 'projects/graphs/ci/overall'
- ci_project = @project.gitlab_ci_project
%fieldset %fieldset
%legend Overall %legend Overall
%p %p
Total: Total:
%strong= pluralize @project.builds.count(:all), 'build' %strong= pluralize ci_project.builds.count(:all), 'build'
%p %p
Successful: Successful:
%strong= pluralize @project.builds.success.count(:all), 'build' %strong= pluralize ci_project.builds.success.count(:all), 'build'
%p %p
Failed: Failed:
%strong= pluralize @project.builds.failed.count(:all), 'build' %strong= pluralize ci_project.builds.failed.count(:all), 'build'
%p %p
Success ratio: Success ratio:
%strong %strong
#{success_ratio(@project.builds.success, @project.builds.failed)}% #{success_ratio(ci_project.builds.success, ci_project.builds.failed)}%
%p %p
Commits covered: Commits covered:
%strong %strong
= @project.commits.count(:all) = ci_project.commits.count(:all)
...@@ -511,6 +511,7 @@ Gitlab::Application.routes.draw do ...@@ -511,6 +511,7 @@ Gitlab::Application.routes.draw do
resources :graphs, only: [:show], constraints: { id: /(?:[^.]|\.(?!json$))+/, format: /json/ } do resources :graphs, only: [:show], constraints: { id: /(?:[^.]|\.(?!json$))+/, format: /json/ } do
member do member do
get :commits get :commits
get :ci
end end
end end
......
...@@ -12,3 +12,9 @@ Feature: Project Graph ...@@ -12,3 +12,9 @@ Feature: Project Graph
Scenario: I should see project commits graphs Scenario: I should see project commits graphs
When I visit project "Shop" commits graph page When I visit project "Shop" commits graph page
Then page should have commits graphs Then page should have commits graphs
@javascript
Scenario: I should see project ci graphs
Given project "Shop" has CI enabled
When I visit project "Shop" CI graph page
Then page should have CI graphs
...@@ -7,12 +7,10 @@ class Spinach::Features::ProjectGraph < Spinach::FeatureSteps ...@@ -7,12 +7,10 @@ class Spinach::Features::ProjectGraph < Spinach::FeatureSteps
end end
When 'I visit project "Shop" graph page' do When 'I visit project "Shop" graph page' do
project = Project.find_by(name: "Shop")
visit namespace_project_graph_path(project.namespace, project, "master") visit namespace_project_graph_path(project.namespace, project, "master")
end end
step 'I visit project "Shop" commits graph page' do step 'I visit project "Shop" commits graph page' do
project = Project.find_by(name: "Shop")
visit commits_namespace_project_graph_path(project.namespace, project, "master") visit commits_namespace_project_graph_path(project.namespace, project, "master")
end end
...@@ -20,4 +18,24 @@ class Spinach::Features::ProjectGraph < Spinach::FeatureSteps ...@@ -20,4 +18,24 @@ class Spinach::Features::ProjectGraph < Spinach::FeatureSteps
expect(page).to have_content "Commit statistics for master" expect(page).to have_content "Commit statistics for master"
expect(page).to have_content "Commits per day of month" expect(page).to have_content "Commits per day of month"
end end
step 'I visit project "Shop" CI graph page' do
visit ci_namespace_project_graph_path(project.namespace, project, 'master')
end
step 'project "Shop" has CI enabled' do
project.enable_ci(@user)
end
step 'page should have CI graphs' do
expect(page).to have_content 'Overall'
expect(page).to have_content 'Builds chart for last week'
expect(page).to have_content 'Builds chart for last month'
expect(page).to have_content 'Builds chart for last year'
expect(page).to have_content 'Commit duration in minutes for last 30 commits'
end
def project
project ||= Project.find_by(name: "Shop")
end
end end
...@@ -45,16 +45,4 @@ describe "Projects" do ...@@ -45,16 +45,4 @@ describe "Projects" do
expect(find_field('Timeout').value).to eq '70' expect(find_field('Timeout').value).to eq '70'
end end
end end
describe "GET /ci/projects/:id/charts" do
before do
visit ci_project_charts_path(@project)
end
it { expect(page).to have_content 'Overall' }
it { expect(page).to have_content 'Builds chart for last week' }
it { expect(page).to have_content 'Builds chart for last month' }
it { expect(page).to have_content 'Builds chart for last year' }
it { expect(page).to have_content 'Commit duration in minutes for last 30 commits' }
end
end 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