Commit 7e6ed7c7 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch '41729-enable-auto-devops-instance-wide-for-everyone' into 'master'

Resolve "Enable Auto DevOps by default for self managed instances of GitLab"

Closes #41729

See merge request gitlab-org/gitlab-ce!21157
parents 354f0bcc d236a6c2
---
title: Enable Auto DevOps Instance Wide Default
merge_request: 21157
author:
type: changed
# frozen_string_literal: true
class ChangeDefaultOfAutoDevopsInstanceWide < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
change_column_default :application_settings, :auto_devops_enabled, true
end
def down
change_column_default :application_settings, :auto_devops_enabled, false
end
end
# frozen_string_literal: true
class EnableAutoDevopsInstanceWideForEveryone < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
def up
execute "UPDATE application_settings SET auto_devops_enabled = true"
end
def down
# No way to know here what their previous setting was...
end
end
...@@ -141,7 +141,7 @@ ActiveRecord::Schema.define(version: 20180907015926) do ...@@ -141,7 +141,7 @@ ActiveRecord::Schema.define(version: 20180907015926) do
t.integer "performance_bar_allowed_group_id" t.integer "performance_bar_allowed_group_id"
t.boolean "hashed_storage_enabled", default: false, null: false t.boolean "hashed_storage_enabled", default: false, null: false
t.boolean "project_export_enabled", default: true, null: false t.boolean "project_export_enabled", default: true, null: false
t.boolean "auto_devops_enabled", default: false, null: false t.boolean "auto_devops_enabled", default: true, null: false
t.integer "circuitbreaker_failure_count_threshold", default: 3 t.integer "circuitbreaker_failure_count_threshold", default: 3
t.integer "circuitbreaker_failure_reset_time", default: 1800 t.integer "circuitbreaker_failure_reset_time", default: 1800
t.integer "circuitbreaker_storage_timeout", default: 15 t.integer "circuitbreaker_storage_timeout", default: 15
......
...@@ -9,6 +9,7 @@ describe 'Pipelines', :js do ...@@ -9,6 +9,7 @@ describe 'Pipelines', :js do
before do before do
sign_in(user) sign_in(user)
project.add_developer(user) project.add_developer(user)
project.update!(auto_devops_attributes: { enabled: false })
end end
describe 'GET /:project/pipelines' do describe 'GET /:project/pipelines' do
...@@ -641,6 +642,7 @@ describe 'Pipelines', :js do ...@@ -641,6 +642,7 @@ describe 'Pipelines', :js do
context 'when user is not logged in' do context 'when user is not logged in' do
before do before do
project.update!(auto_devops_attributes: { enabled: false })
visit project_pipelines_path(project) visit project_pipelines_path(project)
end end
......
...@@ -28,8 +28,6 @@ describe 'Projects > Show > User sees setup shortcut buttons' do ...@@ -28,8 +28,6 @@ describe 'Projects > Show > User sees setup shortcut buttons' do
end end
it '"Auto DevOps enabled" button not linked' do it '"Auto DevOps enabled" button not linked' do
project.create_auto_devops!(enabled: true)
visit project_path(project) visit project_path(project)
page.within('.project-stats') do page.within('.project-stats') do
...@@ -65,19 +63,23 @@ describe 'Projects > Show > User sees setup shortcut buttons' do ...@@ -65,19 +63,23 @@ describe 'Projects > Show > User sees setup shortcut buttons' do
end end
describe 'Auto DevOps button' do describe 'Auto DevOps button' do
it '"Enable Auto DevOps" button linked to settings page' do context 'when Auto DevOps is enabled' do
it '"Auto DevOps enabled" anchor linked to settings page' do
visit project_path(project)
page.within('.project-stats') do page.within('.project-stats') do
expect(page).to have_link('Enable Auto DevOps', href: project_settings_ci_cd_path(project, anchor: 'autodevops-settings')) expect(page).to have_link('Auto DevOps enabled', href: project_settings_ci_cd_path(project, anchor: 'autodevops-settings'))
end
end end
end end
it '"Auto DevOps enabled" anchor linked to settings page' do context 'when Auto DevOps is not enabled' do
project.create_auto_devops!(enabled: true) let(:project) { create(:project, :public, :empty_repo, auto_devops_attributes: { enabled: false }) }
visit project_path(project)
it '"Enable Auto DevOps" button linked to settings page' do
page.within('.project-stats') do page.within('.project-stats') do
expect(page).to have_link('Auto DevOps enabled', href: project_settings_ci_cd_path(project, anchor: 'autodevops-settings')) expect(page).to have_link('Enable Auto DevOps', href: project_settings_ci_cd_path(project, anchor: 'autodevops-settings'))
end
end end
end end
end end
...@@ -113,20 +115,23 @@ describe 'Projects > Show > User sees setup shortcut buttons' do ...@@ -113,20 +115,23 @@ describe 'Projects > Show > User sees setup shortcut buttons' do
visit project_path(project) visit project_path(project)
end end
it 'no Auto DevOps button if can not manage pipelines' do context 'when Auto DevOps is enabled' do
it '"Auto DevOps enabled" button not linked' do
visit project_path(project)
page.within('.project-stats') do page.within('.project-stats') do
expect(page).not_to have_link('Enable Auto DevOps') expect(page).to have_text('Auto DevOps enabled')
expect(page).not_to have_link('Auto DevOps enabled') end
end end
end end
it '"Auto DevOps enabled" button not linked' do context 'when Auto DevOps is not enabled' do
project.create_auto_devops!(enabled: true) let(:project) { create(:project, :public, :repository, auto_devops_attributes: { enabled: false }) }
visit project_path(project)
it 'no Auto DevOps button if can not manage pipelines' do
page.within('.project-stats') do page.within('.project-stats') do
expect(page).to have_text('Auto DevOps enabled') expect(page).not_to have_link('Enable Auto DevOps')
expect(page).not_to have_link('Auto DevOps enabled')
end end
end end
...@@ -137,6 +142,7 @@ describe 'Projects > Show > User sees setup shortcut buttons' do ...@@ -137,6 +142,7 @@ describe 'Projects > Show > User sees setup shortcut buttons' do
end end
end end
end end
end
describe 'as a maintainer' do describe 'as a maintainer' do
before do before do
...@@ -222,6 +228,19 @@ describe 'Projects > Show > User sees setup shortcut buttons' do ...@@ -222,6 +228,19 @@ describe 'Projects > Show > User sees setup shortcut buttons' do
end end
describe 'GitLab CI configuration button' do describe 'GitLab CI configuration button' do
context 'when Auto DevOps is enabled' do
it 'no "Set up CI/CD" button if the project has Auto DevOps enabled' do
visit project_path(project)
page.within('.project-stats') do
expect(page).not_to have_link('Set up CI/CD')
end
end
end
context 'when Auto DevOps is not enabled' do
let(:project) { create(:project, :public, :repository, auto_devops_attributes: { enabled: false }) }
it '"Set up CI/CD" button linked to new file populated for a .gitlab-ci.yml' do it '"Set up CI/CD" button linked to new file populated for a .gitlab-ci.yml' do
visit project_path(project) visit project_path(project)
...@@ -251,34 +270,28 @@ describe 'Projects > Show > User sees setup shortcut buttons' do ...@@ -251,34 +270,28 @@ describe 'Projects > Show > User sees setup shortcut buttons' do
expect(page).not_to have_link('Set up CI/CD') expect(page).not_to have_link('Set up CI/CD')
end end
end end
it 'no "Set up CI/CD" button if the project has Auto DevOps enabled' do
project.create_auto_devops!(enabled: true)
visit project_path(project)
page.within('.project-stats') do
expect(page).not_to have_link('Set up CI/CD')
end
end end
end end
describe 'Auto DevOps button' do describe 'Auto DevOps button' do
it '"Enable Auto DevOps" button linked to settings page' do context 'when Auto DevOps is enabled' do
it '"Auto DevOps enabled" anchor linked to settings page' do
visit project_path(project) visit project_path(project)
page.within('.project-stats') do page.within('.project-stats') do
expect(page).to have_link('Enable Auto DevOps', href: project_settings_ci_cd_path(project, anchor: 'autodevops-settings')) expect(page).to have_link('Auto DevOps enabled', href: project_settings_ci_cd_path(project, anchor: 'autodevops-settings'))
end
end end
end end
it '"Enable Auto DevOps" button linked to settings page' do context 'when Auto DevOps is not enabled' do
project.create_auto_devops!(enabled: true) let(:project) { create(:project, :public, :repository, auto_devops_attributes: { enabled: false }) }
it '"Enable Auto DevOps" button linked to settings page' do
visit project_path(project) visit project_path(project)
page.within('.project-stats') do page.within('.project-stats') do
expect(page).to have_link('Auto DevOps enabled', href: project_settings_ci_cd_path(project, anchor: 'autodevops-settings')) expect(page).to have_link('Enable Auto DevOps', href: project_settings_ci_cd_path(project, anchor: 'autodevops-settings'))
end end
end end
...@@ -316,6 +329,7 @@ describe 'Projects > Show > User sees setup shortcut buttons' do ...@@ -316,6 +329,7 @@ describe 'Projects > Show > User sees setup shortcut buttons' do
end end
end end
end end
end
describe 'Kubernetes cluster button' do describe 'Kubernetes cluster button' do
it '"Add Kubernetes cluster" button linked to clusters page' do it '"Add Kubernetes cluster" button linked to clusters page' do
......
...@@ -16,7 +16,15 @@ describe AutoDevopsHelper do ...@@ -16,7 +16,15 @@ describe AutoDevopsHelper do
subject { helper.show_auto_devops_callout?(project) } subject { helper.show_auto_devops_callout?(project) }
context 'when all conditions are met' do context 'when auto devops is implicitly enabled' do
it { is_expected.to eq(false) }
end
context 'when auto devops is not implicitly enabled' do
before do
Gitlab::CurrentSettings.update!(auto_devops_enabled: false)
end
it { is_expected.to eq(true) } it { is_expected.to eq(true) }
end end
......
...@@ -1151,7 +1151,11 @@ describe Ci::Pipeline, :mailer do ...@@ -1151,7 +1151,11 @@ describe Ci::Pipeline, :mailer do
end end
describe '#set_config_source' do describe '#set_config_source' do
context 'when pipelines does not contain needed data' do context 'when pipelines does not contain needed data and auto devops is disabled' do
before do
stub_application_setting(auto_devops_enabled: false)
end
it 'defines source to be unknown' do it 'defines source to be unknown' do
pipeline.set_config_source pipeline.set_config_source
...@@ -1196,7 +1200,6 @@ describe Ci::Pipeline, :mailer do ...@@ -1196,7 +1200,6 @@ describe Ci::Pipeline, :mailer do
context 'auto devops enabled' do context 'auto devops enabled' do
before do before do
stub_application_setting(auto_devops_enabled: true)
allow(project).to receive(:ci_config_path) { 'custom' } allow(project).to receive(:ci_config_path) { 'custom' }
end end
......
...@@ -3229,17 +3229,17 @@ describe Project do ...@@ -3229,17 +3229,17 @@ describe Project do
expect(repository).to receive(:gitlab_ci_yml) { nil } expect(repository).to receive(:gitlab_ci_yml) { nil }
end end
it "CI is not available" do it "CI is available" do
expect(project).not_to have_ci expect(project).to have_ci
end end
context 'when auto devops is enabled' do context 'when auto devops is disabled' do
before do before do
stub_application_setting(auto_devops_enabled: true) stub_application_setting(auto_devops_enabled: false)
end end
it "CI is available" do it "CI is not available" do
expect(project).to have_ci expect(project).not_to have_ci
end end
end end
end end
......
...@@ -370,6 +370,11 @@ describe API::Pipelines do ...@@ -370,6 +370,11 @@ describe API::Pipelines do
end end
context 'without gitlab-ci.yml' do context 'without gitlab-ci.yml' do
context 'without auto devops enabled' do
before do
project.update!(auto_devops_attributes: { enabled: false })
end
it 'fails to create pipeline' do it 'fails to create pipeline' do
post api("/projects/#{project.id}/pipeline", user), ref: project.default_branch post api("/projects/#{project.id}/pipeline", user), ref: project.default_branch
...@@ -379,6 +384,7 @@ describe API::Pipelines do ...@@ -379,6 +384,7 @@ describe API::Pipelines do
end end
end end
end end
end
context 'unauthorized user' do context 'unauthorized user' do
it 'does not create pipeline' do it 'does not create pipeline' do
......
...@@ -246,13 +246,15 @@ describe GitPushService, services: true do ...@@ -246,13 +246,15 @@ describe GitPushService, services: true do
describe 'system hooks' do describe 'system hooks' do
let!(:push_data) { push_data_from_service(project, user, oldrev, newrev, ref) } let!(:push_data) { push_data_from_service(project, user, oldrev, newrev, ref) }
let(:system_hooks_service) { SystemHooksService.new } let!(:system_hooks_service) { SystemHooksService.new }
it "sends a system hook after pushing a branch" do it "sends a system hook after pushing a branch" do
expect(SystemHooksService).to receive(:new).and_return(system_hooks_service) allow(SystemHooksService).to receive(:new).and_return(system_hooks_service)
expect(system_hooks_service).to receive(:execute_hooks).with(push_data, :push_hooks) allow(system_hooks_service).to receive(:execute_hooks)
execute_service(project, user, oldrev, newrev, ref) execute_service(project, user, oldrev, newrev, ref)
expect(system_hooks_service).to have_received(:execute_hooks).with(push_data, :push_hooks)
end end
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