Commit b6564195 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'move-runners-page'

parents d8e631c1 c876bfa0
...@@ -15,6 +15,7 @@ v 8.1.0 (unreleased) ...@@ -15,6 +15,7 @@ v 8.1.0 (unreleased)
- Remove "Continuous Integration" page from dashboard - Remove "Continuous Integration" page from dashboard
- Add notes and SSL verification entries to hook APIs (Ben Boeckel) - Add notes and SSL verification entries to hook APIs (Ben Boeckel)
- Fix grammar in admin area "labels" .nothing-here-block when no labels exist. - Fix grammar in admin area "labels" .nothing-here-block when no labels exist.
- Move CI runners page to project settings area
v 8.0.3 (unreleased) v 8.0.3 (unreleased)
......
...@@ -55,7 +55,8 @@ module Ci ...@@ -55,7 +55,8 @@ module Ci
def toggle_shared_runners def toggle_shared_runners
project.toggle!(:shared_runners_enabled) project.toggle!(:shared_runners_enabled)
redirect_to :back
redirect_to namespace_project_runners_path(project.gl_project.namespace, project.gl_project)
end end
def dumped_yaml def dumped_yaml
......
...@@ -11,10 +11,12 @@ module Ci ...@@ -11,10 +11,12 @@ module Ci
return head(403) unless current_user.ci_authorized_runners.include?(@runner) return head(403) unless current_user.ci_authorized_runners.include?(@runner)
path = runners_path(@project.gl_project)
if @runner.assign_to(project, current_user) if @runner.assign_to(project, current_user)
redirect_to ci_project_runners_path(project) redirect_to path
else else
redirect_to ci_project_runners_path(project), alert: 'Failed adding runner to project' redirect_to path, alert: 'Failed adding runner to project'
end end
end end
...@@ -22,7 +24,7 @@ module Ci ...@@ -22,7 +24,7 @@ module Ci
runner_project = project.runner_projects.find(params[:id]) runner_project = project.runner_projects.find(params[:id])
runner_project.destroy runner_project.destroy
redirect_to ci_project_runners_path(project) redirect_to runners_path(@project.gl_project)
end end
private private
......
module Ci
class RunnersController < Ci::ApplicationController
before_action :authenticate_user!
before_action :project
before_action :set_runner, only: [:edit, :update, :destroy, :pause, :resume, :show]
before_action :authorize_access_project!
before_action :authorize_manage_project!
layout 'ci/project'
def index
@runners = @project.runners.order('id DESC')
@specific_runners =
Ci::Runner.specific.includes(:runner_projects).
where(Ci::RunnerProject.table_name => { project_id: current_user.authorized_projects } ).
where.not(id: @runners).order("#{Ci::Runner.table_name}.id DESC").page(params[:page]).per(20)
@shared_runners = Ci::Runner.shared.active
@shared_runners_count = @shared_runners.count(:all)
end
def edit
end
def update
if @runner.update_attributes(runner_params)
redirect_to edit_ci_project_runner_path(@project, @runner), notice: 'Runner was successfully updated.'
else
redirect_to edit_ci_project_runner_path(@project, @runner), alert: 'Runner was not updated.'
end
end
def destroy
if @runner.only_for?(@project)
@runner.destroy
end
redirect_to ci_project_runners_path(@project)
end
def resume
if @runner.update_attributes(active: true)
redirect_to ci_project_runners_path(@project, @runner), notice: 'Runner was successfully updated.'
else
redirect_to ci_project_runners_path(@project, @runner), alert: 'Runner was not updated.'
end
end
def pause
if @runner.update_attributes(active: false)
redirect_to ci_project_runners_path(@project, @runner), notice: 'Runner was successfully updated.'
else
redirect_to ci_project_runners_path(@project, @runner), alert: 'Runner was not updated.'
end
end
def show
end
protected
def project
@project = Ci::Project.find(params[:project_id])
end
def set_runner
@runner ||= @project.runners.find(params[:id])
end
def runner_params
params.require(:runner).permit(:description, :tag_list, :contacted_at, :active)
end
end
end
class Projects::RunnersController < Projects::ApplicationController
before_action :ci_project
before_action :set_runner, only: [:edit, :update, :destroy, :pause, :resume, :show]
before_action :authorize_admin_project!
layout 'project_settings'
def index
@runners = @ci_project.runners.order('id DESC')
@specific_runners =
Ci::Runner.specific.includes(:runner_projects).
where(Ci::RunnerProject.table_name => { project_id: current_user.authorized_projects } ).
where.not(id: @runners).order("#{Ci::Runner.table_name}.id DESC").page(params[:page]).per(20)
@shared_runners = Ci::Runner.shared.active
@shared_runners_count = @shared_runners.count(:all)
end
def edit
end
def update
if @runner.update_attributes(runner_params)
redirect_to runner_path(@runner), notice: 'Runner was successfully updated.'
else
redirect_to runner_path(@runner), alert: 'Runner was not updated.'
end
end
def destroy
if @runner.only_for?(@ci_project)
@runner.destroy
end
redirect_to runners_path(@project)
end
def resume
if @runner.update_attributes(active: true)
redirect_to runner_path(@runner), notice: 'Runner was successfully updated.'
else
redirect_to runner_path(@runner), alert: 'Runner was not updated.'
end
end
def pause
if @runner.update_attributes(active: false)
redirect_to runner_path(@runner), notice: 'Runner was successfully updated.'
else
redirect_to runner_path(@runner), alert: 'Runner was not updated.'
end
end
def show
end
protected
def ci_project
@ci_project = @project.gitlab_ci_project
end
def set_runner
@runner ||= @ci_project.runners.find(params[:id])
end
def runner_params
params.require(:runner).permit(:description, :tag_list, :contacted_at, :active)
end
end
...@@ -33,6 +33,14 @@ module GitlabRoutingHelper ...@@ -33,6 +33,14 @@ module GitlabRoutingHelper
edit_namespace_project_path(project.namespace, project, *args) edit_namespace_project_path(project.namespace, project, *args)
end end
def runners_path(project, *args)
namespace_project_runners_path(project.namespace, project, *args)
end
def runner_path(runner, *args)
namespace_project_runner_path(@project.namespace, @project, runner, *args)
end
def issue_path(entity, *args) def issue_path(entity, *args)
namespace_project_issue_path(entity.project.namespace, entity.project, entity, *args) namespace_project_issue_path(entity.project.namespace, entity.project, entity, *args)
end end
......
...@@ -100,7 +100,7 @@ module Ci ...@@ -100,7 +100,7 @@ module Ci
def unassigned(runner) def unassigned(runner)
joins("LEFT JOIN #{Ci::RunnerProject.table_name} ON #{Ci::RunnerProject.table_name}.project_id = #{Ci::Project.table_name}.id " \ joins("LEFT JOIN #{Ci::RunnerProject.table_name} ON #{Ci::RunnerProject.table_name}.project_id = #{Ci::Project.table_name}.id " \
"AND #{Ci::RunnerProject.table_name}.runner_id = #{runner.id}"). "AND #{Ci::RunnerProject.table_name}.runner_id = #{runner.id}").
where('#{Ci::RunnerProject.table_name}.project_id' => nil) where("#{Ci::RunnerProject.table_name}.project_id" => nil)
end end
def ordered_by_last_commit_date def ordered_by_last_commit_date
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
- if current_user && can?(current_user, :manage_project, gl_project) && !@project.any_runners? - if current_user && can?(current_user, :manage_project, gl_project) && !@project.any_runners?
.alert.alert-danger .alert.alert-danger
Builds for this project wont be served unless you configure runners on Builds for this project wont be served unless you configure runners on
= link_to "Runners page", ci_project_runners_path(@project) = link_to "Runners page", runners_path(@project.gl_project)
%ul.nav.nav-tabs.append-bottom-20 %ul.nav.nav-tabs.append-bottom-20
%li{class: ref_tab_class} %li{class: ref_tab_class}
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
%ol %ol
%li %li
Add at least one runner to the project. Add at least one runner to the project.
Go to #{link_to 'Runners page', ci_project_runners_path(@project), target: :blank} for instructions. Go to #{link_to 'Runners page', runners_path(@project.gl_project), target: :blank} for instructions.
%li %li
Put the .gitlab-ci.yml in the root of your repository. Examples can be found in #{link_to "Configuring project (.gitlab-ci.yml)", "http://doc.gitlab.com/ci/yaml/README.html", target: :blank}. Put the .gitlab-ci.yml in the root of your repository. Examples can be found in #{link_to "Configuring project (.gitlab-ci.yml)", "http://doc.gitlab.com/ci/yaml/README.html", target: :blank}.
You can also test your .gitlab-ci.yml in the #{link_to "Lint", ci_lint_path} You can also test your .gitlab-ci.yml in the #{link_to "Lint", ci_lint_path}
......
...@@ -11,11 +11,6 @@ ...@@ -11,11 +11,6 @@
%span %span
Commits Commits
%span.count= @project.commits.count %span.count= @project.commits.count
= nav_link path: ['runners#index', 'runners#show', 'runners#edit'] do
= link_to ci_project_runners_path(@project) do
= icon('cog fw')
%span
Runners
= nav_link path: 'variables#show' do = nav_link path: 'variables#show' do
= link_to ci_project_variables_path(@project) do = link_to ci_project_variables_path(@project) do
= icon('code fw') = icon('code fw')
......
...@@ -34,3 +34,9 @@ ...@@ -34,3 +34,9 @@
%span %span
Protected Branches Protected Branches
- if @project.gitlab_ci?
= nav_link(controller: :runners) do
= link_to namespace_project_runners_path(@project.namespace, @project), title: 'Runners', data: {placement: 'right'} do
= icon('cog fw')
%span
Runners
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
= runner_status_icon(runner) = runner_status_icon(runner)
%span.monospace %span.monospace
- if @runners.include?(runner) - if @runners.include?(runner)
= link_to runner.short_sha, ci_project_runner_path(@project, runner) = link_to runner.short_sha, runner_path(runner)
%small %small
=link_to edit_ci_project_runner_path(@project, runner) do =link_to edit_namespace_project_runner_path(@project.namespace, @project, runner) do
%i.fa.fa-edit.btn %i.fa.fa-edit.btn
- else - else
= runner.short_sha = runner.short_sha
...@@ -13,12 +13,12 @@ ...@@ -13,12 +13,12 @@
.pull-right .pull-right
- if @runners.include?(runner) - if @runners.include?(runner)
- if runner.belongs_to_one_project? - if runner.belongs_to_one_project?
= link_to 'Remove runner', [:ci, @project, runner], data: { confirm: "Are you sure?" }, method: :delete, class: 'btn btn-danger btn-sm' = link_to 'Remove runner', runner_path(runner), data: { confirm: "Are you sure?" }, method: :delete, class: 'btn btn-danger btn-sm'
- else - else
- runner_project = @project.runner_projects.find_by(runner_id: runner) - runner_project = @ci_project.runner_projects.find_by(runner_id: runner)
= link_to 'Disable for this project', [:ci, @project, runner_project], data: { confirm: "Are you sure?" }, method: :delete, class: 'btn btn-danger btn-sm' = link_to 'Disable for this project', [:ci, @ci_project, runner_project], data: { confirm: "Are you sure?" }, method: :delete, class: 'btn btn-danger btn-sm'
- elsif runner.specific? - elsif runner.specific?
= form_for [:ci, @project, @project.runner_projects.new] do |f| = form_for [:ci, @ci_project, @ci_project.runner_projects.new] do |f|
= f.hidden_field :runner_id, value: runner.id = f.hidden_field :runner_id, value: runner.id
= f.submit 'Enable for this project', class: 'btn btn-sm' = f.submit 'Enable for this project', class: 'btn btn-sm'
.pull-right .pull-right
...@@ -32,4 +32,3 @@ ...@@ -32,4 +32,3 @@
- runner.tag_list.each do |tag| - runner.tag_list.each do |tag|
%span.label.label-primary %span.label.label-primary
= tag = tag
...@@ -3,11 +3,11 @@ ...@@ -3,11 +3,11 @@
.bs-callout.bs-callout-warning .bs-callout.bs-callout-warning
GitLab Runners do not offer secure isolation between projects that they do builds for. You are TRUSTING all GitLab users who can push code to project A, B or C to run shell scripts on the machine hosting runner X. GitLab Runners do not offer secure isolation between projects that they do builds for. You are TRUSTING all GitLab users who can push code to project A, B or C to run shell scripts on the machine hosting runner X.
%hr %hr
- if @project.shared_runners_enabled - if @ci_project.shared_runners_enabled
= link_to toggle_shared_runners_ci_project_path(@project), class: 'btn btn-warning', method: :post do = link_to toggle_shared_runners_ci_project_path(@ci_project), class: 'btn btn-warning', method: :post do
Disable shared runners Disable shared runners
- else - else
= link_to toggle_shared_runners_ci_project_path(@project), class: 'btn btn-success', method: :post do = link_to toggle_shared_runners_ci_project_path(@ci_project), class: 'btn btn-success', method: :post do
Enable shared runners Enable shared runners
&nbsp; for this project &nbsp; for this project
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
- else - else
%h4.underlined-title Available shared runners - #{@shared_runners_count} %h4.underlined-title Available shared runners - #{@shared_runners_count}
%ul.bordered-list.available-shared-runners %ul.bordered-list.available-shared-runners
= render @shared_runners.first(10) = render partial: 'runner', collection: @shared_runners, as: :runner
- if @shared_runners_count > 10 - if @shared_runners_count > 10
.light .light
and #{@shared_runners_count - 10} more... and #{@shared_runners_count - 10} more...
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
%code #{ci_root_url(only_path: false)} %code #{ci_root_url(only_path: false)}
%li %li
Use the following registration token during setup: Use the following registration token during setup:
%code #{@project.token} %code #{@ci_project.token}
%li %li
Start runner! Start runner!
...@@ -20,10 +20,10 @@ ...@@ -20,10 +20,10 @@
- if @runners.any? - if @runners.any?
%h4.underlined-title Runners activated for this project %h4.underlined-title Runners activated for this project
%ul.bordered-list.activated-specific-runners %ul.bordered-list.activated-specific-runners
= render @runners = render partial: 'runner', collection: @runners, as: :runner
- if @specific_runners.any? - if @specific_runners.any?
%h4.underlined-title Available specific runners %h4.underlined-title Available specific runners
%ul.bordered-list.available-specific-runners %ul.bordered-list.available-specific-runners
= render @specific_runners = render partial: 'runner', collection: @specific_runners, as: :runner
= paginate @specific_runners = paginate @specific_runners
%h4 Runner ##{@runner.id} %h4 Runner ##{@runner.id}
%hr %hr
= form_for [:ci, @project, @runner], html: { class: 'form-horizontal' } do |f| = form_for @runner, url: runner_path(@runner), html: { class: 'form-horizontal' } do |f|
.form-group .form-group
= label :active, "Active", class: 'control-label' = label :active, "Active", class: 'control-label'
.col-sm-10 .col-sm-10
......
...@@ -55,13 +55,6 @@ Gitlab::Application.routes.draw do ...@@ -55,13 +55,6 @@ Gitlab::Application.routes.draw do
resources :triggers, only: [:index, :create, :destroy] resources :triggers, only: [:index, :create, :destroy]
resources :runners, only: [:index, :edit, :update, :destroy, :show] do
member do
get :resume
get :pause
end
end
resources :runner_projects, only: [:create, :destroy] resources :runner_projects, only: [:create, :destroy]
resources :events, only: [:index] resources :events, only: [:index]
...@@ -653,8 +646,14 @@ Gitlab::Application.routes.draw do ...@@ -653,8 +646,14 @@ Gitlab::Application.routes.draw do
get ":secret/:filename", action: :show, as: :show, constraints: { filename: /[^\/]+/ } get ":secret/:filename", action: :show, as: :show, constraints: { filename: /[^\/]+/ }
end end
end end
end
resources :runners, only: [:index, :edit, :update, :destroy, :show] do
member do
get :resume
get :pause
end
end
end
end end
end end
......
require 'spec_helper' require 'spec_helper'
describe "Runners" do describe "Runners" do
let(:user) { create(:user) } include GitlabRoutingHelper
before do let(:user) { create(:user) }
login_as(user) before { login_as(user) }
end
describe "specific runners" do describe "specific runners" do
before do before do
...@@ -20,18 +19,17 @@ describe "Runners" do ...@@ -20,18 +19,17 @@ describe "Runners" do
@specific_runner2 = FactoryGirl.create :ci_specific_runner @specific_runner2 = FactoryGirl.create :ci_specific_runner
@project.runners << @specific_runner @project.runners << @specific_runner
@project2.runners << @specific_runner2 @project2.runners << @specific_runner2
visit runners_path(@project.gl_project)
end end
it "places runners in right places" do it "places runners in right places" do
visit ci_project_runners_path(@project)
expect(page.find(".available-specific-runners")).to have_content(@specific_runner2.display_name) expect(page.find(".available-specific-runners")).to have_content(@specific_runner2.display_name)
expect(page.find(".activated-specific-runners")).to have_content(@specific_runner.display_name) expect(page.find(".activated-specific-runners")).to have_content(@specific_runner.display_name)
expect(page.find(".available-shared-runners")).to have_content(@shared_runner.display_name) expect(page.find(".available-shared-runners")).to have_content(@shared_runner.display_name)
end end
it "enables specific runner for project" do it "enables specific runner for project" do
visit ci_project_runners_path(@project)
within ".available-specific-runners" do within ".available-specific-runners" do
click_on "Enable for this project" click_on "Enable for this project"
end end
...@@ -41,8 +39,7 @@ describe "Runners" do ...@@ -41,8 +39,7 @@ describe "Runners" do
it "disables specific runner for project" do it "disables specific runner for project" do
@project2.runners << @specific_runner @project2.runners << @specific_runner
visit runners_path(@project.gl_project)
visit ci_project_runners_path(@project)
within ".activated-specific-runners" do within ".activated-specific-runners" do
click_on "Disable for this project" click_on "Disable for this project"
...@@ -52,8 +49,6 @@ describe "Runners" do ...@@ -52,8 +49,6 @@ describe "Runners" do
end end
it "removes specific runner for project if this is last project for that runners" do it "removes specific runner for project if this is last project for that runners" do
visit ci_project_runners_path(@project)
within ".activated-specific-runners" do within ".activated-specific-runners" do
click_on "Remove runner" click_on "Remove runner"
end end
...@@ -66,13 +61,11 @@ describe "Runners" do ...@@ -66,13 +61,11 @@ describe "Runners" do
before do before do
@project = FactoryGirl.create :ci_project @project = FactoryGirl.create :ci_project
@project.gl_project.team << [user, :master] @project.gl_project.team << [user, :master]
visit runners_path(@project.gl_project)
end end
it "enables shared runners" do it "enables shared runners" do
visit ci_project_runners_path(@project)
click_on "Enable shared runners" click_on "Enable shared runners"
expect(@project.reload.shared_runners_enabled).to be_truthy expect(@project.reload.shared_runners_enabled).to be_truthy
end end
end end
...@@ -83,13 +76,11 @@ describe "Runners" do ...@@ -83,13 +76,11 @@ describe "Runners" do
@project.gl_project.team << [user, :master] @project.gl_project.team << [user, :master]
@specific_runner = FactoryGirl.create :ci_specific_runner @specific_runner = FactoryGirl.create :ci_specific_runner
@project.runners << @specific_runner @project.runners << @specific_runner
visit runners_path(@project.gl_project)
end end
it "shows runner information" do it "shows runner information" do
visit ci_project_runners_path(@project)
click_on @specific_runner.short_sha click_on @specific_runner.short_sha
expect(page).to have_content(@specific_runner.platform) expect(page).to have_content(@specific_runner.platform)
end 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