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
Léo-Paul Géneau
gitlab-ce
Commits
555cdade
Commit
555cdade
authored
Aug 16, 2018
by
Dylan Griffith
Committed by
Kamil Trzciński
Aug 16, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Resolve "Enable Auto DevOps instance-wide on GitLab.com"
parent
ce18246c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
54 additions
and
28 deletions
+54
-28
app/models/project.rb
app/models/project.rb
+5
-3
app/models/project_auto_devops.rb
app/models/project_auto_devops.rb
+1
-5
app/services/projects/update_service.rb
app/services/projects/update_service.rb
+1
-1
doc/topics/autodevops/index.md
doc/topics/autodevops/index.md
+5
-0
spec/models/project_auto_devops_spec.rb
spec/models/project_auto_devops_spec.rb
+3
-3
spec/models/project_spec.rb
spec/models/project_spec.rb
+32
-16
spec/spec_helper.rb
spec/spec_helper.rb
+7
-0
No files found.
app/models/project.rb
View file @
555cdade
...
@@ -27,6 +27,7 @@ class Project < ActiveRecord::Base
...
@@ -27,6 +27,7 @@ class Project < ActiveRecord::Base
include
FastDestroyAll
::
Helpers
include
FastDestroyAll
::
Helpers
include
WithUploads
include
WithUploads
include
BatchDestroyDependentAssociations
include
BatchDestroyDependentAssociations
include
FeatureGate
extend
Gitlab
::
Cache
::
RequestCache
extend
Gitlab
::
Cache
::
RequestCache
extend
Gitlab
::
ConfigHelper
extend
Gitlab
::
ConfigHelper
...
@@ -519,18 +520,19 @@ class Project < ActiveRecord::Base
...
@@ -519,18 +520,19 @@ class Project < ActiveRecord::Base
def
auto_devops_enabled?
def
auto_devops_enabled?
if
auto_devops
&
.
enabled
.
nil?
if
auto_devops
&
.
enabled
.
nil?
Gitlab
::
CurrentSettings
.
auto_devops
_enabled?
has_auto_devops_implicitly
_enabled?
else
else
auto_devops
.
enabled?
auto_devops
.
enabled?
end
end
end
end
def
has_auto_devops_implicitly_enabled?
def
has_auto_devops_implicitly_enabled?
auto_devops
&
.
enabled
.
nil?
&&
Gitlab
::
CurrentSettings
.
auto_devops_enabled?
auto_devops
&
.
enabled
.
nil?
&&
(
Gitlab
::
CurrentSettings
.
auto_devops_enabled?
||
Feature
.
enabled?
(
:force_autodevops_on_by_default
,
self
))
end
end
def
has_auto_devops_implicitly_disabled?
def
has_auto_devops_implicitly_disabled?
auto_devops
&
.
enabled
.
nil?
&&
!
Gitlab
::
CurrentSettings
.
auto_devops_enabled?
auto_devops
&
.
enabled
.
nil?
&&
!
(
Gitlab
::
CurrentSettings
.
auto_devops_enabled?
||
Feature
.
enabled?
(
:force_autodevops_on_by_default
,
self
))
end
end
def
empty_repo?
def
empty_repo?
...
...
app/models/project_auto_devops.rb
View file @
555cdade
...
@@ -47,12 +47,8 @@ class ProjectAutoDevops < ActiveRecord::Base
...
@@ -47,12 +47,8 @@ class ProjectAutoDevops < ActiveRecord::Base
end
end
def
needs_to_create_deploy_token?
def
needs_to_create_deploy_token?
auto_devops_enabled?
&&
project
.
auto_devops_enabled?
&&
!
project
.
public?
&&
!
project
.
public?
&&
!
project
.
deploy_tokens
.
find_by
(
name:
DeployToken
::
GITLAB_DEPLOY_TOKEN_NAME
).
present?
!
project
.
deploy_tokens
.
find_by
(
name:
DeployToken
::
GITLAB_DEPLOY_TOKEN_NAME
).
present?
end
end
def
auto_devops_enabled?
Gitlab
::
CurrentSettings
.
auto_devops_enabled?
||
enabled?
end
end
end
app/services/projects/update_service.rb
View file @
555cdade
...
@@ -30,7 +30,7 @@ module Projects
...
@@ -30,7 +30,7 @@ module Projects
def
run_auto_devops_pipeline?
def
run_auto_devops_pipeline?
return
false
if
project
.
repository
.
gitlab_ci_yml
||
!
project
.
auto_devops
&
.
previous_changes
&
.
include?
(
'enabled'
)
return
false
if
project
.
repository
.
gitlab_ci_yml
||
!
project
.
auto_devops
&
.
previous_changes
&
.
include?
(
'enabled'
)
project
.
auto_devops
.
enabled?
||
(
project
.
auto_devops
.
enabled
.
nil?
&&
Gitlab
::
CurrentSettings
.
auto_devops_enabled?
)
project
.
auto_devops
_enabled?
end
end
private
private
...
...
doc/topics/autodevops/index.md
View file @
555cdade
...
@@ -233,6 +233,11 @@ in **Admin Area > Settings > Continuous Integration and Deployment**. Doing that
...
@@ -233,6 +233,11 @@ in **Admin Area > Settings > Continuous Integration and Deployment**. Doing that
all the projects that haven't explicitly set an option will have Auto DevOps
all the projects that haven't explicitly set an option will have Auto DevOps
enabled by default.
enabled by default.
NOTE:
**Note:**
There is also a feature flag to enable Auto DevOps to a percentage of projects
which can be enabled from the console with
`Feature.get(:force_autodevops_on_by_default).enable_percentage_of_actors(10)`
.
### Deployment strategy
### Deployment strategy
> [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/issues/38542) in GitLab 11.0.
> [Introduced](https://gitlab.com/gitlab-org/gitlab-ce/issues/38542) in GitLab 11.0.
...
...
spec/models/project_auto_devops_spec.rb
View file @
555cdade
...
@@ -100,7 +100,7 @@ describe ProjectAutoDevops do
...
@@ -100,7 +100,7 @@ describe ProjectAutoDevops do
end
end
end
end
describe
'#
set
_gitlab_deploy_token'
do
describe
'#
create
_gitlab_deploy_token'
do
let
(
:auto_devops
)
{
build
(
:project_auto_devops
,
project:
project
)
}
let
(
:auto_devops
)
{
build
(
:project_auto_devops
,
project:
project
)
}
context
'when the project is public'
do
context
'when the project is public'
do
...
@@ -144,9 +144,9 @@ describe ProjectAutoDevops do
...
@@ -144,9 +144,9 @@ describe ProjectAutoDevops do
end
end
end
end
context
'when autodevops is enabled at instance
l
level'
do
context
'when autodevops is enabled at instance level'
do
let
(
:project
)
{
create
(
:project
,
:repository
,
:internal
)
}
let
(
:project
)
{
create
(
:project
,
:repository
,
:internal
)
}
let
(
:auto_devops
)
{
build
(
:project_auto_devops
,
:disabled
,
project:
project
)
}
let
(
:auto_devops
)
{
build
(
:project_auto_devops
,
enabled:
nil
,
project:
project
)
}
it
'should create a deploy token'
do
it
'should create a deploy token'
do
allow
(
Gitlab
::
CurrentSettings
).
to
receive
(
:auto_devops_enabled?
).
and_return
(
true
)
allow
(
Gitlab
::
CurrentSettings
).
to
receive
(
:auto_devops_enabled?
).
and_return
(
true
)
...
...
spec/models/project_spec.rb
View file @
555cdade
...
@@ -3259,6 +3259,11 @@ describe Project do
...
@@ -3259,6 +3259,11 @@ describe Project do
end
end
describe
'#auto_devops_enabled?'
do
describe
'#auto_devops_enabled?'
do
before
do
allow
(
Feature
).
to
receive
(
:enabled?
).
and_call_original
Feature
.
get
(
:force_autodevops_on_by_default
).
enable_percentage_of_actors
(
0
)
end
set
(
:project
)
{
create
(
:project
)
}
set
(
:project
)
{
create
(
:project
)
}
subject
{
project
.
auto_devops_enabled?
}
subject
{
project
.
auto_devops_enabled?
}
...
@@ -3268,19 +3273,14 @@ describe Project do
...
@@ -3268,19 +3273,14 @@ describe Project do
stub_application_setting
(
auto_devops_enabled:
true
)
stub_application_setting
(
auto_devops_enabled:
true
)
end
end
it
'auto devops is implicitly enabled'
do
it
{
is_expected
.
to
be_truthy
}
expect
(
project
.
auto_devops
).
to
be_nil
expect
(
project
).
to
be_auto_devops_enabled
end
context
'when explicitly enabled'
do
context
'when explicitly enabled'
do
before
do
before
do
create
(
:project_auto_devops
,
project:
project
)
create
(
:project_auto_devops
,
project:
project
)
end
end
it
"auto devops is enabled"
do
it
{
is_expected
.
to
be_truthy
}
expect
(
project
).
to
be_auto_devops_enabled
end
end
end
context
'when explicitly disabled'
do
context
'when explicitly disabled'
do
...
@@ -3288,9 +3288,7 @@ describe Project do
...
@@ -3288,9 +3288,7 @@ describe Project do
create
(
:project_auto_devops
,
project:
project
,
enabled:
false
)
create
(
:project_auto_devops
,
project:
project
,
enabled:
false
)
end
end
it
"auto devops is disabled"
do
it
{
is_expected
.
to
be_falsey
}
expect
(
project
).
not_to
be_auto_devops_enabled
end
end
end
end
end
...
@@ -3299,19 +3297,22 @@ describe Project do
...
@@ -3299,19 +3297,22 @@ describe Project do
stub_application_setting
(
auto_devops_enabled:
false
)
stub_application_setting
(
auto_devops_enabled:
false
)
end
end
it
'auto devops is implicitly disabled'
do
it
{
is_expected
.
to
be_falsey
}
expect
(
project
.
auto_devops
).
to
be_nil
expect
(
project
).
not_to
be_auto_devops_enabled
end
context
'when explicitly enabled'
do
context
'when explicitly enabled'
do
before
do
before
do
create
(
:project_auto_devops
,
project:
project
)
create
(
:project_auto_devops
,
project:
project
)
end
end
it
"auto devops is enabled"
do
it
{
is_expected
.
to
be_truthy
}
expect
(
project
).
to
be_auto_devops_enabled
end
context
'when force_autodevops_on_by_default is enabled for the project'
do
before
do
Feature
.
get
(
:force_autodevops_on_by_default
).
enable_percentage_of_actors
(
100
)
end
end
it
{
is_expected
.
to
be_truthy
}
end
end
end
end
end
end
...
@@ -3361,6 +3362,11 @@ describe Project do
...
@@ -3361,6 +3362,11 @@ describe Project do
end
end
describe
'#has_auto_devops_implicitly_disabled?'
do
describe
'#has_auto_devops_implicitly_disabled?'
do
before
do
allow
(
Feature
).
to
receive
(
:enabled?
).
and_call_original
Feature
.
get
(
:force_autodevops_on_by_default
).
enable_percentage_of_actors
(
0
)
end
set
(
:project
)
{
create
(
:project
)
}
set
(
:project
)
{
create
(
:project
)
}
context
'when enabled in settings'
do
context
'when enabled in settings'
do
...
@@ -3382,6 +3388,16 @@ describe Project do
...
@@ -3382,6 +3388,16 @@ describe Project do
expect
(
project
).
to
have_auto_devops_implicitly_disabled
expect
(
project
).
to
have_auto_devops_implicitly_disabled
end
end
context
'when force_autodevops_on_by_default is enabled for the project'
do
before
do
Feature
.
get
(
:force_autodevops_on_by_default
).
enable_percentage_of_actors
(
100
)
end
it
'does not have auto devops implicitly disabled'
do
expect
(
project
).
not_to
have_auto_devops_implicitly_disabled
end
end
context
'when explicitly disabled'
do
context
'when explicitly disabled'
do
before
do
before
do
create
(
:project_auto_devops
,
project:
project
,
enabled:
false
)
create
(
:project_auto_devops
,
project:
project
,
enabled:
false
)
...
...
spec/spec_helper.rb
View file @
555cdade
...
@@ -111,6 +111,13 @@ RSpec.configure do |config|
...
@@ -111,6 +111,13 @@ RSpec.configure do |config|
config
.
before
(
:example
)
do
config
.
before
(
:example
)
do
# Enable all features by default for testing
# Enable all features by default for testing
allow
(
Feature
).
to
receive
(
:enabled?
)
{
true
}
allow
(
Feature
).
to
receive
(
:enabled?
)
{
true
}
# The following can be removed when we remove the staged rollout strategy
# and we can just enable it using instance wide settings
# (ie. ApplicationSetting#auto_devops_enabled)
allow
(
Feature
).
to
receive
(
:enabled?
)
.
with
(
:force_autodevops_on_by_default
,
anything
)
.
and_return
(
false
)
end
end
config
.
before
(
:example
,
:request_store
)
do
config
.
before
(
:example
,
:request_store
)
do
...
...
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