Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
940763e0
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,发现更多精彩内容 >>
提交
940763e0
编写于
6月 06, 2016
作者:
G
Grzegorz Bizon
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use CI config errors from new processor in legacy one
上级
a3c07455
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
46 addition
and
14 deletion
+46
-14
lib/ci/gitlab_ci_yaml_processor.rb
lib/ci/gitlab_ci_yaml_processor.rb
+7
-5
lib/gitlab/ci/config.rb
lib/gitlab/ci/config.rb
+4
-0
lib/gitlab/ci/config/node/entry.rb
lib/gitlab/ci/config/node/entry.rb
+1
-1
spec/lib/gitlab/ci/config_spec.rb
spec/lib/gitlab/ci/config_spec.rb
+34
-8
未找到文件。
lib/ci/gitlab_ci_yaml_processor.rb
浏览文件 @
940763e0
...
...
@@ -14,7 +14,9 @@ module Ci
attr_reader
:before_script
,
:after_script
,
:image
,
:services
,
:path
,
:cache
def
initialize
(
config
,
path
=
nil
)
@config
=
Gitlab
::
Ci
::
Config
.
new
(
config
).
to_hash
@ci_config
=
Gitlab
::
Ci
::
Config
.
new
(
config
)
@config
=
@ci_config
.
to_hash
@path
=
path
initial_parsing
...
...
@@ -99,6 +101,10 @@ module Ci
end
def
validate!
unless
@ci_config
.
valid?
raise
ValidationError
,
@ci_config
.
errors
.
first
end
validate_global!
@jobs
.
each
do
|
name
,
job
|
...
...
@@ -109,10 +115,6 @@ module Ci
end
def
validate_global!
unless
validate_array_of_strings
(
@before_script
)
raise
ValidationError
,
"before_script should be an array of strings"
end
unless
@after_script
.
nil?
||
validate_array_of_strings
(
@after_script
)
raise
ValidationError
,
"after_script should be an array of strings"
end
...
...
lib/gitlab/ci/config.rb
浏览文件 @
940763e0
...
...
@@ -3,6 +3,8 @@ module Gitlab
class
Config
class
LoaderError
<
StandardError
;
end
delegate
:valid?
,
:errors
,
to: :@global
def
initialize
(
config
)
loader
=
Loader
.
new
(
config
)
...
...
@@ -11,6 +13,8 @@ module Gitlab
end
@config
=
loader
.
load
@global
=
Node
::
Global
.
new
(
@config
,
self
)
@global
.
process!
end
def
to_hash
...
...
lib/gitlab/ci/config/node/entry.rb
浏览文件 @
940763e0
...
...
@@ -18,7 +18,7 @@ module Gitlab
def
process!
keys
.
each_pair
do
|
key
,
entry
|
next
unless
@value
.
include?
(
key
)
@nodes
[
key
]
=
entry
.
new
(
@value
[
key
],
config
,
self
)
@nodes
[
key
]
=
entry
.
new
(
@value
[
key
],
@
config
,
self
)
end
nodes
.
each
(
&
:process!
)
...
...
spec/lib/gitlab/ci/config_spec.rb
浏览文件 @
940763e0
...
...
@@ -29,17 +29,43 @@ describe Gitlab::Ci::Config do
expect
(
config
.
to_hash
).
to
eq
hash
end
describe
'#valid?'
do
it
'is valid'
do
expect
(
config
).
to
be_valid
end
it
'has no errors'
do
expect
(
config
.
errors
).
to
be_empty
end
end
end
context
'when config is invalid'
do
let
(
:yml
)
{
'// invalid'
}
describe
'.new'
do
it
'raises error'
do
expect
{
config
}.
to
raise_error
(
Gitlab
::
Ci
::
Config
::
LoaderError
,
/Invalid configuration format/
)
context
'when yml is incorrect'
do
let
(
:yml
)
{
'// invalid'
}
describe
'.new'
do
it
'raises error'
do
expect
{
config
}.
to
raise_error
(
Gitlab
::
Ci
::
Config
::
LoaderError
,
/Invalid configuration format/
)
end
end
end
context
'when config logic is incorrect'
do
let
(
:yml
)
{
'before_script: "ls"'
}
describe
'#valid?'
do
it
'is not valid'
do
expect
(
config
).
not_to
be_valid
end
it
'has errors'
do
expect
(
config
.
errors
).
not_to
be_empty
end
end
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录