Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
fc00c545
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
fc00c545
编写于
6月 21, 2016
作者:
G
Grzegorz Bizon
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Handle CI services config in new CI config classes
上级
cd6a2afb
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
82 addition
and
11 deletion
+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
未找到文件。
lib/ci/gitlab_ci_yaml_processor.rb
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
浏览文件 @
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
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录