Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
f0d5ef96
Commit
f0d5ef96
authored
Nov 21, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not create TODO when build is allowed to fail
parent
900999f8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
7 deletions
+39
-7
app/models/ci/build.rb
app/models/ci/build.rb
+5
-1
app/services/merge_requests/add_todo_when_build_fails_service.rb
...vices/merge_requests/add_todo_when_build_fails_service.rb
+6
-1
spec/services/merge_requests/add_todo_when_build_fails_service_spec.rb
.../merge_requests/add_todo_when_build_fails_service_spec.rb
+28
-5
No files found.
app/models/ci/build.rb
View file @
f0d5ef96
...
...
@@ -70,7 +70,11 @@ module Ci
environment:
build
.
environment
,
status_event:
'enqueue'
)
MergeRequests
::
AddTodoWhenBuildFailsService
.
new
(
build
.
project
,
nil
).
close
(
new_build
)
MergeRequests
::
AddTodoWhenBuildFailsService
.
new
(
build
.
project
,
nil
)
.
close
(
new_build
)
build
.
pipeline
.
mark_as_processable_after_stage
(
build
.
stage_idx
)
new_build
end
...
...
app/services/merge_requests/add_todo_when_build_fails_service.rb
View file @
f0d5ef96
module
MergeRequests
class
AddTodoWhenBuildFailsService
<
MergeRequests
::
BaseService
# Adds a todo to the parent merge_request when a CI build fails
#
def
execute
(
commit_status
)
return
if
commit_status
.
allow_failure?
commit_status_merge_requests
(
commit_status
)
do
|
merge_request
|
todo_service
.
merge_request_build_failed
(
merge_request
)
end
end
# Closes any pending build failed todos for the parent MRs when a build is retried
# Closes any pending build failed todos for the parent MRs when a
# build is retried
#
def
close
(
commit_status
)
commit_status_merge_requests
(
commit_status
)
do
|
merge_request
|
todo_service
.
merge_request_build_retried
(
merge_request
)
...
...
spec/services/merge_requests/add_todo_when_build_fails_service_spec.rb
View file @
f0d5ef96
require
'spec_helper'
# Write specs in this file.
describe
MergeRequests
::
AddTodoWhenBuildFailsService
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:merge_request
)
{
create
(
:merge_request
)
}
let
(
:project
)
{
create
(
:project
)
}
let
(
:sha
)
{
'1234567890abcdef1234567890abcdef12345678'
}
let
(
:pipeline
)
{
create
(
:ci_pipeline_with_one_job
,
ref:
merge_request
.
source_branch
,
project:
project
,
sha:
sha
)
}
let
(
:service
)
{
MergeRequests
::
AddTodoWhenBuildFailsService
.
new
(
project
,
user
,
commit_message:
'Awesome message'
)
}
let
(
:ref
)
{
merge_request
.
source_branch
}
let
(
:pipeline
)
do
create
(
:ci_pipeline_with_one_job
,
ref:
ref
,
project:
project
,
sha:
sha
)
end
let
(
:service
)
do
described_class
.
new
(
project
,
user
,
commit_message:
'Awesome message'
)
end
let
(
:todo_service
)
{
TodoService
.
new
}
let
(
:merge_request
)
do
...
...
@@ -23,7 +32,9 @@ describe MergeRequests::AddTodoWhenBuildFailsService do
describe
'#execute'
do
context
'commit status with ref'
do
let
(
:commit_status
)
{
create
(
:generic_commit_status
,
ref:
merge_request
.
source_branch
,
pipeline:
pipeline
)
}
let
(
:commit_status
)
do
create
(
:generic_commit_status
,
ref:
ref
,
pipeline:
pipeline
)
end
it
'notifies the todo service'
do
expect
(
todo_service
).
to
receive
(
:merge_request_build_failed
).
with
(
merge_request
)
...
...
@@ -32,7 +43,7 @@ describe MergeRequests::AddTodoWhenBuildFailsService do
end
context
'commit status with non-HEAD ref'
do
let
(
:commit_status
)
{
create
(
:generic_commit_status
,
ref:
merge_request
.
source_branch
)
}
let
(
:commit_status
)
{
create
(
:generic_commit_status
,
ref:
ref
)
}
it
'does not notify the todo service'
do
expect
(
todo_service
).
not_to
receive
(
:merge_request_build_failed
)
...
...
@@ -48,6 +59,18 @@ describe MergeRequests::AddTodoWhenBuildFailsService do
service
.
execute
(
commit_status
)
end
end
context
'when commit status is a build allowed to fail'
do
let
(
:commit_status
)
do
create
(
:ci_build
,
:allowed_to_fail
,
ref:
ref
,
pipeline:
pipeline
)
end
it
'does not create todo'
do
expect
(
todo_service
).
not_to
receive
(
:merge_request_build_failed
)
service
.
execute
(
commit_status
)
end
end
end
describe
'#close'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment