Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
114c26cc
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,发现更多精彩内容 >>
提交
114c26cc
编写于
6月 04, 2018
作者:
G
Grzegorz Bizon
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Raise error if pipeline / stage hits unknown status
上级
93241149
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
61 addition
and
1 deletion
+61
-1
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+5
-1
app/models/ci/stage.rb
app/models/ci/stage.rb
+4
-0
app/models/concerns/has_status.rb
app/models/concerns/has_status.rb
+2
-0
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+37
-0
spec/models/ci/stage_spec.rb
spec/models/ci/stage_spec.rb
+13
-0
未找到文件。
app/models/ci/pipeline.rb
浏览文件 @
114c26cc
...
...
@@ -517,7 +517,8 @@ module Ci
def
update_status
retry_optimistic_lock
(
self
)
do
case
latest_builds_status
case
latest_builds_status
.
to_s
when
'created'
then
nil
when
'pending'
then
enqueue
when
'running'
then
run
when
'success'
then
succeed
...
...
@@ -525,6 +526,9 @@ module Ci
when
'canceled'
then
cancel
when
'skipped'
then
skip
when
'manual'
then
block
else
raise
HasStatus
::
UnknownStatusError
,
"Unknown status `
#{
latest_builds_status
}
`"
end
end
end
...
...
app/models/ci/stage.rb
浏览文件 @
114c26cc
...
...
@@ -68,6 +68,7 @@ module Ci
def
update_status
retry_optimistic_lock
(
self
)
do
case
statuses
.
latest
.
status
when
'created'
then
nil
when
'pending'
then
enqueue
when
'running'
then
run
when
'success'
then
succeed
...
...
@@ -75,6 +76,9 @@ module Ci
when
'canceled'
then
cancel
when
'manual'
then
block
when
'skipped'
,
nil
then
skip
else
raise
HasStatus
::
UnknownStatusError
,
"Unknown status `
#{
statuses
.
latest
.
status
}
`"
end
end
end
...
...
app/models/concerns/has_status.rb
浏览文件 @
114c26cc
...
...
@@ -11,6 +11,8 @@ module HasStatus
STATUSES_ENUM
=
{
created:
0
,
pending:
1
,
running:
2
,
success:
3
,
failed:
4
,
canceled:
5
,
skipped:
6
,
manual:
7
}.
freeze
UnknownStatusError
=
Class
.
new
(
StandardError
)
class_methods
do
def
status_sql
scope_relevant
=
respond_to?
(
:exclude_ignored
)
?
exclude_ignored
:
all
...
...
spec/models/ci/pipeline_spec.rb
浏览文件 @
114c26cc
...
...
@@ -1251,6 +1251,43 @@ describe Ci::Pipeline, :mailer do
end
end
describe
'#update_status'
do
context
'when pipeline is empty'
do
it
'updates does not change pipeline status'
do
expect
(
pipeline
.
statuses
.
latest
.
status
).
to
be_nil
expect
{
pipeline
.
update_status
}
.
to
change
{
pipeline
.
reload
.
status
}.
to
'skipped'
end
end
context
'when updating status to pending'
do
before
do
allow
(
pipeline
)
.
to
receive_message_chain
(
:statuses
,
:latest
,
:status
)
.
and_return
(
:running
)
end
it
'updates pipeline status to running'
do
expect
{
pipeline
.
update_status
}
.
to
change
{
pipeline
.
reload
.
status
}.
to
'running'
end
end
context
'when statuses status was not recognized'
do
before
do
allow
(
pipeline
)
.
to
receive
(
:latest_builds_status
)
.
and_return
(
:unknown
)
end
it
'raises an exception'
do
expect
{
pipeline
.
update_status
}
.
to
raise_error
(
HasStatus
::
UnknownStatusError
)
end
end
end
describe
'#detailed_status'
do
subject
{
pipeline
.
detailed_status
(
user
)
}
...
...
spec/models/ci/stage_spec.rb
浏览文件 @
114c26cc
...
...
@@ -110,6 +110,19 @@ describe Ci::Stage, :models do
expect
(
stage
.
reload
).
to
be_failed
end
end
context
'when statuses status was not recognized'
do
before
do
allow
(
stage
)
.
to
receive_message_chain
(
:statuses
,
:latest
,
:status
)
.
and_return
(
:unknown
)
end
it
'raises an exception'
do
expect
{
stage
.
update_status
}
.
to
raise_error
(
HasStatus
::
UnknownStatusError
)
end
end
end
describe
'#detailed_status'
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录