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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
fafc5a17
Commit
fafc5a17
authored
Oct 13, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Perform CI build hooks asynchronously using worker
parent
2461e109
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
2 deletions
+35
-2
app/models/ci/build.rb
app/models/ci/build.rb
+3
-2
app/workers/build_hooks_worker.rb
app/workers/build_hooks_worker.rb
+9
-0
spec/workers/build_hooks_worker_spec.rb
spec/workers/build_hooks_worker_spec.rb
+23
-0
No files found.
app/models/ci/build.rb
View file @
fafc5a17
module
Ci
class
Build
<
CommitStatus
include
TokenAuthenticatable
include
AfterCommitQueue
belongs_to
:runner
,
class_name:
'Ci::Runner'
belongs_to
:trigger_request
,
class_name:
'Ci::TriggerRequest'
...
...
@@ -75,12 +76,12 @@ module Ci
state_machine
:status
do
after_transition
pending: :running
do
|
build
|
build
.
execute_hooks
build
.
run_after_commit
{
BuildHooksWorker
.
perform_async
(
id
)
}
end
after_transition
any
=>
[
:success
,
:failed
,
:canceled
]
do
|
build
|
build
.
update_coverage
build
.
execute_hooks
build
.
run_after_commit
{
BuildHooksWorker
.
perform_async
(
id
)
}
end
after_transition
any
=>
[
:success
]
do
|
build
|
...
...
app/workers/build_hooks_worker.rb
0 → 100644
View file @
fafc5a17
class
BuildHooksWorker
include
Sidekiq
::
Worker
sidekiq_options
queue: :default
def
perform
(
build_id
)
Ci
::
Build
.
find_by
(
id:
build_id
)
.
try
(
:execute_hooks
)
end
end
spec/workers/build_hooks_worker_spec.rb
0 → 100644
View file @
fafc5a17
require
'spec_helper'
describe
BuildHooksWorker
do
describe
'#perform'
do
context
'when build exists'
do
let!
(
:build
)
{
create
(
:ci_build
)
}
it
'calls build hooks'
do
expect_any_instance_of
(
Ci
::
Build
)
.
to
receive
(
:execute_hooks
)
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