Commit ad627e40 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'ci-commit-page' into 'master'

Render CI statuses on commit page

This MR merges CI commit page into CE commit page.
Signed-off-by: default avatarDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>

See merge request !1519
parents fcc39d55 f509e3af
No related merge requests found
......@@ -107,3 +107,16 @@
z-index: 2;
}
}
.commit-ci-menu {
padding: 0;
margin: 0;
list-style: none;
margin-top: 5px;
height: 56px;
margin: -16px;
padding: 16px;
text-align: center;
margin-top: 0px;
margin-bottom: 2px;
}
......@@ -31,6 +31,13 @@ class Projects::CommitController < Projects::ApplicationController
end
end
def ci
@ci_commit = @project.ci_commit(@commit.sha)
@builds = @ci_commit.builds if @ci_commit
@notes_count = @commit.notes.count
@ci_project = @project.gitlab_ci_project
end
def branches
@branches = @project.repository.branch_names_contains(commit.id)
@tags = @project.repository.tag_names_contains(commit.id)
......
module CiStatusHelper
def ci_status_path(ci_commit)
ci_project_commits_path(ci_commit.project, ci_commit)
project = ci_commit.gl_project
ci_namespace_project_commit_path(project.namespace, project, ci_commit.sha)
end
def ci_status_icon(ci_commit)
......
%ul.center-top-menu.commit-ci-menu
= nav_link(path: 'commit#show') do
= link_to namespace_project_commit_path(@project.namespace, @project, @commit.id) do
Changes
= nav_link(path: 'commit#ci') do
= link_to ci_namespace_project_commit_path(@project.namespace, @project, @commit.id) do
Builds
- page_title "#{@commit.title} (#{@commit.short_id})", "Commits"
= render "projects/commits/header_title"
= render "commit_box"
= render "ci_menu"
- if @ci_project && current_user && can?(current_user, :manage_builds, @project)
.pull-right
- if @ci_commit.builds.running_or_pending.any?
= link_to "Cancel", cancel_ci_project_commits_path(@ci_project, @ci_commit), class: 'btn btn-sm btn-danger'
- if @ci_commit.yaml_errors.present?
.bs-callout.bs-callout-danger
%h4 Found errors in your .gitlab-ci.yml:
%ul
- @ci_commit.yaml_errors.split(",").each do |error|
%li= error
- unless @ci_commit.ci_yaml_file
.bs-callout.bs-callout-warning
\.gitlab-ci.yml not found in this commit
- @ci_commit.refs.each do |ref|
.gray-content-block.second-block
Builds for #{ref}
- if @ci_commit.duration_for_ref(ref) > 0
%small.pull-right
%i.fa.fa-time
#{time_interval_in_words @ci_commit.duration_for_ref(ref)}
%table.table.builds
%thead
%tr
%th Status
%th Build ID
%th Stage
%th Name
%th Duration
%th Finished at
- if @ci_project && @ci_project.coverage_enabled?
%th Coverage
%th
= render partial: "ci/builds/build", collection: @ci_commit.builds_without_retry.for_ref(ref), controls: true
- if @ci_commit.retried_builds.any?
%h3
Retried builds
%table.table.builds
%thead
%tr
%th Status
%th Build ID
%th Ref
%th Stage
%th Name
%th Duration
%th Finished at
- if @ci_project && @ci_project.coverage_enabled?
%th Coverage
%th
= render partial: "ci/builds/build", collection: @ci_commit.retried_builds, ref: true
- page_title "#{@commit.title} (#{@commit.short_id})", "Commits"
= render "projects/commits/header_title"
= render "commit_box"
= render "ci_menu" if @ci_commit
= render "projects/diffs/diffs", diffs: @diffs, project: @project
= render "projects/notes/notes_with_form", view: params[:view]
......@@ -485,7 +485,10 @@ Gitlab::Application.routes.draw do
resource :avatar, only: [:show, :destroy]
resources :commit, only: [:show], constraints: { id: /[[:alnum:]]{6,40}/ } do
get :branches, on: :member
member do
get :branches
get :ci
end
end
resources :compare, only: [:index, :create]
......
......@@ -20,6 +20,8 @@ Feature: Project Commits
Given commit has ci status
And I click on commit link
Then I see commit ci info
And I click status link
Then I see builds list
Scenario: I browse commit with side-by-side diff view
Given I click on commit link
......
......@@ -104,10 +104,20 @@ class Spinach::Features::ProjectCommits < Spinach::FeatureSteps
step 'commit has ci status' do
@project.enable_ci
create :ci_commit, gl_project: @project, sha: sample_commit.id
ci_commit = create :ci_commit, gl_project: @project, sha: sample_commit.id
create :ci_build, commit: ci_commit
end
step 'I see commit ci info' do
expect(page).to have_content "build: skipped"
expect(page).to have_content "build: pending"
end
step 'I click status link' do
click_link "Builds"
end
step 'I see builds list' do
expect(page).to have_content "build: pending"
expect(page).to have_content "Builds for master"
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