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
10a486b3
Commit
10a486b3
authored
Sep 14, 2017
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove YAML processor refactoring stubs and fix specs
parent
241197c2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
81 additions
and
85 deletions
+81
-85
lib/gitlab/ci/build/policy/refs.rb
lib/gitlab/ci/build/policy/refs.rb
+1
-1
lib/gitlab/ci/yaml_processor.rb
lib/gitlab/ci/yaml_processor.rb
+25
-31
spec/lib/gitlab/ci/yaml_processor_spec.rb
spec/lib/gitlab/ci/yaml_processor_spec.rb
+55
-53
No files found.
lib/gitlab/ci/build/policy/refs.rb
View file @
10a486b3
...
@@ -26,7 +26,7 @@ module Gitlab
...
@@ -26,7 +26,7 @@ module Gitlab
def
matches_pattern?
(
pattern
,
pipeline
)
def
matches_pattern?
(
pattern
,
pipeline
)
return
true
if
pipeline
.
tag?
&&
pattern
==
'tags'
return
true
if
pipeline
.
tag?
&&
pattern
==
'tags'
return
true
if
!
pipeline
.
tag
?
&&
pattern
==
'branches'
return
true
if
pipeline
.
branch
?
&&
pattern
==
'branches'
return
true
if
source_to_pattern
(
pipeline
.
source
)
==
pattern
return
true
if
source_to_pattern
(
pipeline
.
source
)
==
pattern
if
pattern
.
first
==
"/"
&&
pattern
.
last
==
"/"
if
pattern
.
first
==
"/"
&&
pattern
.
last
==
"/"
...
...
lib/gitlab/ci/yaml_processor.rb
View file @
10a486b3
...
@@ -22,28 +22,12 @@ module Gitlab
...
@@ -22,28 +22,12 @@ module Gitlab
end
end
# REFACTORING STUB, remove this method, used only in tests.
#
def
builds_for_stage_and_ref
(
stage
,
ref
,
tag
=
false
,
source
=
nil
)
pipeline_stage_builds
(
stage
,
::
Ci
::
Pipeline
.
new
(
ref:
ref
,
source:
source
,
tag:
tag
))
end
def
builds
def
builds
@jobs
.
map
do
|
name
,
_
|
@jobs
.
map
do
|
name
,
_
|
build_attributes
(
name
)
build_attributes
(
name
)
end
end
end
end
def
stage_seeds
(
pipeline
)
seeds
=
@stages
.
uniq
.
map
do
|
stage
|
builds
=
pipeline_stage_builds
(
stage
,
pipeline
)
Gitlab
::
Ci
::
Stage
::
Seed
.
new
(
pipeline
,
stage
,
builds
)
if
builds
.
any?
end
seeds
.
compact
end
def
build_attributes
(
name
)
def
build_attributes
(
name
)
job
=
@jobs
[
name
.
to_sym
]
||
{}
job
=
@jobs
[
name
.
to_sym
]
||
{}
...
@@ -71,21 +55,8 @@ module Gitlab
...
@@ -71,21 +55,8 @@ module Gitlab
}.
compact
}
}.
compact
}
end
end
def
self
.
validation_message
(
content
)
return
'Please provide content of .gitlab-ci.yml'
if
content
.
blank?
begin
Gitlab
::
Ci
::
YamlProcessor
.
new
(
content
)
nil
rescue
ValidationError
,
Psych
::
SyntaxError
=>
e
e
.
message
end
end
private
def
pipeline_stage_builds
(
stage
,
pipeline
)
def
pipeline_stage_builds
(
stage
,
pipeline
)
s
tage
_jobs
=
@jobs
.
select
do
|
_
,
job
|
s
elected
_jobs
=
@jobs
.
select
do
|
_
,
job
|
next
unless
job
[
:stage
]
==
stage
next
unless
job
[
:stage
]
==
stage
only_specs
=
Gitlab
::
Ci
::
Build
::
Policy
only_specs
=
Gitlab
::
Ci
::
Build
::
Policy
...
@@ -97,9 +68,32 @@ module Gitlab
...
@@ -97,9 +68,32 @@ module Gitlab
except_specs
.
none?
{
|
spec
|
spec
.
satisfied_by?
(
pipeline
,
path:
@path
)
}
except_specs
.
none?
{
|
spec
|
spec
.
satisfied_by?
(
pipeline
,
path:
@path
)
}
end
end
stage_jobs
.
map
{
|
_
,
job
|
build_attributes
(
job
[
:name
])
}
selected_jobs
.
map
{
|
_
,
job
|
build_attributes
(
job
[
:name
])
}
end
def
stage_seeds
(
pipeline
)
seeds
=
@stages
.
uniq
.
map
do
|
stage
|
builds
=
pipeline_stage_builds
(
stage
,
pipeline
)
Gitlab
::
Ci
::
Stage
::
Seed
.
new
(
pipeline
,
stage
,
builds
)
if
builds
.
any?
end
seeds
.
compact
end
def
self
.
validation_message
(
content
)
return
'Please provide content of .gitlab-ci.yml'
if
content
.
blank?
begin
Gitlab
::
Ci
::
YamlProcessor
.
new
(
content
)
nil
rescue
ValidationError
,
Psych
::
SyntaxError
=>
e
e
.
message
end
end
end
private
def
initial_parsing
def
initial_parsing
##
##
# Global config
# Global config
...
...
spec/lib/gitlab/ci/yaml_processor_spec.rb
View file @
10a486b3
...
@@ -167,8 +167,6 @@ module Gitlab
...
@@ -167,8 +167,6 @@ module Gitlab
end
end
context
'when kubernetes policy is specified'
do
context
'when kubernetes policy is specified'
do
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
)
}
let
(
:config
)
do
let
(
:config
)
do
YAML
.
dump
(
YAML
.
dump
(
spinach:
{
stage:
'test'
,
script:
'spinach'
},
spinach:
{
stage:
'test'
,
script:
'spinach'
},
...
@@ -204,7 +202,7 @@ module Gitlab
...
@@ -204,7 +202,7 @@ module Gitlab
end
end
end
end
describe
"#
builds_for_stage_and_ref
"
do
describe
"#
pipeline_stage_builds
"
do
let
(
:type
)
{
'test'
}
let
(
:type
)
{
'test'
}
it
"returns builds if no branch specified"
do
it
"returns builds if no branch specified"
do
...
@@ -215,8 +213,8 @@ module Gitlab
...
@@ -215,8 +213,8 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"master"
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"master"
)
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"master"
).
first
).
to
eq
({
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"master"
)
).
first
).
to
eq
({
stage:
"test"
,
stage:
"test"
,
stage_idx:
1
,
stage_idx:
1
,
name:
"rspec"
,
name:
"rspec"
,
...
@@ -243,7 +241,7 @@ module Gitlab
...
@@ -243,7 +241,7 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"master"
).
size
).
to
eq
(
0
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"master"
)
).
size
).
to
eq
(
0
)
end
end
it
"does not return builds if only has regexp with another branch"
do
it
"does not return builds if only has regexp with another branch"
do
...
@@ -254,7 +252,7 @@ module Gitlab
...
@@ -254,7 +252,7 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"master"
).
size
).
to
eq
(
0
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"master"
)
).
size
).
to
eq
(
0
)
end
end
it
"returns builds if only has specified this branch"
do
it
"returns builds if only has specified this branch"
do
...
@@ -265,7 +263,7 @@ module Gitlab
...
@@ -265,7 +263,7 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"master"
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"master"
)
).
size
).
to
eq
(
1
)
end
end
it
"returns builds if only has a list of branches including specified"
do
it
"returns builds if only has a list of branches including specified"
do
...
@@ -276,7 +274,7 @@ module Gitlab
...
@@ -276,7 +274,7 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"deploy"
)
).
size
).
to
eq
(
1
)
end
end
it
"returns builds if only has a branches keyword specified"
do
it
"returns builds if only has a branches keyword specified"
do
...
@@ -287,7 +285,7 @@ module Gitlab
...
@@ -287,7 +285,7 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"deploy"
)
).
size
).
to
eq
(
1
)
end
end
it
"does not return builds if only has a tags keyword"
do
it
"does not return builds if only has a tags keyword"
do
...
@@ -298,7 +296,7 @@ module Gitlab
...
@@ -298,7 +296,7 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
).
size
).
to
eq
(
0
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"deploy"
)
).
size
).
to
eq
(
0
)
end
end
it
"returns builds if only has special keywords specified and source matches"
do
it
"returns builds if only has special keywords specified and source matches"
do
...
@@ -317,7 +315,7 @@ module Gitlab
...
@@ -317,7 +315,7 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
,
false
,
possibility
[
:source
]
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
'deploy'
,
tag:
false
,
source:
possibility
[
:source
])
).
size
).
to
eq
(
1
)
end
end
end
end
...
@@ -337,7 +335,7 @@ module Gitlab
...
@@ -337,7 +335,7 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
,
false
,
possibility
[
:source
]
).
size
).
to
eq
(
0
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
'deploy'
,
tag:
false
,
source:
possibility
[
:source
])
).
size
).
to
eq
(
0
)
end
end
end
end
...
@@ -349,7 +347,7 @@ module Gitlab
...
@@ -349,7 +347,7 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"deploy"
)
).
size
).
to
eq
(
1
)
end
end
it
"does not return builds if only has different repository path"
do
it
"does not return builds if only has different repository path"
do
...
@@ -360,7 +358,7 @@ module Gitlab
...
@@ -360,7 +358,7 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
).
size
).
to
eq
(
0
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"deploy"
)
).
size
).
to
eq
(
0
)
end
end
it
"returns build only for specified type"
do
it
"returns build only for specified type"
do
...
@@ -373,9 +371,9 @@ module Gitlab
...
@@ -373,9 +371,9 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
'fork'
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
'fork'
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
"deploy"
,
"deploy"
).
size
).
to
eq
(
2
)
expect
(
config_processor
.
pipeline_stage_builds
(
"deploy"
,
pipeline
(
ref:
"deploy"
)
).
size
).
to
eq
(
2
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"deploy"
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"deploy"
)
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
"deploy"
,
"master"
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
pipeline_stage_builds
(
"deploy"
,
pipeline
(
ref:
"master"
)
).
size
).
to
eq
(
1
)
end
end
context
'for invalid value'
do
context
'for invalid value'
do
...
@@ -420,7 +418,7 @@ module Gitlab
...
@@ -420,7 +418,7 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"master"
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"master"
)
).
size
).
to
eq
(
1
)
end
end
it
"returns builds if except has regexp with another branch"
do
it
"returns builds if except has regexp with another branch"
do
...
@@ -431,7 +429,7 @@ module Gitlab
...
@@ -431,7 +429,7 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"master"
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"master"
)
).
size
).
to
eq
(
1
)
end
end
it
"does not return builds if except has specified this branch"
do
it
"does not return builds if except has specified this branch"
do
...
@@ -442,7 +440,7 @@ module Gitlab
...
@@ -442,7 +440,7 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"master"
).
size
).
to
eq
(
0
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"master"
)
).
size
).
to
eq
(
0
)
end
end
it
"does not return builds if except has a list of branches including specified"
do
it
"does not return builds if except has a list of branches including specified"
do
...
@@ -453,7 +451,7 @@ module Gitlab
...
@@ -453,7 +451,7 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
).
size
).
to
eq
(
0
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"deploy"
)
).
size
).
to
eq
(
0
)
end
end
it
"does not return builds if except has a branches keyword specified"
do
it
"does not return builds if except has a branches keyword specified"
do
...
@@ -464,7 +462,7 @@ module Gitlab
...
@@ -464,7 +462,7 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
).
size
).
to
eq
(
0
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"deploy"
)
).
size
).
to
eq
(
0
)
end
end
it
"returns builds if except has a tags keyword"
do
it
"returns builds if except has a tags keyword"
do
...
@@ -475,7 +473,7 @@ module Gitlab
...
@@ -475,7 +473,7 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"deploy"
)
).
size
).
to
eq
(
1
)
end
end
it
"does not return builds if except has special keywords specified and source matches"
do
it
"does not return builds if except has special keywords specified and source matches"
do
...
@@ -494,7 +492,7 @@ module Gitlab
...
@@ -494,7 +492,7 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
,
false
,
possibility
[
:source
]
).
size
).
to
eq
(
0
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
'deploy'
,
tag:
false
,
source:
possibility
[
:source
])
).
size
).
to
eq
(
0
)
end
end
end
end
...
@@ -514,7 +512,7 @@ module Gitlab
...
@@ -514,7 +512,7 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
,
false
,
possibility
[
:source
]
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
'deploy'
,
tag:
false
,
source:
possibility
[
:source
])
).
size
).
to
eq
(
1
)
end
end
end
end
...
@@ -526,7 +524,7 @@ module Gitlab
...
@@ -526,7 +524,7 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
).
size
).
to
eq
(
0
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"deploy"
)
).
size
).
to
eq
(
0
)
end
end
it
"returns builds if except has different repository path"
do
it
"returns builds if except has different repository path"
do
...
@@ -537,7 +535,7 @@ module Gitlab
...
@@ -537,7 +535,7 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
type
,
"deploy"
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
pipeline_stage_builds
(
type
,
pipeline
(
ref:
"deploy"
)
).
size
).
to
eq
(
1
)
end
end
it
"returns build except specified type"
do
it
"returns build except specified type"
do
...
@@ -550,9 +548,9 @@ module Gitlab
...
@@ -550,9 +548,9 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
'fork'
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
'fork'
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
"deploy"
,
"deploy"
).
size
).
to
eq
(
2
)
expect
(
config_processor
.
pipeline_stage_builds
(
"deploy"
,
pipeline
(
ref:
"deploy"
)
).
size
).
to
eq
(
2
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"test"
).
size
).
to
eq
(
0
)
expect
(
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"test"
)
).
size
).
to
eq
(
0
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
"deploy"
,
"master"
).
size
).
to
eq
(
0
)
expect
(
config_processor
.
pipeline_stage_builds
(
"deploy"
,
pipeline
(
ref:
"master"
)
).
size
).
to
eq
(
0
)
end
end
context
'for invalid value'
do
context
'for invalid value'
do
...
@@ -593,7 +591,7 @@ module Gitlab
...
@@ -593,7 +591,7 @@ module Gitlab
let
(
:config_data
)
{
YAML
.
dump
(
config
)
}
let
(
:config_data
)
{
YAML
.
dump
(
config
)
}
let
(
:config_processor
)
{
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config_data
,
path
)
}
let
(
:config_processor
)
{
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config_data
,
path
)
}
subject
{
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
).
first
}
subject
{
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"master"
)
).
first
}
describe
"before_script"
do
describe
"before_script"
do
context
"in global context"
do
context
"in global context"
do
...
@@ -676,8 +674,8 @@ module Gitlab
...
@@ -676,8 +674,8 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"master"
)
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
).
first
).
to
eq
({
expect
(
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"master"
)
).
first
).
to
eq
({
stage:
"test"
,
stage:
"test"
,
stage_idx:
1
,
stage_idx:
1
,
name:
"rspec"
,
name:
"rspec"
,
...
@@ -711,8 +709,8 @@ module Gitlab
...
@@ -711,8 +709,8 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"master"
)
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
).
first
).
to
eq
({
expect
(
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"master"
)
).
first
).
to
eq
({
stage:
"test"
,
stage:
"test"
,
stage_idx:
1
,
stage_idx:
1
,
name:
"rspec"
,
name:
"rspec"
,
...
@@ -744,8 +742,8 @@ module Gitlab
...
@@ -744,8 +742,8 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"master"
)
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
).
first
).
to
eq
({
expect
(
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"master"
)
).
first
).
to
eq
({
stage:
"test"
,
stage:
"test"
,
stage_idx:
1
,
stage_idx:
1
,
name:
"rspec"
,
name:
"rspec"
,
...
@@ -773,8 +771,8 @@ module Gitlab
...
@@ -773,8 +771,8 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"master"
)
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
).
first
).
to
eq
({
expect
(
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"master"
)
).
first
).
to
eq
({
stage:
"test"
,
stage:
"test"
,
stage_idx:
1
,
stage_idx:
1
,
name:
"rspec"
,
name:
"rspec"
,
...
@@ -920,7 +918,7 @@ module Gitlab
...
@@ -920,7 +918,7 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
builds
=
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
)
builds
=
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"master"
)
)
expect
(
builds
.
size
).
to
eq
(
1
)
expect
(
builds
.
size
).
to
eq
(
1
)
expect
(
builds
.
first
[
:when
]).
to
eq
(
when_state
)
expect
(
builds
.
first
[
:when
]).
to
eq
(
when_state
)
end
end
...
@@ -951,8 +949,8 @@ module Gitlab
...
@@ -951,8 +949,8 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"master"
)
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
).
first
[
:options
][
:cache
]).
to
eq
(
expect
(
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"master"
)
).
first
[
:options
][
:cache
]).
to
eq
(
paths:
[
"logs/"
,
"binaries/"
],
paths:
[
"logs/"
,
"binaries/"
],
untracked:
true
,
untracked:
true
,
key:
'key'
,
key:
'key'
,
...
@@ -970,8 +968,8 @@ module Gitlab
...
@@ -970,8 +968,8 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"master"
)
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
).
first
[
:options
][
:cache
]).
to
eq
(
expect
(
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"master"
)
).
first
[
:options
][
:cache
]).
to
eq
(
paths:
[
"logs/"
,
"binaries/"
],
paths:
[
"logs/"
,
"binaries/"
],
untracked:
true
,
untracked:
true
,
key:
'key'
,
key:
'key'
,
...
@@ -990,8 +988,8 @@ module Gitlab
...
@@ -990,8 +988,8 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"master"
)
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
).
first
[
:options
][
:cache
]).
to
eq
(
expect
(
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"master"
)
).
first
[
:options
][
:cache
]).
to
eq
(
paths:
[
"test/"
],
paths:
[
"test/"
],
untracked:
false
,
untracked:
false
,
key:
'local'
,
key:
'local'
,
...
@@ -1019,8 +1017,8 @@ module Gitlab
...
@@ -1019,8 +1017,8 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"master"
)
).
size
).
to
eq
(
1
)
expect
(
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
).
first
).
to
eq
({
expect
(
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"master"
)
).
first
).
to
eq
({
stage:
"test"
,
stage:
"test"
,
stage_idx:
1
,
stage_idx:
1
,
name:
"rspec"
,
name:
"rspec"
,
...
@@ -1057,7 +1055,7 @@ module Gitlab
...
@@ -1057,7 +1055,7 @@ module Gitlab
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
config_processor
=
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
,
path
)
builds
=
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
)
builds
=
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"master"
)
)
expect
(
builds
.
size
).
to
eq
(
1
)
expect
(
builds
.
size
).
to
eq
(
1
)
expect
(
builds
.
first
[
:options
][
:artifacts
][
:when
]).
to
eq
(
when_state
)
expect
(
builds
.
first
[
:options
][
:artifacts
][
:when
]).
to
eq
(
when_state
)
end
end
...
@@ -1072,7 +1070,7 @@ module Gitlab
...
@@ -1072,7 +1070,7 @@ module Gitlab
end
end
let
(
:processor
)
{
Gitlab
::
Ci
::
YamlProcessor
.
new
(
YAML
.
dump
(
config
))
}
let
(
:processor
)
{
Gitlab
::
Ci
::
YamlProcessor
.
new
(
YAML
.
dump
(
config
))
}
let
(
:builds
)
{
processor
.
builds_for_stage_and_ref
(
'deploy'
,
'master'
)
}
let
(
:builds
)
{
processor
.
pipeline_stage_builds
(
'deploy'
,
pipeline
(
ref:
'master'
)
)
}
context
'when a production environment is specified'
do
context
'when a production environment is specified'
do
let
(
:environment
)
{
'production'
}
let
(
:environment
)
{
'production'
}
...
@@ -1229,7 +1227,7 @@ module Gitlab
...
@@ -1229,7 +1227,7 @@ module Gitlab
describe
"Hidden jobs"
do
describe
"Hidden jobs"
do
let
(
:config_processor
)
{
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
}
let
(
:config_processor
)
{
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
}
subject
{
config_processor
.
builds_for_stage_and_ref
(
"test"
,
"master"
)
}
subject
{
config_processor
.
pipeline_stage_builds
(
"test"
,
pipeline
(
ref:
"master"
)
)
}
shared_examples
'hidden_job_handling'
do
shared_examples
'hidden_job_handling'
do
it
"doesn't create jobs that start with dot"
do
it
"doesn't create jobs that start with dot"
do
...
@@ -1277,7 +1275,7 @@ module Gitlab
...
@@ -1277,7 +1275,7 @@ module Gitlab
describe
"YAML Alias/Anchor"
do
describe
"YAML Alias/Anchor"
do
let
(
:config_processor
)
{
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
}
let
(
:config_processor
)
{
Gitlab
::
Ci
::
YamlProcessor
.
new
(
config
)
}
subject
{
config_processor
.
builds_for_stage_and_ref
(
"build"
,
"master"
)
}
subject
{
config_processor
.
pipeline_stage_builds
(
"build"
,
pipeline
(
ref:
"master"
)
)
}
shared_examples
'job_templates_handling'
do
shared_examples
'job_templates_handling'
do
it
"is correctly supported for jobs"
do
it
"is correctly supported for jobs"
do
...
@@ -1694,6 +1692,10 @@ EOT
...
@@ -1694,6 +1692,10 @@ EOT
end
end
end
end
end
end
def
pipeline
(
**
attributes
)
build_stubbed
(
:ci_empty_pipeline
,
**
attributes
)
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