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
Léo-Paul Géneau
gitlab-ce
Commits
5b7f211c
Commit
5b7f211c
authored
Jul 05, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new CI config entry that holds jobs definition
parent
9686a4f2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
11 deletions
+61
-11
lib/gitlab/ci/config/node/global.rb
lib/gitlab/ci/config/node/global.rb
+5
-9
lib/gitlab/ci/config/node/jobs.rb
lib/gitlab/ci/config/node/jobs.rb
+18
-0
spec/lib/gitlab/ci/config/node/global_spec.rb
spec/lib/gitlab/ci/config/node/global_spec.rb
+2
-2
spec/lib/gitlab/ci/config/node/jobs_spec.rb
spec/lib/gitlab/ci/config/node/jobs_spec.rb
+36
-0
No files found.
lib/gitlab/ci/config/node/global.rb
View file @
5b7f211c
...
@@ -33,11 +33,14 @@ module Gitlab
...
@@ -33,11 +33,14 @@ module Gitlab
node
:cache
,
Node
::
Cache
,
node
:cache
,
Node
::
Cache
,
description:
'Configure caching between build jobs.'
description:
'Configure caching between build jobs.'
node
:jobs
,
Node
::
Jobs
,
description:
'Definition of jobs for this pipeline.'
helpers
:before_script
,
:image
,
:services
,
:after_script
,
helpers
:before_script
,
:image
,
:services
,
:after_script
,
:variables
,
:stages
,
:types
,
:cache
:variables
,
:stages
,
:types
,
:cache
,
:jobs
def
initialize
(
config
)
def
initialize
(
config
)
return
super
(
config
)
unless
config
.
is_a?
(
Hash
)
return
super
unless
config
.
is_a?
(
Hash
)
jobs
=
config
.
except
(
*
self
.
class
.
nodes
.
keys
)
jobs
=
config
.
except
(
*
self
.
class
.
nodes
.
keys
)
global
=
config
.
slice
(
*
self
.
class
.
nodes
.
keys
)
global
=
config
.
slice
(
*
self
.
class
.
nodes
.
keys
)
...
@@ -45,13 +48,6 @@ module Gitlab
...
@@ -45,13 +48,6 @@ module Gitlab
super
(
global
.
merge
(
jobs:
jobs
))
super
(
global
.
merge
(
jobs:
jobs
))
end
end
##
# Temporary refactoring stub
#
def
jobs
@config
[
:jobs
]
end
def
stages
def
stages
stages_defined?
?
stages_value
:
types_value
stages_defined?
?
stages_value
:
types_value
end
end
...
...
lib/gitlab/ci/config/node/jobs.rb
0 → 100644
View file @
5b7f211c
module
Gitlab
module
Ci
class
Config
module
Node
##
# Entry that represents a set of jobs.
#
class
Jobs
<
Entry
include
Validatable
validations
do
validates
:config
,
type:
Hash
end
end
end
end
end
end
spec/lib/gitlab/ci/config/node/global_spec.rb
View file @
5b7f211c
...
@@ -35,7 +35,7 @@ describe Gitlab::Ci::Config::Node::Global do
...
@@ -35,7 +35,7 @@ describe Gitlab::Ci::Config::Node::Global do
end
end
it
'creates node object for each entry'
do
it
'creates node object for each entry'
do
expect
(
global
.
nodes
.
count
).
to
eq
8
expect
(
global
.
nodes
.
count
).
to
eq
9
end
end
it
'creates node object using valid class'
do
it
'creates node object using valid class'
do
...
@@ -139,7 +139,7 @@ describe Gitlab::Ci::Config::Node::Global do
...
@@ -139,7 +139,7 @@ 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
.
nodes
.
count
).
to
eq
8
expect
(
global
.
nodes
.
count
).
to
eq
9
end
end
it
'contains undefined nodes'
do
it
'contains undefined nodes'
do
...
...
spec/lib/gitlab/ci/config/node/jobs_spec.rb
0 → 100644
View file @
5b7f211c
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Jobs
do
let
(
:entry
)
{
described_class
.
new
(
config
)
}
describe
'validations'
do
context
'when entry config value is correct'
do
let
(
:config
)
{
{
rspec:
{
script:
'rspec'
}
}
}
describe
'#value'
do
it
'returns key value'
do
expect
(
entry
.
value
).
to
eq
(
rspec:
{
script:
'rspec'
})
end
end
describe
'#valid?'
do
it
'is valid'
do
expect
(
entry
).
to
be_valid
end
end
end
context
'when entry value is not correct'
do
context
'incorrect config value type'
do
let
(
:config
)
{
[
'incorrect'
]
}
describe
'#errors'
do
it
'saves errors'
do
expect
(
entry
.
errors
)
.
to
include
'jobs config should be a hash'
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