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
3c558f21
Commit
3c558f21
authored
Feb 19, 2021
by
Pedro Pombeiro
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Report any cyclic dep error when seeding build
parent
1a0afd17
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
1 deletion
+78
-1
lib/gitlab/ci/pipeline/seed/build.rb
lib/gitlab/ci/pipeline/seed/build.rb
+7
-1
spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
+71
-0
No files found.
lib/gitlab/ci/pipeline/seed/build.rb
View file @
3c558f21
...
@@ -52,7 +52,7 @@ module Gitlab
...
@@ -52,7 +52,7 @@ module Gitlab
return
unless
included?
return
unless
included?
strong_memoize
(
:errors
)
do
strong_memoize
(
:errors
)
do
needs_errors
[
needs_errors
,
variable_expansion_errors
].
compact
.
flatten
end
end
end
end
...
@@ -153,6 +153,12 @@ module Gitlab
...
@@ -153,6 +153,12 @@ module Gitlab
@pipeline
.
project
.
actual_limits
.
ci_needs_size_limit
@pipeline
.
project
.
actual_limits
.
ci_needs_size_limit
end
end
def
variable_expansion_errors
sorted_collection
=
evaluate_context
.
variables
.
sorted_collection
(
@pipeline
.
project
)
errors
=
sorted_collection
.
errors
[
"
#{
name
}
:
#{
errors
}
"
]
if
errors
end
def
pipeline_attributes
def
pipeline_attributes
{
{
pipeline:
@pipeline
,
pipeline:
@pipeline
,
...
...
spec/lib/gitlab/ci/pipeline/seed/build_spec.rb
View file @
3c558f21
...
@@ -1025,4 +1025,75 @@ RSpec.describe Gitlab::Ci::Pipeline::Seed::Build do
...
@@ -1025,4 +1025,75 @@ RSpec.describe Gitlab::Ci::Pipeline::Seed::Build do
end
end
end
end
end
end
describe
'applying pipeline variables'
do
subject
{
seed_build
}
let
(
:pipeline_variables
)
{
[]
}
let
(
:pipeline
)
do
build
(
:ci_empty_pipeline
,
project:
project
,
sha:
head_sha
,
variables:
pipeline_variables
)
end
context
'containing variable references'
do
let
(
:pipeline_variables
)
do
[
build
(
:ci_pipeline_variable
,
key:
'A'
,
value:
'$B'
),
build
(
:ci_pipeline_variable
,
key:
'B'
,
value:
'$C'
)
]
end
context
'when FF :variable_inside_variable is enabled'
do
before
do
stub_feature_flags
(
variable_inside_variable:
[
project
])
end
it
"does not have errors"
do
expect
(
subject
.
errors
).
to
be_empty
end
end
end
context
'containing cyclic reference'
do
let
(
:pipeline_variables
)
do
[
build
(
:ci_pipeline_variable
,
key:
'A'
,
value:
'$B'
),
build
(
:ci_pipeline_variable
,
key:
'B'
,
value:
'$C'
),
build
(
:ci_pipeline_variable
,
key:
'C'
,
value:
'$A'
)
]
end
context
'when FF :variable_inside_variable is disabled'
do
before
do
stub_feature_flags
(
variable_inside_variable:
false
)
end
it
"does not have errors"
do
expect
(
subject
.
errors
).
to
be_empty
end
end
context
'when FF :variable_inside_variable is enabled'
do
before
do
stub_feature_flags
(
variable_inside_variable:
[
project
])
end
it
"returns an error"
do
expect
(
subject
.
errors
).
to
contain_exactly
(
'rspec: circular variable reference detected: ["A", "B", "C"]'
)
end
context
'with job:rules:[if:]'
do
let
(
:attributes
)
{
{
name:
'rspec'
,
ref:
'master'
,
rules:
[{
if:
'$C != null'
,
when:
'always'
}]
}
}
it
"included? does not raise"
do
expect
{
subject
.
included?
}.
not_to
raise_error
end
it
"included? returns true"
do
expect
(
subject
.
included?
).
to
eq
(
true
)
end
end
end
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