Commit 9f055126 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'shared_runners' into 'master'

Enable shared runners for all new projects

This adds Admin Setting option to enable shared runners for all new projects, and by default it is set to true.

/cc @dzaporozhets @sytses 


See merge request !1738
parents bf76df22 4fda9ef8
...@@ -14,6 +14,7 @@ v 8.2.0 (unreleased) ...@@ -14,6 +14,7 @@ v 8.2.0 (unreleased)
- Use git follow flag for commits page when retrieve history for file or directory - Use git follow flag for commits page when retrieve history for file or directory
- Show merge request CI status on merge requests index page - Show merge request CI status on merge requests index page
- Extend yml syntax for only and except to support specifying repository path - Extend yml syntax for only and except to support specifying repository path
- Enable shared runners to all new projects
- Fix: 500 error returned if destroy request without HTTP referer (Kazuki Shimizu) - Fix: 500 error returned if destroy request without HTTP referer (Kazuki Shimizu)
- Remove deprecated CI events from project settings page - Remove deprecated CI events from project settings page
- Use issue editor as cross reference comment author when issue is edited with a new mention. - Use issue editor as cross reference comment author when issue is edited with a new mention.
......
...@@ -57,6 +57,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController ...@@ -57,6 +57,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
:version_check_enabled, :version_check_enabled,
:admin_notification_email, :admin_notification_email,
:user_oauth_applications, :user_oauth_applications,
:shared_runners_enabled,
restricted_visibility_levels: [], restricted_visibility_levels: [],
import_sources: [] import_sources: []
) )
......
...@@ -87,7 +87,8 @@ class ApplicationSetting < ActiveRecord::Base ...@@ -87,7 +87,8 @@ class ApplicationSetting < ActiveRecord::Base
default_project_visibility: Settings.gitlab.default_projects_features['visibility_level'], default_project_visibility: Settings.gitlab.default_projects_features['visibility_level'],
default_snippet_visibility: Settings.gitlab.default_projects_features['visibility_level'], default_snippet_visibility: Settings.gitlab.default_projects_features['visibility_level'],
restricted_signup_domains: Settings.gitlab['restricted_signup_domains'], restricted_signup_domains: Settings.gitlab['restricted_signup_domains'],
import_sources: ['github','bitbucket','gitlab','gitorious','google_code','fogbugz','git'] import_sources: ['github','bitbucket','gitlab','gitorious','google_code','fogbugz','git'],
shared_runners_enabled: Settings.gitlab_ci['shared_runners_enabled'],
) )
end end
......
...@@ -37,6 +37,7 @@ class Project < ActiveRecord::Base ...@@ -37,6 +37,7 @@ class Project < ActiveRecord::Base
include Gitlab::ConfigHelper include Gitlab::ConfigHelper
include Gitlab::ShellAdapter include Gitlab::ShellAdapter
include Gitlab::VisibilityLevel include Gitlab::VisibilityLevel
include Gitlab::CurrentSettings
include Referable include Referable
include Sortable include Sortable
include AfterCommitQueue include AfterCommitQueue
...@@ -775,7 +776,9 @@ class Project < ActiveRecord::Base ...@@ -775,7 +776,9 @@ class Project < ActiveRecord::Base
end end
def ensure_gitlab_ci_project def ensure_gitlab_ci_project
gitlab_ci_project || create_gitlab_ci_project gitlab_ci_project || create_gitlab_ci_project(
shared_runners_enabled: current_application_settings.shared_runners_enabled
)
end end
def enable_ci def enable_ci
......
...@@ -130,5 +130,14 @@ ...@@ -130,5 +130,14 @@
= f.text_area :help_page_text, class: 'form-control', rows: 4 = f.text_area :help_page_text, class: 'form-control', rows: 4
.help-block Markdown enabled .help-block Markdown enabled
%fieldset
%legend Continuous Integration
.form-group
.col-sm-offset-2.col-sm-10
.checkbox
= f.label :shared_runners_enabled do
= f.check_box :shared_runners_enabled
Enable shared runners for a new projects
.form-actions .form-actions
= f.submit 'Save', class: 'btn btn-primary' = f.submit 'Save', class: 'btn btn-primary'
...@@ -181,6 +181,7 @@ Settings.gitlab['import_sources'] ||= ['github','bitbucket','gitlab','gitorious' ...@@ -181,6 +181,7 @@ Settings.gitlab['import_sources'] ||= ['github','bitbucket','gitlab','gitorious'
# CI # CI
# #
Settings['gitlab_ci'] ||= Settingslogic.new({}) Settings['gitlab_ci'] ||= Settingslogic.new({})
Settings.gitlab_ci['shared_runners_enabled'] = true if Settings.gitlab_ci['shared_runners_enabled'].nil?
Settings.gitlab_ci['all_broken_builds'] = true if Settings.gitlab_ci['all_broken_builds'].nil? Settings.gitlab_ci['all_broken_builds'] = true if Settings.gitlab_ci['all_broken_builds'].nil?
Settings.gitlab_ci['add_pusher'] = false if Settings.gitlab_ci['add_pusher'].nil? Settings.gitlab_ci['add_pusher'] = false if Settings.gitlab_ci['add_pusher'].nil?
Settings.gitlab_ci['url'] ||= Settings.send(:build_gitlab_ci_url) Settings.gitlab_ci['url'] ||= Settings.send(:build_gitlab_ci_url)
......
class AddSharedRunnersSetting < ActiveRecord::Migration
def up
add_column :application_settings, :shared_runners_enabled, :boolean, default: true, null: false
end
end
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20151103001141) do ActiveRecord::Schema.define(version: 20151103133339) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
...@@ -47,6 +47,7 @@ ActiveRecord::Schema.define(version: 20151103001141) do ...@@ -47,6 +47,7 @@ ActiveRecord::Schema.define(version: 20151103001141) do
t.text "import_sources" t.text "import_sources"
t.text "help_page_text" t.text "help_page_text"
t.string "admin_notification_email" t.string "admin_notification_email"
t.boolean "shared_runners_enabled", default: true, null: false
end end
create_table "audit_events", force: true do |t| create_table "audit_events", force: true do |t|
......
...@@ -23,7 +23,8 @@ module Gitlab ...@@ -23,7 +23,8 @@ module Gitlab
restricted_visibility_levels: Settings.gitlab['restricted_visibility_levels'], restricted_visibility_levels: Settings.gitlab['restricted_visibility_levels'],
max_attachment_size: Settings.gitlab['max_attachment_size'], max_attachment_size: Settings.gitlab['max_attachment_size'],
session_expire_delay: Settings.gitlab['session_expire_delay'], session_expire_delay: Settings.gitlab['session_expire_delay'],
import_sources: Settings.gitlab['import_sources'] import_sources: Settings.gitlab['import_sources'],
shared_runners_enabled: Settings.gitlab_ci['shared_runners_enabled'],
) )
end end
......
...@@ -33,6 +33,8 @@ FactoryGirl.define do ...@@ -33,6 +33,8 @@ FactoryGirl.define do
gl_project factory: :empty_project gl_project factory: :empty_project
shared_runners_enabled false
factory :ci_project do factory :ci_project do
token 'iPWx6WM4lhHNedGfBpPJNP' token 'iPWx6WM4lhHNedGfBpPJNP'
end end
......
...@@ -28,11 +28,11 @@ ...@@ -28,11 +28,11 @@
require 'spec_helper' require 'spec_helper'
describe ApplicationSetting, models: true do describe ApplicationSetting, models: true do
it { expect(ApplicationSetting.create_from_defaults).to be_valid }
context 'restricted signup domains' do
let(:setting) { ApplicationSetting.create_from_defaults } let(:setting) { ApplicationSetting.create_from_defaults }
it { expect(setting).to be_valid }
context 'restricted signup domains' do
it 'set single domain' do it 'set single domain' do
setting.restricted_signup_domains_raw = 'example.com' setting.restricted_signup_domains_raw = 'example.com'
expect(setting.restricted_signup_domains).to eq(['example.com']) expect(setting.restricted_signup_domains).to eq(['example.com'])
...@@ -53,4 +53,26 @@ describe ApplicationSetting, models: true do ...@@ -53,4 +53,26 @@ describe ApplicationSetting, models: true do
expect(setting.restricted_signup_domains).to eq(['example.com', '*.example.com']) expect(setting.restricted_signup_domains).to eq(['example.com', '*.example.com'])
end end
end end
context 'shared runners' do
let(:gl_project) { create(:empty_project) }
before do
allow_any_instance_of(Project).to receive(:current_application_settings).and_return(setting)
end
subject { gl_project.ensure_gitlab_ci_project.shared_runners_enabled }
context 'enabled' do
before { setting.update_attributes(shared_runners_enabled: true) }
it { is_expected.to be_truthy }
end
context 'disabled' do
before { setting.update_attributes(shared_runners_enabled: false) }
it { is_expected.to be_falsey }
end
end
end end
...@@ -70,6 +70,10 @@ module Ci ...@@ -70,6 +70,10 @@ module Ci
end end
context 'disallow shared runners' do context 'disallow shared runners' do
before do
gl_project.gitlab_ci_project.update(shared_runners_enabled: false)
end
context 'shared runner' do context 'shared runner' do
let(:build) { service.execute(shared_runner) } let(:build) { service.execute(shared_runner) }
......
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