BigW Consortium Gitlab

Commit 030b5038 by Dmitriy Zaporozhets

Merge branch 'cleanup-ci-pages' into 'master'

Cleanup CI pages - [x] Remove `ci/projects/:id` page - [x] Remove Continuous integration from project menu - [x] Remove unused css/js - [x] Remove Ci::Commit and Ci::Build controllers - [x] Move CI services to project settings area cc @ayufan Part of #2594 See merge request !1529
parents 92c33a8e 7f63a878
......@@ -35,6 +35,7 @@ v 8.1.0 (unreleased)
- Add user preference to change layout width (Peter Göbel)
- Use commit status in merge request widget as preffered source of CI status
- Integrate CI commit and build pages into project pages
- Move CI services page to project settings area
v 8.0.4
- Fix Message-ID header to be RFC 2111-compliant to prevent e-mails being dropped (Stan Hu)
......
$(document).on 'click', '.badge-codes-toggle', ->
$('.badge-codes-block').toggleClass("hide")
return false
$(document).on 'click', '.sync-now', ->
$(this).find('i').addClass('fa-spin')
module Ci
class BuildsController < Ci::ApplicationController
before_action :authenticate_user!, except: [:status]
before_action :project
before_action :authorize_access_project!, except: [:status]
before_action :authorize_manage_project!, except: [:status, :retry, :cancel]
before_action :authorize_manage_builds!, only: [:retry, :cancel]
before_action :build
def retry
if @build.commands.blank?
return page_404
end
build = Ci::Build.retry(@build)
if params[:return_to]
redirect_to URI.parse(params[:return_to]).path
else
redirect_to build_path(build)
end
end
def status
render json: @build.to_json(only: [:status, :id, :sha, :coverage], methods: :sha)
end
def cancel
@build.cancel
redirect_to build_path(@build)
end
protected
def project
@project = Ci::Project.find(params[:project_id])
end
def build
@build ||= project.builds.unscoped.find_by!(id: params[:id])
end
def commit_by_sha
@project.commits.find_by(sha: params[:id])
end
def build_path(build)
namespace_project_build_path(build.gl_project.namespace, build.gl_project, build)
end
end
end
module Ci
class CommitsController < Ci::ApplicationController
before_action :authenticate_user!, except: [:status, :show]
before_action :authenticate_public_page!, only: :show
before_action :project
before_action :authorize_access_project!, except: [:status, :show, :cancel]
before_action :authorize_manage_builds!, only: [:cancel]
def status
commit = Ci::Project.find(params[:project_id]).commits.find_by_sha!(params[:id])
render json: commit.to_json(only: [:id, :sha], methods: [:status, :coverage])
rescue ActiveRecord::RecordNotFound
render json: { status: "not_found" }
end
def cancel
commit.builds.running_or_pending.each(&:cancel)
redirect_to namespace_project_commit_path(commit.gl_project.namespace, commit.gl_project, commit.sha)
end
private
def project
@project ||= Ci::Project.find(params[:project_id])
end
def commit
@commit ||= Ci::Project.find(params[:project_id]).commits.find_by_sha!(params[:id])
end
end
end
module Ci
class ProjectsController < Ci::ApplicationController
before_action :authenticate_user!, except: [:build, :badge, :show]
before_action :authenticate_public_page!, only: :show
before_action :project, only: [:build, :show, :badge, :toggle_shared_runners, :dumped_yaml]
before_action :authorize_access_project!, except: [:build, :badge, :show, :new]
before_action :project
before_action :authenticate_user!, except: [:build, :badge]
before_action :authorize_access_project!, except: [:badge]
before_action :authorize_manage_project!, only: [:toggle_shared_runners, :dumped_yaml]
before_action :authenticate_token!, only: [:build]
before_action :no_cache, only: [:badge]
protect_from_forgery except: :build
layout 'ci/project', except: [:index]
def show
@ref = params[:ref]
@commits = @project.commits.reverse_order
if @ref
# unscope is required, because of default_scope defined in Ci::Build
builds = @project.builds.unscope(:select, :order).where(ref: @ref).select(:commit_id).distinct
@commits = @commits.where(id: builds)
end
@commits = @commits.page(params[:page]).per(20)
end
protect_from_forgery
# Project status badge
# Image with build status for sha or ref
......
......@@ -2,6 +2,8 @@ class Projects::BuildsController < Projects::ApplicationController
before_action :ci_project
before_action :build
before_action :authorize_admin_project!, except: [:show, :status]
layout "project"
def show
......@@ -17,9 +19,37 @@ class Projects::BuildsController < Projects::ApplicationController
end
end
def retry
if @build.commands.blank?
return page_404
end
build = Ci::Build.retry(@build)
if params[:return_to]
redirect_to URI.parse(params[:return_to]).path
else
redirect_to build_path(build)
end
end
def status
render json: @build.to_json(only: [:status, :id, :sha, :coverage], methods: :sha)
end
def cancel
@build.cancel
redirect_to build_path(@build)
end
private
def build
@build ||= ci_project.builds.unscoped.find_by!(id: params[:id])
end
def build_path(build)
namespace_project_build_path(build.gl_project.namespace, build.gl_project, build)
end
end
module Ci
class ServicesController < Ci::ApplicationController
before_action :authenticate_user!
before_action :project
before_action :authorize_access_project!
before_action :authorize_manage_project!
before_action :service, only: [:edit, :update, :test]
class Projects::CiServicesController < Projects::ApplicationController
before_action :ci_project
before_action :authorize_admin_project!
respond_to :html
layout "project_settings"
layout 'ci/project'
def index
@project.build_missing_services
@services = @project.services.reload
end
def index
@ci_project.build_missing_services
@services = @ci_project.services.reload
end
def edit
end
def edit
service
end
def update
if @service.update_attributes(service_params)
redirect_to edit_ci_project_service_path(@project, @service.to_param)
else
render 'edit'
end
def update
if @service.update_attributes(service_params)
redirect_to edit_namespace_project_ci_service_path(@project, @project.namespace, @service.to_param)
else
render 'edit'
end
end
def test
last_build = @project.builds.last
if @service.execute(last_build)
message = { notice: 'We successfully tested the service' }
else
message = { alert: 'We tried to test the service but error occurred' }
end
def test
last_build = @project.builds.last
redirect_to :back, message
if @service.execute(last_build)
message = { notice: 'We successfully tested the service' }
else
message = { alert: 'We tried to test the service but error occurred' }
end
private
redirect_to :back, message
end
def project
@project = Ci::Project.find(params[:project_id])
end
private
def service
@service ||= @project.services.find { |service| service.to_param == params[:id] }
end
def service
@service ||= @ci_project.services.find { |service| service.to_param == params[:id] }
end
def service_params
params.require(:service).permit(
:type, :active, :webhook, :notify_only_broken_builds,
:email_recipients, :email_only_broken_builds, :email_add_pusher,
:hipchat_token, :hipchat_room, :hipchat_server
)
end
def service_params
params.require(:service).permit(
:type, :active, :webhook, :notify_only_broken_builds,
:email_recipients, :email_only_broken_builds, :email_add_pusher,
:hipchat_token, :hipchat_room, :hipchat_server
)
end
end
......@@ -38,6 +38,14 @@ class Projects::CommitController < Projects::ApplicationController
@ci_project = @project.gitlab_ci_project
end
def cancel_builds
@ci_commit = @project.ci_commit(@commit.sha)
@ci_commit.builds.running_or_pending.each(&:cancel)
redirect_to ci_namespace_project_commit_path(project.namespace, project, commit.sha)
end
def branches
@branches = @project.repository.branch_names_contains(commit.id)
@tags = @project.repository.tag_names_contains(commit.id)
......
- if no_runners_for_project?(@project)
= render 'no_runners'
= render 'ci/shared/guide' unless @project.setup_finished?
- if current_user && can?(current_user, :manage_project, gl_project) && !@project.any_runners?
.alert.alert-danger
Builds for this project wont be served unless you configure runners on
= link_to "Runners page", runners_path(@project.gl_project)
%ul.nav.nav-tabs.append-bottom-20
%li{class: ref_tab_class}
= link_to 'All commits', ci_project_path(@project)
- @project.tracked_refs.each do |ref|
%li{class: ref_tab_class(ref)}
= link_to ref, ci_project_path(@project, ref: ref)
- if @ref && !@project.tracked_refs.include?(@ref)
%li{class: 'active'}
= link_to @ref, ci_project_path(@project, ref: @ref)
%li.pull-right
= link_to 'Go to project', project_path(gl_project), class: 'btn btn-sm'
- if @ref
%p
Paste build status image for #{@ref} with next link
= link_to '#', class: 'badge-codes-toggle btn btn-default btn-xs' do
Status Badge
.badge-codes-block.bs-callout.bs-callout-info.hide
%p
Status badge for
%span.label.label-info #{@ref}
branch
%div
%label Markdown:
= text_field_tag 'badge_md', markdown_badge_code(@project, @ref), readonly: true, class: 'form-control'
%label Html:
= text_field_tag 'badge_html', html_badge_code(@project, @ref), readonly: true, class: 'form-control'
%table.table.builds
%thead
%tr
%th Status
%th Commit
%th Message
%th Branch
%th Total duration
%th Finished at
- if @project.coverage_enabled?
%th Coverage
= render @commits
= paginate @commits
- if @commits.empty?
.bs-callout
%h4 No commits yet
......@@ -5,17 +5,6 @@
%span
Back to project
%li.separate-item
= nav_link path: ['projects#show', 'commits#show', 'builds#show'] do
= link_to ci_project_path(@project) do
= icon('list-alt fw')
%span
Commits
%span.count= @project.commits.count
= nav_link path: ['services#index', 'services#edit'] do
= link_to ci_project_services_path(@project) do
= icon('share fw')
%span
Services
= nav_link path: 'events#index' do
= link_to ci_project_events_path(@project) do
= icon('book fw')
......
......@@ -32,7 +32,7 @@
Files
- if project_nav_tab? :commits
= nav_link(controller: %w(commit commits compare repositories tags branches)) do
= nav_link(controller: %w(commit commits compare repositories tags branches builds)) do
= link_to project_commits_path(@project), title: 'Commits', class: 'shortcuts-commits', data: {placement: 'right'} do
= icon('history fw')
%span
......@@ -76,13 +76,6 @@
Merge Requests
%span.count.merge_counter= @project.merge_requests.opened.count
- if @project.gitlab_ci?
= nav_link(controller: [:ci, :project]) do
= link_to ci_project_path(@project.gitlab_ci_project), title: 'Continuous Integration', data: {placement: 'right'} do
= icon('building fw')
%span
Continuous Integration
- if project_nav_tab? :settings
= nav_link(controller: [:project_members, :teams]) do
= link_to namespace_project_project_members_path(@project.namespace, @project), title: 'Members', class: 'team-tab tab', data: {placement: 'right'} do
......
......@@ -60,3 +60,13 @@
= icon('building fw')
%span
CI Settings
= nav_link controller: 'ci_services' do
= link_to namespace_project_ci_services_path(@project.namespace, @project) do
= icon('share fw')
%span
CI Services
= nav_link path: 'events#index' do
= link_to ci_project_events_path(@project.gitlab_ci_project) do
= icon('book fw')
%span
CI Events
......@@ -43,8 +43,8 @@
- if defined?(controls) && current_user && can?(current_user, :manage_builds, gl_project)
.pull-right
- if build.active?
= link_to cancel_ci_project_build_path(build.project, build, return_to: request.original_url), title: 'Cancel build' do
= link_to cancel_namespace_project_build_path(gl_project.namespace, gl_project, build, return_to: request.original_url), title: 'Cancel build' do
%i.fa.fa-remove.cred
- elsif build.commands.present?
= link_to retry_ci_project_build_path(build.project, build, return_to: request.original_url), method: :post, title: 'Retry build' do
= link_to retry_namespace_project_build_path(gl_project.namespace, gl_project, build, return_to: request.original_url), method: :post, title: 'Retry build' do
%i.fa.fa-repeat
......@@ -72,9 +72,9 @@
- if current_user && can?(current_user, :manage_builds, @project)
.pull-right
- if @build.active?
= link_to "Cancel", cancel_ci_project_build_path(@ci_project, @build), class: 'btn btn-sm btn-danger'
= link_to "Cancel", cancel_namespace_project_build_path(@project.namespace, @project, @build), class: 'btn btn-sm btn-danger'
- elsif @build.commands.present?
= link_to "Retry", retry_ci_project_build_path(@ci_project, @build), class: 'btn btn-sm btn-primary', method: :post
= link_to "Retry", retry_namespace_project_build_path(@project.namespace, @project, @build), class: 'btn btn-sm btn-primary', method: :post
- if @build.duration
%p
......
......@@ -4,13 +4,10 @@
%p= @service.description
.back-link
= link_to ci_project_services_path(@project) do
&larr; to services
%hr
= form_for(@service, as: :service, url: ci_project_service_path(@project, @service.to_param), method: :put, html: { class: 'form-horizontal' }) do |f|
= form_for(@service, as: :service, url: namespace_project_ci_service_path(@project.namespace, @project, @service.to_param), method: :put, html: { class: 'form-horizontal' }) do |f|
- if @service.errors.any?
.alert.alert-danger
%ul
......@@ -54,4 +51,4 @@
= f.submit 'Save', class: 'btn btn-save'
&nbsp;
- if @service.valid? && @service.activated? && @service.can_test?
= link_to 'Test settings', test_ci_project_service_path(@project, @service.to_param), class: 'btn'
= link_to 'Test settings', test_namespace_project_ci_service_path(@project.namespace, @project, @service.to_param), class: 'btn'
......@@ -13,7 +13,7 @@
%td
= boolean_to_icon service.activated?
%td
= link_to edit_ci_project_service_path(@project, service.to_param) do
= link_to edit_namespace_project_ci_service_path(@project.namespace, @project, service.to_param) do
%strong= service.title
%td
= service.description
......
......@@ -8,6 +8,22 @@
Edit your
#{link_to ".gitlab-ci.yml using web-editor", yaml_web_editor_link(@ci_project)}
- unless @project.empty_repo?
%p
Paste build status image for #{@repository.root_ref} with next link
= link_to '#', class: 'badge-codes-toggle btn btn-default btn-xs' do
Status Badge
.badge-codes-block.bs-callout.bs-callout-info.hide
%p
Status badge for
%span.label.label-info #{@ref}
branch
%div
%label Markdown:
= text_field_tag 'badge_md', markdown_badge_code(@ci_project, @repository.root_ref), readonly: true, class: 'form-control'
%label Html:
= text_field_tag 'badge_html', html_badge_code(@ci_project, @repository.root_ref), readonly: true, class: 'form-control'
= nested_form_for @ci_project, url: namespace_project_ci_settings_path(@project.namespace, @project), html: { class: 'form-horizontal' } do |f|
- if @ci_project.errors.any?
#error_explanation
......
......@@ -4,5 +4,5 @@
%br
You can add Specific runner for this project on Runners page
- if current_user.is_admin
- if current_user.admin
or add Shared runner for whole application in admin are.
......@@ -6,6 +6,9 @@
yaml file which is based on your old jobs.
Put this file to the root of your project and name it .gitlab-ci.yml
- if no_runners_for_project?(@ci_project)
= render 'no_runners'
= render 'form'
- if @ci_project.generated_yaml_config
......
......@@ -6,7 +6,7 @@
- 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'
= link_to "Cancel", cancel_builds_namespace_project_commit_path(@project.namespace, @project, @commit.sha), class: 'btn btn-sm btn-danger'
- if @ci_commit.yaml_errors.present?
......
......@@ -22,27 +22,6 @@ Gitlab::Application.routes.draw do
get :dumped_yaml
end
resources :services, only: [:index, :edit, :update] do
member do
get :test
end
end
resources :commits, only: [] do
member do
get :status
get :cancel
end
end
resources :builds, only: [] do
member do
get :cancel
get :status
post :retry
end
end
resources :runner_projects, only: [:create, :destroy]
resources :events, only: [:index]
......@@ -495,6 +474,7 @@ Gitlab::Application.routes.draw do
member do
get :branches
get :ci
get :cancel_builds
end
end
......@@ -599,7 +579,19 @@ Gitlab::Application.routes.draw do
end
end
resources :builds, only: [:show]
resources :ci_services, constraints: { id: /[^\/]+/ }, only: [:index, :edit, :update] do
member do
get :test
end
end
resources :builds, only: [:show] do
member do
get :cancel
get :status
post :retry
end
end
resources :hooks, only: [:index, :create, :destroy], constraints: { id: /\d+/ } do
member do
......
require "spec_helper"
describe Ci::CommitsController do
describe "GET /status" do
it "returns status of commit" do
commit = FactoryGirl.create :ci_commit
get :status, id: commit.sha, ref_id: commit.ref, project_id: commit.project.id
expect(response).to be_success
expect(response.code).to eq('200')
JSON.parse(response.body)["status"] == "pending"
end
it "returns not_found status" do
commit = FactoryGirl.create :ci_commit
get :status, id: commit.sha, ref_id: "deploy", project_id: commit.project.id
expect(response).to be_success
expect(response.code).to eq('200')
JSON.parse(response.body)["status"] == "not_found"
end
end
end
require 'spec_helper'
describe "Builds" do
before do
login_as(:user)
@commit = FactoryGirl.create :ci_commit
......@@ -19,4 +18,24 @@ describe "Builds" do
it { expect(page).to have_content @commit.git_commit_message }
it { expect(page).to have_content @commit.git_author_name }
end
describe "GET /:project/builds/:id/cancel" do
before do
@build.run!
visit cancel_namespace_project_build_path(@gl_project.namespace, @gl_project, @build)
end
it { expect(page).to have_content 'canceled' }
it { expect(page).to have_content 'Retry' }
end
describe "POST /:project/builds/:id/retry" do
before do
visit cancel_namespace_project_build_path(@gl_project.namespace, @gl_project, @build)
click_link 'Retry'
end
it { expect(page).to have_content 'pending' }
it { expect(page).to have_content 'Cancel' }
end
end
require 'spec_helper'
describe "Builds" do
before do
login_as(:user)
@commit = FactoryGirl.create :ci_commit
@build = FactoryGirl.create :ci_build, commit: @commit
@gl_project = @commit.project.gl_project
@gl_project.team << [@user, :master]
end
describe "GET /:project/builds/:id/cancel" do
before do
@build.run!
visit cancel_ci_project_build_path(@commit.project, @build)
end
it { expect(page).to have_content 'canceled' }
it { expect(page).to have_content 'Retry' }
end
describe "POST /:project/builds/:id/retry" do
before do
visit cancel_ci_project_build_path(@commit.project, @build)
click_link 'Retry'
end
it { expect(page).to have_content 'pending' }
it { expect(page).to have_content 'Cancel' }
end
end
require 'spec_helper'
describe "Projects" do
let(:user) { create(:user) }
before do
login_as(user)
@project = FactoryGirl.create :ci_project, name: "GitLab / gitlab-shell"
@project.gl_project.team << [user, :master]
end
describe "GET /ci/projects/:id" do
before do
visit ci_project_path(@project)
end
it { expect(page).to have_content @project.name }
it { expect(page).to have_content 'All commits' }
end
end
require 'spec_helper'
describe "Builds" do
before do
@commit = FactoryGirl.create :ci_commit
@build = FactoryGirl.create :ci_build, commit: @commit
end
describe "GET /:project/builds/:id/status.json" do
before do
get status_ci_project_build_path(@commit.project, @build), format: :json
end
it { expect(response.status).to eq(200) }
it { expect(response.body).to include(@build.sha) }
end
end
require 'spec_helper'
describe "Commits" do
before do
@commit = FactoryGirl.create :ci_commit
end
describe "GET /:project/refs/:ref_name/commits/:id/status.json" do
before do
get status_ci_project_commits_path(@commit.project, @commit.sha), format: :json
end
it { expect(response.status).to eq(200) }
it { expect(response.body).to include(@commit.sha) }
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