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
5904793a
Commit
5904793a
authored
Oct 14, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add build finished worker that creates a workflow
parent
b8003aa0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
2 deletions
+43
-2
app/models/ci/build.rb
app/models/ci/build.rb
+1
-2
app/workers/build_finished_worker.rb
app/workers/build_finished_worker.rb
+12
-0
spec/workers/build_finished_worker_spec.rb
spec/workers/build_finished_worker_spec.rb
+30
-0
No files found.
app/models/ci/build.rb
View file @
5904793a
...
...
@@ -83,8 +83,7 @@ module Ci
after_transition
any
=>
[
:success
,
:failed
,
:canceled
]
do
|
build
|
build
.
run_after_commit
do
BuildCoverageWorker
.
perform_async
(
id
)
BuildHooksWorker
.
perform_async
(
id
)
BuildFinishedWorker
.
perform_async
(
id
)
end
end
...
...
app/workers/build_finished_worker.rb
0 → 100644
View file @
5904793a
class
BuildFinishedWorker
include
Sidekiq
::
Worker
def
perform
(
build_id
)
Ci
::
Build
.
find_by
(
id:
build_id
).
try
do
|
build
|
build
.
with_lock
do
BuildCoverageWorker
.
new
.
perform
(
build
.
id
)
BuildHooksWorker
.
new
.
perform
(
build
.
id
)
end
end
end
end
spec/workers/build_finished_worker_spec.rb
0 → 100644
View file @
5904793a
require
'spec_helper'
describe
BuildFinishedWorker
do
describe
'#perform'
do
context
'when build exists'
do
let
(
:build
)
{
create
(
:ci_build
)
}
it
'calculates coverage and calls hooks'
do
expect
(
BuildCoverageWorker
)
.
to
receive
(
:new
).
ordered
.
and_call_original
expect
(
BuildHooksWorker
)
.
to
receive
(
:new
).
ordered
.
and_call_original
expect_any_instance_of
(
BuildCoverageWorker
)
.
to
receive
(
:perform
)
expect_any_instance_of
(
BuildHooksWorker
)
.
to
receive
(
:perform
)
described_class
.
new
.
perform
(
build
.
id
)
end
end
context
'when build does not exist'
do
it
'does not raise exception'
do
expect
{
described_class
.
new
.
perform
(
123
)
}
.
not_to
raise_error
end
end
end
end
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