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
8048dcc8
Commit
8048dcc8
authored
Jun 06, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement CI configuration nodes tree processing
parent
7f2f683e
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
10 deletions
+58
-10
lib/gitlab/ci/config/node/before_script.rb
lib/gitlab/ci/config/node/before_script.rb
+5
-2
lib/gitlab/ci/config/node/entry.rb
lib/gitlab/ci/config/node/entry.rb
+20
-2
lib/gitlab/ci/config/node/global.rb
lib/gitlab/ci/config/node/global.rb
+3
-0
spec/lib/gitlab/ci/config/node/before_script_spec.rb
spec/lib/gitlab/ci/config/node/before_script_spec.rb
+0
-6
spec/lib/gitlab/ci/config/node/global_spec.rb
spec/lib/gitlab/ci/config/node/global_spec.rb
+30
-0
No files found.
lib/gitlab/ci/config/node/before_script.rb
View file @
8048dcc8
...
...
@@ -3,8 +3,11 @@ module Gitlab
class
Config
module
Node
class
BeforeScript
<
Entry
def
leaf?
true
def
keys
{}
end
def
validate!
end
end
end
...
...
lib/gitlab/ci/config/node/entry.rb
View file @
8048dcc8
...
...
@@ -3,14 +3,32 @@ module Gitlab
class
Config
module
Node
class
Entry
attr_reader
:hash
,
:config
,
:parent
,
:nodes
,
:errors
def
initialize
(
hash
,
config
,
parent
=
nil
)
@hash
=
hash
@config
=
config
@parent
=
parent
@nodes
=
{}
@errors
=
[]
end
def
process!
keys
.
each_pair
do
|
key
,
entry
|
next
unless
hash
.
include?
(
key
)
@nodes
[
key
]
=
entry
.
new
(
hash
[
key
],
config
,
self
)
end
@nodes
.
values
.
each
(
&
:process!
)
@nodes
.
values
.
each
(
&
:validate!
)
end
def
keys
raise
NotImplementedError
end
def
allowed_keys
[]
def
validate!
raise
NotImplementedError
end
end
end
...
...
lib/gitlab/ci/config/node/global.rb
View file @
8048dcc8
...
...
@@ -3,6 +3,9 @@ module Gitlab
class
Config
module
Node
class
Global
<
Entry
def
keys
{
before_script:
BeforeScript
}
end
end
end
end
...
...
spec/lib/gitlab/ci/config/node/before_script_spec.rb
View file @
8048dcc8
...
...
@@ -2,10 +2,4 @@ require 'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
BeforeScript
do
let
(
:entry
)
{
described_class
.
new
(
hash
,
config
)
}
describe
'#leaf?'
do
it
'is a leaf entry'
do
expect
(
entry
).
to
be_leaf
end
end
end
spec/lib/gitlab/ci/config/node/global_spec.rb
View file @
8048dcc8
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Global
do
let
(
:global
)
{
described_class
.
new
(
hash
,
config
)
}
let
(
:config
)
{
double
(
'Config'
)
}
describe
'#keys'
do
it
'can contain global config keys'
do
expect
(
global
.
keys
).
to
include
:before_script
end
end
context
'when hash is valid'
do
let
(
:hash
)
do
{
before_script:
[
'ls'
,
'pwd'
]
}
end
describe
'#process!'
do
before
{
global
.
process!
}
it
'creates nodes hash'
do
expect
(
global
.
nodes
).
to
be_a
Hash
end
it
'creates node object for each entry'
do
expect
(
global
.
nodes
.
count
).
to
eq
1
end
it
'creates node object using valid class'
do
expect
(
global
.
nodes
[
:before_script
])
.
to
be_an_instance_of
Gitlab
::
Ci
::
Config
::
Node
::
BeforeScript
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