Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
9b5a912f
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,发现更多精彩内容 >>
提交
9b5a912f
编写于
3月 21, 2018
作者:
G
Grzegorz Bizon
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Make it easier to test pipeline stage seeds
上级
b82de0f0
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
39 addition
and
36 deletion
+39
-36
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+3
-0
lib/gitlab/ci/pipeline/chain/create.rb
lib/gitlab/ci/pipeline/chain/create.rb
+4
-6
lib/gitlab/ci/pipeline/chain/populate.rb
lib/gitlab/ci/pipeline/chain/populate.rb
+4
-3
lib/gitlab/ci/pipeline/chain/validate/config.rb
lib/gitlab/ci/pipeline/chain/validate/config.rb
+1
-1
lib/gitlab/ci/pipeline/seed/build.rb
lib/gitlab/ci/pipeline/seed/build.rb
+4
-0
lib/gitlab/ci/pipeline/seed/stage.rb
lib/gitlab/ci/pipeline/seed/stage.rb
+4
-7
spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb
spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb
+11
-11
spec/lib/gitlab/ci/yaml_processor_spec.rb
spec/lib/gitlab/ci/yaml_processor_spec.rb
+8
-8
未找到文件。
app/models/ci/pipeline.rb
浏览文件 @
9b5a912f
...
...
@@ -381,6 +381,9 @@ module Ci
end
end
##
# TODO, setting yaml_errors should be moved to the pipeline creation chain.
#
def
config_processor
return
unless
ci_yaml_file
return
@config_processor
if
defined?
(
@config_processor
)
...
...
lib/gitlab/ci/pipeline/chain/create.rb
浏览文件 @
9b5a912f
...
...
@@ -9,16 +9,14 @@ module Gitlab
::
Ci
::
Pipeline
.
transaction
do
pipeline
.
save!
# TODO populate environments with find_or_initialize_by in the chain too.
##
# Create the environment before the build starts. This sets its slug and
# makes it available as an environment variable
# Create environments before the pipeline starts.
#
pipeline
.
builds
.
each
do
|
build
|
if
build
.
has_environment?
environment_name
=
build
.
expanded_environment_name
project
.
environments
.
find_or_create_by
(
name:
environment_name
)
project
.
environments
.
find_or_create_by
(
name:
build
.
expanded_environment_name
)
end
end
end
...
...
lib/gitlab/ci/pipeline/chain/populate.rb
浏览文件 @
9b5a912f
...
...
@@ -9,12 +9,13 @@ module Gitlab
def
perform!
##
# Populate pipeline with seeds block.
#
# It comes from a block argument to CreatePipelineService#execute.
# Populate pipeline with block `CreatePipelineService#execute`.
#
@command
.
seeds_block
&
.
call
(
pipeline
)
##
# Populate pipeline with all stages and builds.
#
pipeline
.
stage_seeds
.
each
do
|
seed
|
seed
.
user
=
current_user
...
...
lib/gitlab/ci/pipeline/chain/validate/config.rb
浏览文件 @
9b5a912f
...
...
@@ -16,7 +16,7 @@ module Gitlab
@pipeline
.
drop!
(
:config_error
)
end
return
error
(
@pipeline
.
yaml_errors
)
error
(
@pipeline
.
yaml_errors
)
end
end
...
...
lib/gitlab/ci/pipeline/seed/build.rb
浏览文件 @
9b5a912f
...
...
@@ -3,6 +3,10 @@ module Gitlab
module
Pipeline
module
Seed
class
Build
<
Seed
::
Base
attr_reader
:pipeline
,
:attributes
delegate
:dig
,
to: :attributes
def
initialize
(
pipeline
,
attributes
)
@pipeline
=
pipeline
@attributes
=
attributes
...
...
lib/gitlab/ci/pipeline/seed/stage.rb
浏览文件 @
9b5a912f
...
...
@@ -3,7 +3,10 @@ module Gitlab
module
Pipeline
module
Seed
class
Stage
<
Seed
::
Base
delegate
:size
,
to: :@seeds
attr_reader
:pipeline
,
:seeds
delegate
:size
,
to: :seeds
delegate
:dig
,
to: :seeds
def
initialize
(
pipeline
,
name
,
builds
)
@pipeline
=
pipeline
...
...
@@ -24,12 +27,6 @@ module Gitlab
project:
@pipeline
.
project
}
end
# TODO decouple
#
def
builds_attributes
@seeds
.
map
(
&
:attributes
)
end
def
to_resource
::
Ci
::
Stage
.
new
(
attributes
).
tap
do
|
stage
|
@seeds
.
each
do
|
seed
|
...
...
spec/lib/gitlab/ci/pipeline/seed/stage_spec.rb
浏览文件 @
9b5a912f
...
...
@@ -17,20 +17,20 @@ describe Gitlab::Ci::Pipeline::Seed::Stage do
end
end
describe
'#
stage_
attributes'
do
describe
'#attributes'
do
it
'returns hash attributes of a stage'
do
expect
(
subject
.
attributes
).
to
be_a
Hash
expect
(
subject
.
attributes
).
to
include
(
:name
,
:project
)
end
end
describe
'#
builds_attribute
s'
do
describe
'#
seed
s'
do
it
'returns hash attributes of all builds'
do
expect
(
subject
.
builds_attribute
s
.
size
).
to
eq
2
expect
(
subject
.
builds_attributes
).
to
all
(
include
(
ref:
'master'
))
expect
(
subject
.
builds_attributes
).
to
all
(
include
(
tag:
false
))
expect
(
subject
.
builds_attributes
).
to
all
(
include
(
project:
pipeline
.
project
))
expect
(
subject
.
builds_attributes
)
expect
(
subject
.
seed
s
.
size
).
to
eq
2
expect
(
subject
.
seeds
.
map
(
&
:attributes
)
).
to
all
(
include
(
ref:
'master'
))
expect
(
subject
.
seeds
.
map
(
&
:attributes
)
).
to
all
(
include
(
tag:
false
))
expect
(
subject
.
seeds
.
map
(
&
:attributes
)
).
to
all
(
include
(
project:
pipeline
.
project
))
expect
(
subject
.
seeds
.
map
(
&
:attributes
)
)
.
to
all
(
include
(
trigger_request:
pipeline
.
trigger_requests
.
first
))
end
...
...
@@ -40,17 +40,17 @@ describe Gitlab::Ci::Pipeline::Seed::Stage do
end
it
'returns protected builds'
do
expect
(
subject
.
builds_attributes
).
to
all
(
include
(
protected:
true
))
expect
(
subject
.
seeds
.
map
(
&
:attributes
)
).
to
all
(
include
(
protected:
true
))
end
end
context
'when a ref is
un
protected'
do
context
'when a ref is
not
protected'
do
before
do
allow_any_instance_of
(
Project
).
to
receive
(
:protected_for?
).
and_return
(
false
)
end
it
'returns unprotected builds'
do
expect
(
subject
.
builds_attributes
).
to
all
(
include
(
protected:
false
))
expect
(
subject
.
seeds
.
map
(
&
:attributes
)
).
to
all
(
include
(
protected:
false
))
end
end
end
...
...
@@ -61,7 +61,7 @@ describe Gitlab::Ci::Pipeline::Seed::Stage do
it
'assignes relevant pipeline attributes'
do
subject
.
user
=
user
expect
(
subject
.
builds_attributes
).
to
all
(
include
(
user:
user
))
expect
(
subject
.
seeds
.
map
(
&
:attributes
)
).
to
all
(
include
(
user:
user
))
end
end
...
...
spec/lib/gitlab/ci/yaml_processor_spec.rb
浏览文件 @
9b5a912f
...
...
@@ -121,9 +121,9 @@ module Gitlab
expect
(
seeds
.
size
).
to
eq
2
expect
(
seeds
.
first
.
attributes
[
:name
]).
to
eq
'test'
expect
(
seeds
.
second
.
attributes
[
:name
]).
to
eq
'deploy'
expect
(
seeds
.
first
.
builds_attributes
.
dig
(
0
,
:name
)).
to
eq
'rspec'
expect
(
seeds
.
first
.
builds_attributes
.
dig
(
1
,
:name
)).
to
eq
'spinach'
expect
(
seeds
.
second
.
builds_attributes
.
dig
(
0
,
:name
)).
to
eq
'production'
expect
(
seeds
.
dig
(
0
,
0
,
:name
)).
to
eq
'rspec'
expect
(
seeds
.
dig
(
0
,
1
,
:name
)).
to
eq
'spinach'
expect
(
seeds
.
dig
(
1
,
0
,
:name
)).
to
eq
'production'
end
end
...
...
@@ -142,7 +142,7 @@ module Gitlab
expect
(
seeds
.
size
).
to
eq
1
expect
(
seeds
.
first
.
attributes
[
:name
]).
to
eq
'test'
expect
(
seeds
.
first
.
builds_attributes
.
dig
(
0
,
:name
)).
to
eq
'spinach'
expect
(
seeds
.
dig
(
0
,
0
,
:name
)).
to
eq
'spinach'
end
end
...
...
@@ -161,7 +161,7 @@ module Gitlab
expect
(
seeds
.
size
).
to
eq
1
expect
(
seeds
.
first
.
attributes
[
:name
]).
to
eq
'test'
expect
(
seeds
.
first
.
builds_attributes
.
dig
(
0
,
:name
)).
to
eq
'spinach'
expect
(
seeds
.
dig
(
0
,
0
,
:name
)).
to
eq
'spinach'
end
end
...
...
@@ -183,8 +183,8 @@ module Gitlab
seeds
=
subject
.
stage_seeds
(
pipeline
)
expect
(
seeds
.
size
).
to
eq
2
expect
(
seeds
.
first
.
builds_attributes
.
dig
(
0
,
:name
)).
to
eq
'spinach'
expect
(
seeds
.
second
.
builds_attributes
.
dig
(
0
,
:name
)).
to
eq
'production'
expect
(
seeds
.
dig
(
0
,
0
,
:name
)).
to
eq
'spinach'
expect
(
seeds
.
dig
(
1
,
0
,
:name
)).
to
eq
'production'
end
end
...
...
@@ -209,7 +209,7 @@ module Gitlab
seeds
=
subject
.
stage_seeds
(
pipeline
)
expect
(
seeds
.
size
).
to
eq
1
expect
(
seeds
.
first
.
builds_attributes
.
dig
(
0
,
:name
)).
to
eq
'spinach'
expect
(
seeds
.
dig
(
0
,
0
,
:name
)).
to
eq
'spinach'
end
end
end
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录