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
Jérome Perrin
gitlab-ce
Commits
6ae80732
Commit
6ae80732
authored
Jul 05, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ability to define nodes in new CI config entry
parent
e00ae9a8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
14 deletions
+18
-14
lib/gitlab/ci/config/node/entry.rb
lib/gitlab/ci/config/node/entry.rb
+10
-6
spec/lib/gitlab/ci/config/node/global_spec.rb
spec/lib/gitlab/ci/config/node/global_spec.rb
+8
-8
No files found.
lib/gitlab/ci/config/node/entry.rb
View file @
6ae80732
...
@@ -26,12 +26,16 @@ module Gitlab
...
@@ -26,12 +26,16 @@ module Gitlab
process_nodes!
process_nodes!
end
end
def
leaf?
nodes
.
none?
end
def
nodes
def
nodes
@nodes
.
valu
es
self
.
class
.
nod
es
end
end
def
leaf?
def
descendants
self
.
class
.
nodes
.
none?
@nodes
.
values
end
end
def
ancestors
def
ancestors
...
@@ -43,7 +47,7 @@ module Gitlab
...
@@ -43,7 +47,7 @@ module Gitlab
end
end
def
errors
def
errors
@validator
.
messages
+
nod
es
.
flat_map
(
&
:errors
)
@validator
.
messages
+
@nodes
.
valu
es
.
flat_map
(
&
:errors
)
end
end
def
value
def
value
...
@@ -73,13 +77,13 @@ module Gitlab
...
@@ -73,13 +77,13 @@ module Gitlab
private
private
def
compose!
def
compose!
self
.
class
.
nodes
.
each
do
|
key
,
essence
|
nodes
.
each
do
|
key
,
essence
|
@nodes
[
key
]
=
create_node
(
key
,
essence
)
@nodes
[
key
]
=
create_node
(
key
,
essence
)
end
end
end
end
def
process_nodes!
def
process_nodes!
nodes
.
each
(
&
:process!
)
@nodes
.
each_value
(
&
:process!
)
end
end
def
create_node
(
key
,
essence
)
def
create_node
(
key
,
essence
)
...
...
spec/lib/gitlab/ci/config/node/global_spec.rb
View file @
6ae80732
...
@@ -31,24 +31,24 @@ describe Gitlab::Ci::Config::Node::Global do
...
@@ -31,24 +31,24 @@ describe Gitlab::Ci::Config::Node::Global do
before
{
global
.
process!
}
before
{
global
.
process!
}
it
'creates nodes hash'
do
it
'creates nodes hash'
do
expect
(
global
.
node
s
).
to
be_an
Array
expect
(
global
.
descendant
s
).
to
be_an
Array
end
end
it
'creates node object for each entry'
do
it
'creates node object for each entry'
do
expect
(
global
.
node
s
.
count
).
to
eq
9
expect
(
global
.
descendant
s
.
count
).
to
eq
9
end
end
it
'creates node object using valid class'
do
it
'creates node object using valid class'
do
expect
(
global
.
node
s
.
first
)
expect
(
global
.
descendant
s
.
first
)
.
to
be_an_instance_of
Gitlab
::
Ci
::
Config
::
Node
::
Script
.
to
be_an_instance_of
Gitlab
::
Ci
::
Config
::
Node
::
Script
expect
(
global
.
node
s
.
second
)
expect
(
global
.
descendant
s
.
second
)
.
to
be_an_instance_of
Gitlab
::
Ci
::
Config
::
Node
::
Image
.
to
be_an_instance_of
Gitlab
::
Ci
::
Config
::
Node
::
Image
end
end
it
'sets correct description for nodes'
do
it
'sets correct description for nodes'
do
expect
(
global
.
node
s
.
first
.
description
)
expect
(
global
.
descendant
s
.
first
.
description
)
.
to
eq
'Script that will be executed before each job.'
.
to
eq
'Script that will be executed before each job.'
expect
(
global
.
node
s
.
second
.
description
)
expect
(
global
.
descendant
s
.
second
.
description
)
.
to
eq
'Docker image that will be used to execute jobs.'
.
to
eq
'Docker image that will be used to execute jobs.'
end
end
end
end
...
@@ -139,11 +139,11 @@ describe Gitlab::Ci::Config::Node::Global do
...
@@ -139,11 +139,11 @@ describe Gitlab::Ci::Config::Node::Global do
describe
'#nodes'
do
describe
'#nodes'
do
it
'instantizes all nodes'
do
it
'instantizes all nodes'
do
expect
(
global
.
node
s
.
count
).
to
eq
9
expect
(
global
.
descendant
s
.
count
).
to
eq
9
end
end
it
'contains undefined nodes'
do
it
'contains undefined nodes'
do
expect
(
global
.
node
s
.
first
)
expect
(
global
.
descendant
s
.
first
)
.
to
be_an_instance_of
Gitlab
::
Ci
::
Config
::
Node
::
Undefined
.
to
be_an_instance_of
Gitlab
::
Ci
::
Config
::
Node
::
Undefined
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