Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
56449cc6
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,体验更适合开发者的 AI 搜索 >>
提交
56449cc6
编写于
2月 19, 2016
作者:
K
Kamil Trzcinski
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix Merge When Succeeded for multiple stages
Use around_transition to trigger build creation for next stages
上级
2cc9a42c
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
46 addition
and
10 deletion
+46
-10
CHANGELOG
CHANGELOG
+1
-0
app/models/ci/build.rb
app/models/ci/build.rb
+9
-4
app/models/commit_status.rb
app/models/commit_status.rb
+6
-6
spec/services/merge_requests/merge_when_build_succeeds_service_spec.rb
.../merge_requests/merge_when_build_succeeds_service_spec.rb
+30
-0
未找到文件。
CHANGELOG
浏览文件 @
56449cc6
...
...
@@ -52,6 +52,7 @@ v 8.5.0 (unreleased)
- Improve UI consistency between projects and groups lists
- Add sort dropdown to dashboard projects page
- Fixed logo animation on Safari (Roman Rott)
- Fix Merge When Succeeded when multiple stages
- Hide remove source branch button when the MR is merged but new commits are pushed (Zeger-Jan van de Weg)
- In seach autocomplete show only groups and projects you are member of
- Don't process cross-reference notes from forks
...
...
app/models/ci/build.rb
浏览文件 @
56449cc6
...
...
@@ -107,15 +107,18 @@ module Ci
end
state_machine
:status
,
initial: :pending
do
after_transition
pending: :running
do
|
build
,
transition
|
after_transition
pending: :running
do
|
build
|
build
.
execute_hooks
end
after_transition
any
=>
[
:success
,
:failed
,
:canceled
]
do
|
build
,
transition
|
return
unless
build
.
project
# We use around_transition to create builds for next stage as soon as possible, before the `after_*` is executed
around_transition
any
=>
[
:success
,
:failed
,
:canceled
]
do
|
build
,
block
|
block
.
call
build
.
commit
.
create_next_builds
(
build
)
if
build
.
commit
end
after_transition
any
=>
[
:success
,
:failed
,
:canceled
]
do
|
build
|
build
.
update_coverage
build
.
commit
.
create_next_builds
(
build
)
build
.
execute_hooks
end
end
...
...
@@ -179,6 +182,7 @@ module Ci
end
def
update_coverage
return
unless
project
coverage_regex
=
project
.
build_coverage_regex
return
unless
coverage_regex
coverage
=
extract_coverage
(
trace
,
coverage_regex
)
...
...
@@ -334,6 +338,7 @@ module Ci
end
def
execute_hooks
return
unless
project
build_data
=
Gitlab
::
BuildDataBuilder
.
build
(
self
)
project
.
execute_hooks
(
build_data
.
dup
,
:build_hooks
)
project
.
execute_services
(
build_data
.
dup
,
:build_hooks
)
...
...
app/models/commit_status.rb
浏览文件 @
56449cc6
...
...
@@ -75,16 +75,16 @@ class CommitStatus < ActiveRecord::Base
transition
[
:pending
,
:running
]
=>
:canceled
end
after_transition
pending: :running
do
|
build
,
transition
|
build
.
update_attributes
started_at:
Time
.
now
after_transition
pending: :running
do
|
commit_status
|
commit_status
.
update_attributes
started_at:
Time
.
now
end
after_transition
any
=>
[
:success
,
:failed
,
:canceled
]
do
|
build
,
transition
|
build
.
update_attributes
finished_at:
Time
.
now
after_transition
any
=>
[
:success
,
:failed
,
:canceled
]
do
|
commit_status
|
commit_status
.
update_attributes
finished_at:
Time
.
now
end
after_transition
[
:pending
,
:running
]
=>
:success
do
|
build
,
transition
|
MergeRequests
::
MergeWhenBuildSucceedsService
.
new
(
build
.
commit
.
project
,
nil
).
trigger
(
build
)
after_transition
[
:pending
,
:running
]
=>
:success
do
|
commit_status
|
MergeRequests
::
MergeWhenBuildSucceedsService
.
new
(
commit_status
.
commit
.
project
,
nil
).
trigger
(
commit_status
)
end
state
:pending
,
value:
'pending'
...
...
spec/services/merge_requests/merge_when_build_succeeds_service_spec.rb
浏览文件 @
56449cc6
...
...
@@ -63,6 +63,36 @@ describe MergeRequests::MergeWhenBuildSucceedsService do
expect
(
MergeWorker
).
to
receive
(
:perform_async
)
service
.
trigger
(
build
)
end
context
'properly handles multiple stages'
do
let
(
:ref
)
{
mr_merge_if_green_enabled
.
source_branch
}
let
(
:build
)
{
create
(
:ci_build
,
commit:
ci_commit
,
ref:
ref
,
name:
'build'
,
stage:
'build'
)
}
let
(
:test
)
{
create
(
:ci_build
,
commit:
ci_commit
,
ref:
ref
,
name:
'test'
,
stage:
'test'
)
}
before
do
# This behavior of MergeRequest: we instantiate a new object
allow_any_instance_of
(
MergeRequest
).
to
receive
(
:ci_commit
).
and_wrap_original
do
Ci
::
Commit
.
find
(
ci_commit
.
id
)
end
# We create test after the build
allow
(
ci_commit
).
to
receive
(
:create_next_builds
).
and_wrap_original
do
test
end
end
it
"doesn't merge if some stages failed"
do
expect
(
MergeWorker
).
to_not
receive
(
:perform_async
)
build
.
success
test
.
drop
end
it
'merge when all stages succeeded'
do
expect
(
MergeWorker
).
to
receive
(
:perform_async
)
build
.
success
test
.
success
end
end
end
describe
"#cancel"
do
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录