Commit 081a0ddc authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce

parents 827367ea 24e8445a
......@@ -3,6 +3,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 8.1.0 (unreleased)
- Show CI status on all pages where commits list is rendered
- Automatically enable CI when push .gitlab-ci.yml file to repository
- Move CI charts to project graphs area
- Fix cases where Markdown did not render links in activity feed (Stan Hu)
- Add first and last to pagination (Zeger-Jan van de Weg)
......@@ -15,6 +16,7 @@ v 8.0.2 (unreleased)
- Fix LDAP attribute mapping
v 8.0.1
- Remove git refs used internally by GitLab from network graph (Stan Hu)
- Improve CI migration procedure and documentation
v 8.0.0
......
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
......@@ -25,4 +25,10 @@ class Projects::ApplicationController < ApplicationController
)
end
end
private
def ci_enabled
return render_404 unless @project.gitlab_ci?
end
end
......@@ -5,6 +5,7 @@ class Projects::GraphsController < Projects::ApplicationController
before_action :require_non_empty_project
before_action :assign_ref_vars
before_action :authorize_download_code!
before_action :ci_enabled, only: :ci
def show
respond_to do |format|
......@@ -23,6 +24,16 @@ class Projects::GraphsController < Projects::ApplicationController
@commits_per_month = @commits_graph.commits_per_month
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
def fetch_graph
......
module GraphHelper
def get_refs(repo, commit)
refs = ""
refs << commit.ref_names(repo).join(' ')
# Commit::ref_names already strips the refs/XXX from important refs (e.g. refs/heads/XXX)
# so anything leftover is internally used by GitLab
commit_refs = commit.ref_names(repo).reject{ |name| name.starts_with?('refs/') }
refs << commit_refs.join(' ')
# append note count
refs << "[#{@graph.notes[commit.id]}]" if @graph.notes[commit.id] > 0
......
module VersionCheckHelper
def version_status_badge
if Rails.env.production?
if Rails.env.production? && current_application_settings.version_check_enabled
image_tag VersionCheck.new.url
end
end
......
#charts.ci-charts
= render 'builds'
= render 'build_times'
= render 'overall'
%div
%h1
GitLab
%span= Gitlab::VERSION
%small= Gitlab::REVISION
- if current_application_settings.version_check_enabled
Community Edition
- if user_signed_in?
%span= Gitlab::VERSION
%small= Gitlab::REVISION
= version_status_badge
%p.slead
GitLab is open source software to collaborate on code.
%br
Manage git repositories with fine grained access controls that keep your code secure.
Manage git repositories with fine-grained access controls that keep your code secure.
%br
Perform code reviews and enhance collaboration with merge requests.
%br
......@@ -33,19 +34,8 @@
.panel-heading
Quick help
%ul.well-list
%li
See our website for
= link_to 'getting help', promo_url + '/getting-help/'
%li
Use the
= link_to 'search bar', '#', onclick: 'Shortcuts.focusSearch(event)'
on the top of this page
%li
Use
= link_to 'shortcuts', '#', onclick: 'Shortcuts.showHelp(event)'
%li
Get a support
= link_to 'subscription', 'https://about.gitlab.com/pricing/'
%li
= link_to 'Compare', 'https://about.gitlab.com/features/#compare'
GitLab editions
%li= link_to 'See our website for getting help', promo_url + '/getting-help/'
%li= link_to 'Use the search bar on the top of this page', '#', onclick: 'Shortcuts.focusSearch(event)'
%li= link_to 'Use shortcuts', '#', onclick: 'Shortcuts.showHelp(event)'
%li= link_to 'Get a support subscription', 'https://about.gitlab.com/pricing/'
%li= link_to 'Compare GitLab editions', 'https://about.gitlab.com/features/#compare'
......@@ -10,12 +10,6 @@
%span
Commits
%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
= link_to ci_project_runners_path(@project) do
= icon('cog fw')
......
......@@ -3,3 +3,7 @@
= link_to 'Contributors', namespace_project_graph_path
= nav_link(action: :commits) do
= 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 "header_title"
= 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
%legend Overall
%p
Total:
%strong= pluralize @project.builds.count(:all), 'build'
%strong= pluralize ci_project.builds.count(:all), 'build'
%p
Successful:
%strong= pluralize @project.builds.success.count(:all), 'build'
%strong= pluralize ci_project.builds.success.count(:all), 'build'
%p
Failed:
%strong= pluralize @project.builds.failed.count(:all), 'build'
%strong= pluralize ci_project.builds.failed.count(:all), 'build'
%p
Success ratio:
%strong
#{success_ratio(@project.builds.success, @project.builds.failed)}%
#{success_ratio(ci_project.builds.success, ci_project.builds.failed)}%
%p
Commits covered:
%strong
= @project.commits.count(:all)
= ci_project.commits.count(:all)
......@@ -511,6 +511,7 @@ Gitlab::Application.routes.draw do
resources :graphs, only: [:show], constraints: { id: /(?:[^.]|\.(?!json$))+/, format: /json/ } do
member do
get :commits
get :ci
end
end
......
......@@ -12,3 +12,9 @@ Feature: Project Graph
Scenario: I should see project commits graphs
When I visit project "Shop" commits graph page
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
end
When 'I visit project "Shop" graph page' do
project = Project.find_by(name: "Shop")
visit namespace_project_graph_path(project.namespace, project, "master")
end
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")
end
......@@ -20,4 +18,24 @@ class Spinach::Features::ProjectGraph < Spinach::FeatureSteps
expect(page).to have_content "Commit statistics for master"
expect(page).to have_content "Commits per day of month"
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
......@@ -45,16 +45,4 @@ describe "Projects" do
expect(find_field('Timeout').value).to eq '70'
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
require 'spec_helper'
describe GraphHelper do
describe '#get_refs' do
let(:project) { create(:project) }
let(:commit) { project.commit("master") }
let(:graph) { Network::Graph.new(project, 'master', commit, '') }
it 'filter our refs used by GitLab' do
allow(commit).to receive(:ref_names).and_return(['refs/merge-requests/abc', 'master', 'refs/tmp/xyz'])
self.instance_variable_set(:@graph, graph)
refs = get_refs(project.repository, commit)
expect(refs).to eq('master')
end
end
end
require 'rails_helper'
describe 'help/index' do
describe 'version information' do
it 'is hidden from guests' do
stub_user(nil)
stub_version('8.0.2', 'abcdefg')
stub_helpers
render
expect(rendered).not_to match '8.0.2'
expect(rendered).not_to match 'abcdefg'
end
it 'is shown to users' do
stub_user
stub_version('8.0.2', 'abcdefg')
stub_helpers
render
expect(rendered).to match '8.0.2'
expect(rendered).to match 'abcdefg'
end
end
def stub_user(user = double)
allow(view).to receive(:user_signed_in?).and_return(user)
end
def stub_version(version, revision)
stub_const('Gitlab::VERSION', version)
stub_const('Gitlab::REVISION', revision)
end
def stub_helpers
allow(view).to receive(:markdown).and_return('')
allow(view).to receive(:version_status_badge).and_return('')
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