Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
ccbdb402
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,发现更多精彩内容 >>
提交
ccbdb402
编写于
7月 09, 2016
作者:
G
Grzegorz Bizon
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Integrate CI job stage entry into CI configuration
上级
1b624ba4
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
68 addition
and
25 deletion
+68
-25
lib/gitlab/ci/config/node/entry.rb
lib/gitlab/ci/config/node/entry.rb
+12
-6
lib/gitlab/ci/config/node/job.rb
lib/gitlab/ci/config/node/job.rb
+24
-0
lib/gitlab/ci/config/node/stage.rb
lib/gitlab/ci/config/node/stage.rb
+2
-2
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+3
-3
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/job_spec.rb
spec/lib/gitlab/ci/config/node/job_spec.rb
+10
-2
spec/lib/gitlab/ci/config/node/jobs_spec.rb
spec/lib/gitlab/ci/config/node/jobs_spec.rb
+4
-3
spec/lib/gitlab/ci/config/node/stage_spec.rb
spec/lib/gitlab/ci/config/node/stage_spec.rb
+11
-7
未找到文件。
lib/gitlab/ci/config/node/entry.rb
浏览文件 @
ccbdb402
...
...
@@ -20,21 +20,21 @@ module Gitlab
end
@validator
=
self
.
class
.
validator
.
new
(
self
)
@validator
.
validate
@validator
.
validate
(
:new
)
end
def
process!
return
unless
valid?
nodes
.
each
do
|
key
,
essence
|
@entries
[
key
]
=
create
(
key
,
essence
)
end
compose!
@entries
.
each_value
(
&
:process!
)
end
def
validate!
@validator
.
validate
(
:processed
)
if
@validator
.
valid?
(
:new
)
@validator
.
validate
(
:processed
)
end
@entries
.
each_value
(
&
:validate!
)
end
...
...
@@ -95,6 +95,12 @@ module Gitlab
private
def
compose!
nodes
.
each
do
|
key
,
essence
|
@entries
[
key
]
=
create
(
key
,
essence
)
end
end
def
create
(
entry
,
essence
)
raise
NotImplementedError
end
...
...
lib/gitlab/ci/config/node/job.rb
浏览文件 @
ccbdb402
...
...
@@ -7,6 +7,30 @@ module Gitlab
#
class
Job
<
Entry
include
Configurable
node
:stage
,
Stage
,
description:
'Pipeline stage this job will be executed into.'
node
:type
,
Stage
,
description:
'Deprecated: stage this job will be executed into.'
helpers
:stage
,
:type
def
value
@config
.
merge
(
stage:
stage_value
)
end
private
def
compose!
super
if
type_defined?
&&
!
stage_defined?
@entries
[
:stage
]
=
@entries
[
:type
]
end
@entries
.
delete
(
:type
)
end
end
end
end
...
...
lib/gitlab/ci/config/node/stage.rb
浏览文件 @
ccbdb402
...
...
@@ -9,7 +9,7 @@ module Gitlab
include
Validatable
validations
do
validates
:config
,
key:
true
validates
:config
,
type:
String
validates
:global
,
required_attribute:
true
validate
:known_stage
,
on: :processed
...
...
@@ -27,7 +27,7 @@ module Gitlab
end
def
self
.
default
:test
'test'
end
end
end
...
...
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
浏览文件 @
ccbdb402
...
...
@@ -1082,21 +1082,21 @@ EOT
config
=
YAML
.
dump
({
rspec:
{
script:
"test"
,
type:
1
}
})
expect
do
GitlabCiYamlProcessor
.
new
(
config
,
path
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
rspec job: stage parameter should be build, test, deploy
"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
jobs:rspec:type config should be a string
"
)
end
it
"returns errors if job stage is not a pre-defined stage"
do
config
=
YAML
.
dump
({
rspec:
{
script:
"test"
,
type:
"acceptance"
}
})
expect
do
GitlabCiYamlProcessor
.
new
(
config
,
path
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
rspec job: stage parameter should be build, test, deploy
"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
jobs:rspec:type config should be one of defined stages (build, test, deploy)
"
)
end
it
"returns errors if job stage is not a defined stage"
do
config
=
YAML
.
dump
({
types:
[
"build"
,
"test"
],
rspec:
{
script:
"test"
,
type:
"acceptance"
}
})
expect
do
GitlabCiYamlProcessor
.
new
(
config
,
path
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
rspec job: stage parameter should be build, test
"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
jobs:rspec:type config should be one of defined stages (build, test)
"
)
end
it
"returns errors if stages is not an array"
do
...
...
spec/lib/gitlab/ci/config/node/global_spec.rb
浏览文件 @
ccbdb402
...
...
@@ -129,8 +129,8 @@ describe Gitlab::Ci::Config::Node::Global do
describe
'#jobs'
do
it
'returns jobs configuration'
do
expect
(
global
.
jobs
)
.
to
eq
(
rspec:
{
script:
'rspec'
},
spinach:
{
script:
'spinach'
})
.
to
eq
(
rspec:
{
script:
'rspec'
,
stage:
'test'
},
spinach:
{
script:
'spinach'
,
stage:
'test'
})
end
end
end
...
...
spec/lib/gitlab/ci/config/node/job_spec.rb
浏览文件 @
ccbdb402
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Job
do
let
(
:entry
)
{
described_class
.
new
(
config
)
}
let
(
:entry
)
{
described_class
.
new
(
config
,
global:
global
)
}
let
(
:global
)
{
spy
(
'Global'
)
}
describe
'validations'
do
before
do
entry
.
process!
entry
.
validate!
end
context
'when entry config value is correct'
do
let
(
:config
)
{
{
script:
'rspec'
}
}
describe
'#value'
do
it
'returns key value'
do
expect
(
entry
.
value
).
to
eq
(
script:
'rspec'
)
expect
(
entry
.
value
)
.
to
eq
(
script:
'rspec'
,
stage:
'test'
)
end
end
...
...
spec/lib/gitlab/ci/config/node/jobs_spec.rb
浏览文件 @
ccbdb402
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Jobs
do
let
(
:entry
)
{
described_class
.
new
(
config
)
}
let
(
:entry
)
{
described_class
.
new
(
config
,
global:
spy
)
}
describe
'validations'
do
context
'when entry config value is correct'
do
...
...
@@ -61,8 +61,9 @@ describe Gitlab::Ci::Config::Node::Jobs do
describe
'#value'
do
it
'returns key value'
do
expect
(
entry
.
value
).
to
eq
(
rspec:
{
script:
'rspec'
},
spinach:
{
script:
'spinach'
})
expect
(
entry
.
value
)
.
to
eq
(
rspec:
{
script:
'rspec'
,
stage:
'test'
},
spinach:
{
script:
'spinach'
,
stage:
'test'
})
end
end
...
...
spec/lib/gitlab/ci/config/node/stage_spec.rb
浏览文件 @
ccbdb402
...
...
@@ -6,7 +6,11 @@ describe Gitlab::Ci::Config::Node::Stage do
describe
'validations'
do
context
'when stage config value is correct'
do
let
(
:config
)
{
:build
}
let
(
:config
)
{
'build'
}
before
do
allow
(
global
).
to
receive
(
:stages
).
and_return
(
%w[build]
)
end
describe
'#value'
do
it
'returns a stage key'
do
...
...
@@ -39,16 +43,16 @@ describe Gitlab::Ci::Config::Node::Stage do
it
'reports errors about wrong type'
do
expect
(
stage
.
errors
)
.
to
include
'stage config should be a string
or symbol
'
.
to
include
'stage config should be a string'
end
end
context
'when stage is not present in global configuration'
do
let
(
:config
)
{
:unknown
}
let
(
:config
)
{
'unknown'
}
before
do
allow
(
global
)
.
to
receive
(
:stages
).
and_return
(
[
:test
,
:
deploy
])
.
to
receive
(
:stages
).
and_return
(
%w[test
deploy]
)
end
it
'reports error about missing stage'
do
...
...
@@ -65,7 +69,7 @@ describe Gitlab::Ci::Config::Node::Stage do
describe
'#known?'
do
before
do
allow
(
global
).
to
receive
(
:stages
).
and_return
(
[
:test
,
:
deploy
])
allow
(
global
).
to
receive
(
:stages
).
and_return
(
%w[test
deploy]
)
end
context
'when stage is not known'
do
...
...
@@ -77,7 +81,7 @@ describe Gitlab::Ci::Config::Node::Stage do
end
context
'when stage is known'
do
let
(
:config
)
{
:test
}
let
(
:config
)
{
'test'
}
it
'returns false'
do
expect
(
stage
.
known?
).
to
be
true
...
...
@@ -87,7 +91,7 @@ describe Gitlab::Ci::Config::Node::Stage do
describe
'.default'
do
it
'returns default stage'
do
expect
(
described_class
.
default
).
to
eq
:test
expect
(
described_class
.
default
).
to
eq
'test'
end
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录