Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
d236a6c2
Commit
d236a6c2
authored
Sep 18, 2018
by
Dylan Griffith
Committed by
Kamil Trzciński
Sep 18, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Enable Auto DevOps by default for self managed instances of GitLab"
parent
354f0bcc
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
173 additions
and
103 deletions
+173
-103
changelogs/unreleased/41729-enable-auto-devops-instance-wide-for-everyone.yml
...d/41729-enable-auto-devops-instance-wide-for-everyone.yml
+5
-0
db/migrate/20180813101999_change_default_of_auto_devops_instance_wide.rb
...0813101999_change_default_of_auto_devops_instance_wide.rb
+15
-0
db/migrate/20180813102000_enable_auto_devops_instance_wide_for_everyone.rb
...13102000_enable_auto_devops_instance_wide_for_everyone.rb
+15
-0
db/schema.rb
db/schema.rb
+1
-1
spec/features/projects/pipelines/pipelines_spec.rb
spec/features/projects/pipelines/pipelines_spec.rb
+2
-0
spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb
...es/projects/show/user_sees_setup_shortcut_buttons_spec.rb
+99
-85
spec/helpers/auto_devops_helper_spec.rb
spec/helpers/auto_devops_helper_spec.rb
+9
-1
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+5
-2
spec/models/project_spec.rb
spec/models/project_spec.rb
+6
-6
spec/requests/api/pipelines_spec.rb
spec/requests/api/pipelines_spec.rb
+11
-5
spec/services/git_push_service_spec.rb
spec/services/git_push_service_spec.rb
+5
-3
No files found.
changelogs/unreleased/41729-enable-auto-devops-instance-wide-for-everyone.yml
0 → 100644
View file @
d236a6c2
---
title
:
Enable Auto DevOps Instance Wide Default
merge_request
:
21157
author
:
type
:
changed
db/migrate/20180813101999_change_default_of_auto_devops_instance_wide.rb
0 → 100644
View file @
d236a6c2
# 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
db/migrate/20180813102000_enable_auto_devops_instance_wide_for_everyone.rb
0 → 100644
View file @
d236a6c2
# 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
db/schema.rb
View file @
d236a6c2
...
...
@@ -141,7 +141,7 @@ ActiveRecord::Schema.define(version: 20180907015926) do
t
.
integer
"performance_bar_allowed_group_id"
t
.
boolean
"hashed_storage_enabled"
,
default:
false
,
null:
false
t
.
boolean
"project_export_enabled"
,
default:
true
,
null:
false
t
.
boolean
"auto_devops_enabled"
,
default:
fals
e
,
null:
false
t
.
boolean
"auto_devops_enabled"
,
default:
tru
e
,
null:
false
t
.
integer
"circuitbreaker_failure_count_threshold"
,
default:
3
t
.
integer
"circuitbreaker_failure_reset_time"
,
default:
1800
t
.
integer
"circuitbreaker_storage_timeout"
,
default:
15
...
...
spec/features/projects/pipelines/pipelines_spec.rb
View file @
d236a6c2
...
...
@@ -9,6 +9,7 @@ describe 'Pipelines', :js do
before
do
sign_in
(
user
)
project
.
add_developer
(
user
)
project
.
update!
(
auto_devops_attributes:
{
enabled:
false
})
end
describe
'GET /:project/pipelines'
do
...
...
@@ -641,6 +642,7 @@ describe 'Pipelines', :js do
context
'when user is not logged in'
do
before
do
project
.
update!
(
auto_devops_attributes:
{
enabled:
false
})
visit
project_pipelines_path
(
project
)
end
...
...
spec/features/projects/show/user_sees_setup_shortcut_buttons_spec.rb
View file @
d236a6c2
...
...
@@ -28,8 +28,6 @@ describe 'Projects > Show > User sees setup shortcut buttons' do
end
it
'"Auto DevOps enabled" button not linked'
do
project
.
create_auto_devops!
(
enabled:
true
)
visit
project_path
(
project
)
page
.
within
(
'.project-stats'
)
do
...
...
@@ -65,19 +63,23 @@ describe 'Projects > Show > User sees setup shortcut buttons' do
end
describe
'Auto DevOps button'
do
it
'"Enable Auto DevOps" button linked to settings page'
do
page
.
within
(
'.project-stats'
)
do
expect
(
page
).
to
have_link
(
'Enable Auto DevOps'
,
href:
project_settings_ci_cd_path
(
project
,
anchor:
'autodevops-settings'
))
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
expect
(
page
).
to
have_link
(
'Auto DevOps enabled'
,
href:
project_settings_ci_cd_path
(
project
,
anchor:
'autodevops-settings'
))
end
end
end
it
'"Auto DevOps enabled" anchor linked to settings page'
do
project
.
create_auto_devops!
(
enabled:
true
)
visit
project_path
(
project
)
context
'when Auto DevOps is not enabled'
do
let
(
:project
)
{
create
(
:project
,
:public
,
:empty_repo
,
auto_devops_attributes:
{
enabled:
false
})
}
page
.
within
(
'.project-stats'
)
do
expect
(
page
).
to
have_link
(
'Auto DevOps enabled'
,
href:
project_settings_ci_cd_path
(
project
,
anchor:
'autodevops-settings'
))
it
'"Enable Auto DevOps" button linked to settings page'
do
page
.
within
(
'.project-stats'
)
do
expect
(
page
).
to
have_link
(
'Enable Auto DevOps'
,
href:
project_settings_ci_cd_path
(
project
,
anchor:
'autodevops-settings'
))
end
end
end
end
...
...
@@ -113,27 +115,31 @@ describe 'Projects > Show > User sees setup shortcut buttons' do
visit
project_path
(
project
)
end
it
'no Auto DevOps button if can not manage pipelines'
do
page
.
within
(
'.project-stats'
)
do
expect
(
page
).
not_to
have_link
(
'Enable Auto DevOps'
)
expect
(
page
).
not_to
have_link
(
'Auto DevOps enabled'
)
context
'when Auto DevOps is enabled'
do
it
'"Auto DevOps enabled" button not linked'
do
visit
project_path
(
project
)
page
.
within
(
'.project-stats'
)
do
expect
(
page
).
to
have_text
(
'Auto DevOps enabled'
)
end
end
end
it
'"Auto DevOps enabled" button not linked'
do
project
.
create_auto_devops!
(
enabled:
true
)
visit
project_path
(
project
)
context
'when Auto DevOps is not enabled'
do
let
(
:project
)
{
create
(
:project
,
:public
,
:repository
,
auto_devops_attributes:
{
enabled:
false
})
}
page
.
within
(
'.project-stats'
)
do
expect
(
page
).
to
have_text
(
'Auto DevOps enabled'
)
it
'no Auto DevOps button if can not manage pipelines'
do
page
.
within
(
'.project-stats'
)
do
expect
(
page
).
not_to
have_link
(
'Enable Auto DevOps'
)
expect
(
page
).
not_to
have_link
(
'Auto DevOps enabled'
)
end
end
end
it
'no Kubernetes cluster button if can not manage clusters'
do
page
.
within
(
'.project-stats'
)
do
expect
(
page
).
not_to
have_link
(
'Add Kubernetes cluster'
)
expect
(
page
).
not_to
have_link
(
'Kubernetes configured'
)
it
'no Kubernetes cluster button if can not manage clusters'
do
page
.
within
(
'.project-stats'
)
do
expect
(
page
).
not_to
have_link
(
'Add Kubernetes cluster'
)
expect
(
page
).
not_to
have_link
(
'Kubernetes configured'
)
end
end
end
end
...
...
@@ -222,97 +228,105 @@ describe 'Projects > Show > User sees setup shortcut buttons' do
end
describe
'GitLab CI configuration button'
do
it
'"Set up CI/CD" button linked to new file populated for a .gitlab-ci.yml'
do
visit
project_path
(
project
)
expect
(
project
.
repository
.
gitlab_ci_yml
).
to
be_nil
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
).
to
have_link
(
'Set up CI/CD'
,
href:
presenter
.
add_ci_yml_path
)
page
.
within
(
'.project-stats'
)
do
expect
(
page
).
not_to
have_link
(
'Set up CI/CD'
)
end
end
end
it
'no "Set up CI/CD" button if the project already has a .gitlab-ci.yml'
do
Files
::
CreateService
.
new
(
project
,
project
.
creator
,
start_branch:
'master'
,
branch_name:
'master'
,
commit_message:
"Add .gitlab-ci.yml"
,
file_path:
'.gitlab-ci.yml'
,
file_content:
File
.
read
(
Rails
.
root
.
join
(
'spec/support/gitlab_stubs/gitlab_ci.yml'
))
).
execute
context
'when Auto DevOps is not enabled'
do
let
(
:project
)
{
create
(
:project
,
:public
,
:repository
,
auto_devops_attributes:
{
enabled:
false
})
}
expect
(
project
.
repository
.
gitlab_ci_yml
).
not_to
be_nil
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
)
expect
(
project
.
repository
.
gitlab_ci_yml
).
to
be_nil
page
.
within
(
'.project-stats'
)
do
expect
(
page
).
not_to
have_link
(
'Set up CI/CD'
)
page
.
within
(
'.project-stats'
)
do
expect
(
page
).
to
have_link
(
'Set up CI/CD'
,
href:
presenter
.
add_ci_yml_path
)
end
end
end
it
'no "Set up CI/CD" button if the project has Auto DevOps enabled'
do
project
.
create_auto_devops!
(
enabled:
true
)
it
'no "Set up CI/CD" button if the project already has a .gitlab-ci.yml'
do
Files
::
CreateService
.
new
(
project
,
project
.
creator
,
start_branch:
'master'
,
branch_name:
'master'
,
commit_message:
"Add .gitlab-ci.yml"
,
file_path:
'.gitlab-ci.yml'
,
file_content:
File
.
read
(
Rails
.
root
.
join
(
'spec/support/gitlab_stubs/gitlab_ci.yml'
))
).
execute
visit
project_path
(
project
)
expect
(
project
.
repository
.
gitlab_ci_yml
).
not_to
be_nil
page
.
within
(
'.project-stats'
)
do
expect
(
page
).
not_to
have_link
(
'Set up CI/CD'
)
visit
project_path
(
project
)
page
.
within
(
'.project-stats'
)
do
expect
(
page
).
not_to
have_link
(
'Set up CI/CD'
)
end
end
end
end
describe
'Auto DevOps button'
do
it
'"Enable Auto DevOps" button linked to settings page'
do
visit
project_path
(
project
)
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
expect
(
page
).
to
have_link
(
'Enable Auto DevOps'
,
href:
project_settings_ci_cd_path
(
project
,
anchor:
'autodevops-settings'
))
page
.
within
(
'.project-stats'
)
do
expect
(
page
).
to
have_link
(
'Auto DevOps enabled'
,
href:
project_settings_ci_cd_path
(
project
,
anchor:
'autodevops-settings'
))
end
end
end
it
'"Enable Auto DevOps" button linked to settings page
'
do
project
.
create_auto_devops!
(
enabled:
true
)
context
'when Auto DevOps is not enabled
'
do
let
(
:project
)
{
create
(
:project
,
:public
,
:repository
,
auto_devops_attributes:
{
enabled:
false
})
}
visit
project_path
(
project
)
it
'"Enable Auto DevOps" button linked to settings page'
do
visit
project_path
(
project
)
page
.
within
(
'.project-stats'
)
do
expect
(
page
).
to
have_link
(
'Auto DevOps enabled'
,
href:
project_settings_ci_cd_path
(
project
,
anchor:
'autodevops-settings'
))
page
.
within
(
'.project-stats'
)
do
expect
(
page
).
to
have_link
(
'Enable Auto DevOps'
,
href:
project_settings_ci_cd_path
(
project
,
anchor:
'autodevops-settings'
))
end
end
end
it
'no Auto DevOps button if Auto DevOps callout is shown'
do
allow_any_instance_of
(
AutoDevopsHelper
).
to
receive
(
:show_auto_devops_callout?
).
and_return
(
true
)
it
'no Auto DevOps button if Auto DevOps callout is shown'
do
allow_any_instance_of
(
AutoDevopsHelper
).
to
receive
(
:show_auto_devops_callout?
).
and_return
(
true
)
visit
project_path
(
project
)
visit
project_path
(
project
)
expect
(
page
).
to
have_selector
(
'.js-autodevops-banner'
)
expect
(
page
).
to
have_selector
(
'.js-autodevops-banner'
)
page
.
within
(
'.project-stats'
)
do
expect
(
page
).
not_to
have_link
(
'Enable Auto DevOps'
)
expect
(
page
).
not_to
have_link
(
'Auto DevOps enabled'
)
page
.
within
(
'.project-stats'
)
do
expect
(
page
).
not_to
have_link
(
'Enable Auto DevOps'
)
expect
(
page
).
not_to
have_link
(
'Auto DevOps enabled'
)
end
end
end
it
'no "Enable Auto DevOps" button when .gitlab-ci.yml already exists'
do
Files
::
CreateService
.
new
(
project
,
project
.
creator
,
start_branch:
'master'
,
branch_name:
'master'
,
commit_message:
"Add .gitlab-ci.yml"
,
file_path:
'.gitlab-ci.yml'
,
file_content:
File
.
read
(
Rails
.
root
.
join
(
'spec/support/gitlab_stubs/gitlab_ci.yml'
))
).
execute
it
'no "Enable Auto DevOps" button when .gitlab-ci.yml already exists'
do
Files
::
CreateService
.
new
(
project
,
project
.
creator
,
start_branch:
'master'
,
branch_name:
'master'
,
commit_message:
"Add .gitlab-ci.yml"
,
file_path:
'.gitlab-ci.yml'
,
file_content:
File
.
read
(
Rails
.
root
.
join
(
'spec/support/gitlab_stubs/gitlab_ci.yml'
))
).
execute
expect
(
project
.
repository
.
gitlab_ci_yml
).
not_to
be_nil
expect
(
project
.
repository
.
gitlab_ci_yml
).
not_to
be_nil
visit
project_path
(
project
)
visit
project_path
(
project
)
page
.
within
(
'.project-stats'
)
do
expect
(
page
).
not_to
have_link
(
'Enable Auto DevOps'
)
expect
(
page
).
not_to
have_link
(
'Auto DevOps enabled'
)
page
.
within
(
'.project-stats'
)
do
expect
(
page
).
not_to
have_link
(
'Enable Auto DevOps'
)
expect
(
page
).
not_to
have_link
(
'Auto DevOps enabled'
)
end
end
end
end
...
...
spec/helpers/auto_devops_helper_spec.rb
View file @
d236a6c2
...
...
@@ -16,7 +16,15 @@ describe AutoDevopsHelper do
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
)
}
end
...
...
spec/models/ci/pipeline_spec.rb
View file @
d236a6c2
...
...
@@ -1151,7 +1151,11 @@ describe Ci::Pipeline, :mailer do
end
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
pipeline
.
set_config_source
...
...
@@ -1196,7 +1200,6 @@ describe Ci::Pipeline, :mailer do
context
'auto devops enabled'
do
before
do
stub_application_setting
(
auto_devops_enabled:
true
)
allow
(
project
).
to
receive
(
:ci_config_path
)
{
'custom'
}
end
...
...
spec/models/project_spec.rb
View file @
d236a6c2
...
...
@@ -3229,17 +3229,17 @@ describe Project do
expect
(
repository
).
to
receive
(
:gitlab_ci_yml
)
{
nil
}
end
it
"CI is
not
available"
do
expect
(
project
).
not_
to
have_ci
it
"CI is available"
do
expect
(
project
).
to
have_ci
end
context
'when auto devops is
en
abled'
do
context
'when auto devops is
dis
abled'
do
before
do
stub_application_setting
(
auto_devops_enabled:
tru
e
)
stub_application_setting
(
auto_devops_enabled:
fals
e
)
end
it
"CI is available"
do
expect
(
project
).
to
have_ci
it
"CI is
not
available"
do
expect
(
project
).
not_
to
have_ci
end
end
end
...
...
spec/requests/api/pipelines_spec.rb
View file @
d236a6c2
...
...
@@ -370,12 +370,18 @@ describe API::Pipelines do
end
context
'without gitlab-ci.yml'
do
it
'fails to create pipeline'
do
post
api
(
"/projects/
#{
project
.
id
}
/pipeline"
,
user
),
ref:
project
.
default_branch
context
'without auto devops enabled'
do
before
do
project
.
update!
(
auto_devops_attributes:
{
enabled:
false
})
end
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
json_response
[
'message'
][
'base'
].
first
).
to
eq
'Missing .gitlab-ci.yml file'
expect
(
json_response
).
not_to
be_an
Array
it
'fails to create pipeline'
do
post
api
(
"/projects/
#{
project
.
id
}
/pipeline"
,
user
),
ref:
project
.
default_branch
expect
(
response
).
to
have_gitlab_http_status
(
400
)
expect
(
json_response
[
'message'
][
'base'
].
first
).
to
eq
'Missing .gitlab-ci.yml file'
expect
(
json_response
).
not_to
be_an
Array
end
end
end
end
...
...
spec/services/git_push_service_spec.rb
View file @
d236a6c2
...
...
@@ -246,13 +246,15 @@ describe GitPushService, services: true do
describe
'system hooks'
do
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
expect
(
SystemHooksService
).
to
receive
(
:new
).
and_return
(
system_hooks_service
)
expect
(
system_hooks_service
).
to
receive
(
:execute_hooks
).
with
(
push_data
,
:push
_hooks
)
allow
(
SystemHooksService
).
to
receive
(
:new
).
and_return
(
system_hooks_service
)
allow
(
system_hooks_service
).
to
receive
(
:execute
_hooks
)
execute_service
(
project
,
user
,
oldrev
,
newrev
,
ref
)
expect
(
system_hooks_service
).
to
have_received
(
:execute_hooks
).
with
(
push_data
,
:push_hooks
)
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment