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
af59919b
Commit
af59919b
authored
Aug 14, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
11b21512
8fc2fbb6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
4 deletions
+52
-4
lib/gitlab/ci/pipeline/seed/build.rb
lib/gitlab/ci/pipeline/seed/build.rb
+19
-1
spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
+33
-3
No files found.
lib/gitlab/ci/pipeline/seed/build.rb
View file @
af59919b
...
...
@@ -9,6 +9,10 @@ module Gitlab
delegate
:dig
,
to: :@attributes
# When the `ci_dag_limit_needs` is enabled it uses the lower limit
LOW_NEEDS_LIMIT
=
5
HARD_NEEDS_LIMIT
=
50
def
initialize
(
pipeline
,
attributes
,
previous_stages
)
@pipeline
=
pipeline
@attributes
=
attributes
...
...
@@ -77,9 +81,15 @@ module Gitlab
end
def
needs_errors
return
unless
Feature
.
enabled?
(
:ci_dag_support
,
@pipeline
.
project
)
return
if
@needs_attributes
.
nil?
if
@needs_attributes
.
size
>
max_needs_allowed
return
[
"
#{
name
}
: one job can only need
#{
max_needs_allowed
}
others, but you have listed
#{
@needs_attributes
.
size
}
. "
\
"See needs keyword documentation for more details"
]
end
@needs_attributes
.
flat_map
do
|
need
|
result
=
@previous_stages
.
any?
do
|
stage
|
stage
.
seeds_names
.
include?
(
need
[
:name
])
...
...
@@ -88,6 +98,14 @@ module Gitlab
"
#{
name
}
: needs '
#{
need
[
:name
]
}
'"
unless
result
end
.
compact
end
def
max_needs_allowed
if
Feature
.
enabled?
(
:ci_dag_limit_needs
,
@project
,
default_enabled:
true
)
LOW_NEEDS_LIMIT
else
HARD_NEEDS_LIMIT
end
end
end
end
end
...
...
spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
View file @
af59919b
...
...
@@ -386,12 +386,16 @@ describe Gitlab::Ci::Pipeline::Seed::Build do
describe
'applying needs: dependency'
do
subject
{
seed_build
}
let
(
:needs_count
)
{
1
}
let
(
:needs_attributes
)
do
Array
.
new
(
needs_count
,
name:
'build'
)
end
let
(
:attributes
)
do
{
name:
'rspec'
,
needs_attributes:
[{
name:
'build'
}]
needs_attributes:
needs_attributes
}
end
...
...
@@ -429,5 +433,31 @@ describe Gitlab::Ci::Pipeline::Seed::Build do
expect
(
subject
.
errors
).
to
be_empty
end
end
context
'when lower limit of needs is reached'
do
before
do
stub_feature_flags
(
ci_dag_limit_needs:
true
)
end
let
(
:needs_count
)
{
described_class
::
LOW_NEEDS_LIMIT
+
1
}
it
"returns an error"
do
expect
(
subject
.
errors
).
to
contain_exactly
(
"rspec: one job can only need 5 others, but you have listed 6. See needs keyword documentation for more details"
)
end
end
context
'when upper limit of needs is reached'
do
before
do
stub_feature_flags
(
ci_dag_limit_needs:
false
)
end
let
(
:needs_count
)
{
described_class
::
HARD_NEEDS_LIMIT
+
1
}
it
"returns an error"
do
expect
(
subject
.
errors
).
to
contain_exactly
(
"rspec: one job can only need 50 others, but you have listed 51. See needs keyword documentation for more details"
)
end
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