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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
7e461df6
Commit
7e461df6
authored
Apr 16, 2019
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add project level config for merge train
We add the option and expose the parameter for frontend work
parent
72db0691
Changes
15
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
189 additions
and
44 deletions
+189
-44
app/models/project_ci_cd_setting.rb
app/models/project_ci_cd_setting.rb
+2
-0
db/migrate/20190416185130_add_merge_train_enabled_to_ci_cd_settings.rb
...190416185130_add_merge_train_enabled_to_ci_cd_settings.rb
+17
-0
db/schema.rb
db/schema.rb
+1
-0
ee/app/controllers/ee/projects_controller.rb
ee/app/controllers/ee/projects_controller.rb
+6
-0
ee/app/helpers/ee/projects_helper.rb
ee/app/helpers/ee/projects_helper.rb
+6
-0
ee/app/models/ee/project.rb
ee/app/models/ee/project.rb
+1
-4
ee/app/models/ee/project_ci_cd_setting.rb
ee/app/models/ee/project_ci_cd_setting.rb
+15
-0
ee/app/models/license.rb
ee/app/models/license.rb
+1
-0
ee/app/serializers/ee/merge_request_widget_entity.rb
ee/app/serializers/ee/merge_request_widget_entity.rb
+4
-0
ee/changelogs/unreleased/add-project-level-config-for-merge-train.yml
...s/unreleased/add-project-level-config-for-merge-train.yml
+5
-0
ee/spec/controllers/projects_controller_spec.rb
ee/spec/controllers/projects_controller_spec.rb
+42
-0
ee/spec/models/project_ci_cd_setting_spec.rb
ee/spec/models/project_ci_cd_setting_spec.rb
+84
-0
ee/spec/models/project_spec.rb
ee/spec/models/project_spec.rb
+0
-39
ee/spec/serializers/merge_request_widget_entity_spec.rb
ee/spec/serializers/merge_request_widget_entity_spec.rb
+4
-0
spec/models/merge_request_spec.rb
spec/models/merge_request_spec.rb
+1
-1
No files found.
app/models/project_ci_cd_setting.rb
View file @
7e461df6
...
...
@@ -16,3 +16,5 @@ class ProjectCiCdSetting < ApplicationRecord
super
end
end
ProjectCiCdSetting
.
prepend
(
EE
::
ProjectCiCdSetting
)
db/migrate/20190416185130_add_merge_train_enabled_to_ci_cd_settings.rb
0 → 100644
View file @
7e461df6
# frozen_string_literal: true
class
AddMergeTrainEnabledToCiCdSettings
<
ActiveRecord
::
Migration
[
5.1
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
add_column_with_default
:project_ci_cd_settings
,
:merge_trains_enabled
,
:boolean
,
default:
false
,
allow_null:
false
end
def
down
remove_column
:project_ci_cd_settings
,
:merge_trains_enabled
end
end
db/schema.rb
View file @
7e461df6
...
...
@@ -2314,6 +2314,7 @@ ActiveRecord::Schema.define(version: 20190426180107) do
t
.
integer
"project_id"
,
null:
false
t
.
boolean
"group_runners_enabled"
,
default:
true
,
null:
false
t
.
boolean
"merge_pipelines_enabled"
t
.
boolean
"merge_trains_enabled"
,
default:
false
,
null:
false
t
.
index
[
"project_id"
],
name:
"index_project_ci_cd_settings_on_project_id"
,
unique:
true
,
using: :btree
end
...
...
ee/app/controllers/ee/projects_controller.rb
View file @
7e461df6
...
...
@@ -50,6 +50,8 @@ module EE
attrs
<<
%i[merge_pipelines_enabled]
end
attrs
<<
%i[merge_trains_enabled]
if
allow_merge_trains_params?
if
allow_mirror_params?
attrs
+
mirror_params
else
...
...
@@ -76,5 +78,9 @@ module EE
def
allow_merge_pipelines_params?
project
&
.
feature_available?
(
:merge_pipelines
)
end
def
allow_merge_trains_params?
project
&
.
feature_available?
(
:merge_trains
)
end
end
end
ee/app/helpers/ee/projects_helper.rb
View file @
7e461df6
...
...
@@ -121,6 +121,12 @@ module EE
@project
.
feature_available?
(
:merge_pipelines
)
end
def
merge_trains_available?
return
false
unless
@project
.
builds_enabled?
@project
.
feature_available?
(
:merge_trains
)
end
def
size_limit_message
(
project
)
show_lfs
=
project
.
lfs_enabled?
?
'including files in LFS'
:
''
...
...
ee/app/models/ee/project.rb
View file @
7e461df6
...
...
@@ -107,6 +107,7 @@ module EE
delegate
:log_jira_dvcs_integration_usage
,
:jira_dvcs_server_last_sync_at
,
:jira_dvcs_cloud_last_sync_at
,
to: :feature_usage
delegate
:merge_pipelines_enabled
,
:merge_pipelines_enabled
=
,
:merge_pipelines_enabled?
,
to: :ci_cd_settings
delegate
:merge_trains_enabled
,
:merge_trains_enabled
=
,
:merge_trains_enabled?
,
to: :ci_cd_settings
validates
:repository_size_limit
,
numericality:
{
only_integer:
true
,
greater_than_or_equal_to:
0
,
allow_nil:
true
}
...
...
@@ -524,10 +525,6 @@ module EE
feature_available?
(
:protected_environments
)
end
def
merge_pipelines_enabled?
feature_available?
(
:merge_pipelines
)
&&
super
end
# Because we use default_value_for we need to be sure
# packages_enabled= method does exist even if we rollback migration.
# Otherwise many tests from spec/migrations will fail.
...
...
ee/app/models/ee/project_ci_cd_setting.rb
0 → 100644
View file @
7e461df6
# frozen_string_literal: true
module
EE
module
ProjectCiCdSetting
extend
ActiveSupport
::
Concern
def
merge_pipelines_enabled?
project
.
feature_available?
(
:merge_pipelines
)
&&
super
end
def
merge_trains_enabled?
merge_pipelines_enabled?
&&
project
.
feature_available?
(
:merge_trains
)
&&
super
end
end
end
ee/app/models/license.rb
View file @
7e461df6
...
...
@@ -75,6 +75,7 @@ class License < ApplicationRecord
batch_comments
issues_analytics
merge_pipelines
merge_trains
design_management
operations_dashboard
dependency_proxy
...
...
ee/app/serializers/ee/merge_request_widget_entity.rb
View file @
7e461df6
...
...
@@ -127,6 +127,10 @@ module EE
merge_request
.
target_project
.
merge_pipelines_enabled?
end
expose
:merge_trains_enabled?
,
as: :merge_trains_enabled
do
|
merge_request
|
merge_request
.
target_project
.
merge_trains_enabled?
end
expose
:can_push_to_source_branch
do
|
merge_request
|
presenter
(
merge_request
).
can_push_to_source_branch?
end
...
...
ee/changelogs/unreleased/add-project-level-config-for-merge-train.yml
0 → 100644
View file @
7e461df6
---
title
:
Add project level config for merge train
merge_request
:
11065
author
:
type
:
added
ee/spec/controllers/projects_controller_spec.rb
View file @
7e461df6
...
...
@@ -224,6 +224,48 @@ describe ProjectsController do
end
end
context
'when merge_trains_enabled param is specified'
do
let
(
:params
)
{
{
merge_trains_enabled:
true
}
}
let
(
:request
)
do
put
:update
,
params:
{
namespace_id:
project
.
namespace
,
id:
project
,
project:
params
}
end
before
do
stub_licensed_features
(
merge_trains:
true
)
end
it
'updates the attribute'
do
request
expect
(
project
.
reload
.
merge_trains_enabled
).
to
be_truthy
end
context
'when feature flag is disabled'
do
before
do
stub_feature_flags
(
merge_trains:
false
)
end
it
'does not update the attribute'
do
request
expect
(
project
.
reload
.
merge_trains_enabled
).
to
be_falsy
end
end
context
'when license is not sufficient'
do
before
do
stub_licensed_features
(
merge_trains:
false
)
end
it
'does not update the attribute'
do
request
expect
(
project
.
reload
.
merge_trains_enabled
).
to
be_falsy
end
end
end
context
'repository mirrors'
do
let
(
:params
)
do
{
...
...
ee/spec/models/project_ci_cd_setting_spec.rb
0 → 100644
View file @
7e461df6
# frozen_string_literal: true
require
'spec_helper'
describe
ProjectCiCdSetting
do
describe
'#merge_pipelines_enabled?'
do
subject
{
project
.
merge_pipelines_enabled?
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:merge_pipelines_enabled
)
{
true
}
before
do
project
.
merge_pipelines_enabled
=
merge_pipelines_enabled
end
context
'when Merge pipelines (EEP) is available'
do
before
do
stub_licensed_features
(
merge_pipelines:
true
)
end
it
{
is_expected
.
to
be_truthy
}
context
'when project setting is disabled'
do
let
(
:merge_pipelines_enabled
)
{
false
}
it
{
is_expected
.
to
be_falsy
}
end
end
context
'when Merge pipelines (EEP) is unavailable'
do
before
do
stub_licensed_features
(
merge_pipelines:
false
)
end
it
{
is_expected
.
to
be_falsy
}
context
'when project setting is disabled'
do
let
(
:merge_pipelines_enabled
)
{
false
}
it
{
is_expected
.
to
be_falsy
}
end
end
end
describe
'#merge_trains_enabled?'
do
subject
{
project
.
merge_trains_enabled?
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:merge_trains_enabled
)
{
true
}
before
do
project
.
merge_trains_enabled
=
merge_trains_enabled
end
context
'when Merge trains (EEP) is available'
do
before
do
stub_licensed_features
(
merge_pipelines:
true
,
merge_trains:
true
)
project
.
merge_pipelines_enabled
=
true
end
it
{
is_expected
.
to
be_truthy
}
context
'when project setting is disabled'
do
let
(
:merge_trains_enabled
)
{
false
}
it
{
is_expected
.
to
be_falsy
}
end
end
context
'when Merge trains (EEP) is unavailable'
do
before
do
stub_licensed_features
(
merge_trains:
false
)
end
it
{
is_expected
.
to
be_falsy
}
context
'when project setting is disabled'
do
let
(
:merge_trains_enabled
)
{
false
}
it
{
is_expected
.
to
be_falsy
}
end
end
end
end
ee/spec/models/project_spec.rb
View file @
7e461df6
...
...
@@ -1745,45 +1745,6 @@ describe Project do
end
end
describe
'#merge_pipelines_enabled?'
do
subject
{
project
.
merge_pipelines_enabled?
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:merge_pipelines_enabled
)
{
true
}
before
do
project
.
merge_pipelines_enabled
=
merge_pipelines_enabled
end
context
'when Merge pipelines (EEP) is available'
do
before
do
stub_licensed_features
(
merge_pipelines:
true
)
end
it
{
is_expected
.
to
be_truthy
}
context
'when project setting is disabled'
do
let
(
:merge_pipelines_enabled
)
{
false
}
it
{
is_expected
.
to
be_falsy
}
end
end
context
'when Merge pipelines (EEP) is unavailable'
do
before
do
stub_licensed_features
(
merge_pipelines:
false
)
end
it
{
is_expected
.
to
be_falsy
}
context
'when project setting is disabled'
do
let
(
:merge_pipelines_enabled
)
{
false
}
it
{
is_expected
.
to
be_falsy
}
end
end
end
describe
"#insights_config"
do
context
'when project has no Insights config file'
do
let
(
:project
)
{
create
(
:project
)
}
...
...
ee/spec/serializers/merge_request_widget_entity_spec.rb
View file @
7e461df6
...
...
@@ -190,4 +190,8 @@ describe MergeRequestWidgetEntity do
expect
(
subject
.
as_json
).
to
include
(
:pipeline_id
)
end
it
'has merge trains flag'
do
expect
(
subject
.
as_json
).
to
include
(
:merge_trains_enabled
)
end
end
spec/models/merge_request_spec.rb
View file @
7e461df6
...
...
@@ -2123,7 +2123,7 @@ describe MergeRequest do
end
context
'when merges are not restricted to green builds'
do
subject
{
build
(
:merge_request
,
target_project:
build
(
:project
,
only_allow_merge_if_pipeline_succeeds:
false
))
}
subject
{
build
(
:merge_request
,
target_project:
create
(
:project
,
only_allow_merge_if_pipeline_succeeds:
false
))
}
context
'and a failed pipeline is associated'
do
before
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