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
fc00c545
Commit
fc00c545
authored
Jun 21, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle CI services config in new CI config classes
parent
cd6a2afb
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
82 additions
and
11 deletions
+82
-11
lib/ci/gitlab_ci_yaml_processor.rb
lib/ci/gitlab_ci_yaml_processor.rb
+2
-6
lib/gitlab/ci/config.rb
lib/gitlab/ci/config.rb
+1
-1
lib/gitlab/ci/config/node/global.rb
lib/gitlab/ci/config/node/global.rb
+3
-0
lib/gitlab/ci/config/node/services.rb
lib/gitlab/ci/config/node/services.rb
+22
-0
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+2
-2
spec/lib/gitlab/ci/config/node/global_spec.rb
spec/lib/gitlab/ci/config/node/global_spec.rb
+10
-2
spec/lib/gitlab/ci/config/node/services_spec.rb
spec/lib/gitlab/ci/config/node/services_spec.rb
+42
-0
No files found.
lib/ci/gitlab_ci_yaml_processor.rb
View file @
fc00c545
...
...
@@ -14,7 +14,7 @@ module Ci
ALLOWED_CACHE_KEYS
=
[
:key
,
:untracked
,
:paths
]
ALLOWED_ARTIFACTS_KEYS
=
[
:name
,
:untracked
,
:paths
,
:when
,
:expire_in
]
attr_reader
:after_script
,
:
services
,
:
path
,
:cache
attr_reader
:after_script
,
:path
,
:cache
def
initialize
(
config
,
path
=
nil
)
@ci_config
=
Gitlab
::
Ci
::
Config
.
new
(
config
)
...
...
@@ -68,7 +68,7 @@ module Ci
@after_script
=
@config
[
:after_script
]
@image
=
@config
[
:image
]
@services
=
@c
onfig
[
:services
]
@services
=
@c
i_config
.
services
@stages
=
@config
[
:stages
]
||
@config
[
:types
]
@variables
=
@config
[
:variables
]
||
{}
@cache
=
@config
[
:cache
]
...
...
@@ -127,10 +127,6 @@ module Ci
raise
ValidationError
,
"after_script should be an array of strings"
end
unless
@services
.
nil?
||
validate_array_of_strings
(
@services
)
raise
ValidationError
,
"services should be an array of strings"
end
unless
@stages
.
nil?
||
validate_array_of_strings
(
@stages
)
raise
ValidationError
,
"stages should be an array of strings"
end
...
...
lib/gitlab/ci/config.rb
View file @
fc00c545
...
...
@@ -7,7 +7,7 @@ module Gitlab
##
# Temporary delegations that should be removed after refactoring
#
delegate
:before_script
,
:image
,
to: :@global
delegate
:before_script
,
:image
,
:services
,
to: :@global
def
initialize
(
config
)
@config
=
Loader
.
new
(
config
).
load!
...
...
lib/gitlab/ci/config/node/global.rb
View file @
fc00c545
...
...
@@ -14,6 +14,9 @@ module Gitlab
allow_node
:image
,
Image
,
description:
'Docker image that will be used to execute jobs.'
allow_node
:services
,
Services
,
description:
'Docker images that will be linked to the container.'
end
end
end
...
...
lib/gitlab/ci/config/node/services.rb
0 → 100644
View file @
fc00c545
module
Gitlab
module
Ci
class
Config
module
Node
##
# Entry that represents a configuration of Docker services.
#
class
Services
<
Entry
include
Validatable
validations
do
validates
:config
,
array_of_strings:
true
end
def
value
@config
end
end
end
end
end
end
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
View file @
fc00c545
...
...
@@ -1007,14 +1007,14 @@ EOT
config
=
YAML
.
dump
({
services:
"test"
,
rspec:
{
script:
"test"
}
})
expect
do
GitlabCiYamlProcessor
.
new
(
config
,
path
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
services
should be an array of strings"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
Services config
should be an array of strings"
)
end
it
"returns errors if services parameter is not an array of strings"
do
config
=
YAML
.
dump
({
services:
[
10
,
"test"
],
rspec:
{
script:
"test"
}
})
expect
do
GitlabCiYamlProcessor
.
new
(
config
,
path
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
services
should be an array of strings"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
Services config
should be an array of strings"
)
end
it
"returns errors if job services parameter is not an array"
do
...
...
spec/lib/gitlab/ci/config/node/global_spec.rb
View file @
fc00c545
...
...
@@ -22,7 +22,8 @@ describe Gitlab::Ci::Config::Node::Global do
context
'when hash is valid'
do
let
(
:hash
)
do
{
before_script:
[
'ls'
,
'pwd'
],
image:
'ruby:2.2'
}
image:
'ruby:2.2'
,
services:
[
'postgres:9.1'
,
'mysql:5.5'
]
}
end
describe
'#process!'
do
...
...
@@ -33,7 +34,7 @@ describe Gitlab::Ci::Config::Node::Global do
end
it
'creates node object for each entry'
do
expect
(
global
.
nodes
.
count
).
to
eq
2
expect
(
global
.
nodes
.
count
).
to
eq
3
end
it
'creates node object using valid class'
do
...
...
@@ -56,6 +57,7 @@ describe Gitlab::Ci::Config::Node::Global do
expect
(
global
).
not_to
be_leaf
end
end
context
'when not processed'
do
describe
'#before_script'
do
it
'returns nil'
do
...
...
@@ -78,6 +80,12 @@ describe Gitlab::Ci::Config::Node::Global do
expect
(
global
.
image
).
to
eq
'ruby:2.2'
end
end
describe
'#services'
do
it
'returns array of services'
do
expect
(
global
.
services
).
to
eq
[
'postgres:9.1'
,
'mysql:5.5'
]
end
end
end
end
...
...
spec/lib/gitlab/ci/config/node/services_spec.rb
0 → 100644
View file @
fc00c545
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Services
do
let
(
:entry
)
{
described_class
.
new
(
config
)
}
describe
'#process!'
do
before
{
entry
.
process!
}
context
'when entry config value is correct'
do
let
(
:config
)
{
[
'postgres:9.1'
,
'mysql:5.5'
]
}
describe
'#value'
do
it
'returns array of services as is'
do
expect
(
entry
.
value
).
to
eq
config
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
let
(
:config
)
{
'ls'
}
describe
'#errors'
do
it
'saves errors'
do
expect
(
entry
.
errors
)
.
to
include
'Services config should be an array of strings'
end
end
describe
'#valid?'
do
it
'is not valid'
do
expect
(
entry
).
not_to
be_valid
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