Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
heptapod
heptapod
Commits
0b79dd93448e
Commit
ea4ac578
authored
Aug 12, 2016
by
Kamil Trzcinski
Browse files
Use event `enqueue` instead of `queue`
parent
51365a690a12
Changes
6
Hide whitespace changes
Inline
Side-by-side
app/models/ci/build.rb
View file @
0b79dd93
...
...
@@ -59,7 +59,7 @@ def retry(build, user = nil)
when:
build
.
when
,
user:
user
,
environment:
build
.
environment
,
status_event:
'queue'
status_event:
'
en
queue'
)
MergeRequests
::
AddTodoWhenBuildFailsService
.
new
(
build
.
project
,
nil
).
close
(
new_build
)
new_build
...
...
@@ -102,7 +102,7 @@ def playable?
def
play
(
current_user
=
nil
)
# Try to queue a current build
if
self
.
queue
if
self
.
en
queue
self
.
update
(
user:
current_user
)
self
else
...
...
app/models/ci/pipeline.rb
View file @
0b79dd93
...
...
@@ -20,7 +20,7 @@ class Pipeline < ActiveRecord::Base
after_save
:keep_around_commits
state_machine
:status
,
initial: :created
do
event
:queue
do
event
:
en
queue
do
transition
created: :pending
transition
any
-
[
:created
,
:pending
]
=>
:running
end
...
...
@@ -224,18 +224,12 @@ def process!
def
build_updated
case
latest_builds_status
when
'pending'
queue
when
'running'
run
when
'success'
succeed
when
'failed'
drop
when
'canceled'
cancel
when
'skipped'
skip
when
'pending'
then
enqueue
when
'running'
then
run
when
'success'
then
succeed
when
'failed'
then
drop
when
'canceled'
then
cancel
when
'skipped'
then
skip
end
end
...
...
app/models/commit_status.rb
View file @
0b79dd93
...
...
@@ -26,7 +26,7 @@ class CommitStatus < ActiveRecord::Base
scope
:ignored
,
->
{
where
(
allow_failure:
true
,
status:
[
:failed
,
:canceled
])
}
state_machine
:status
do
event
:queue
do
event
:
en
queue
do
transition
[
:created
,
:skipped
]
=>
:pending
end
...
...
app/services/ci/process_pipeline_service.rb
View file @
0b79dd93
...
...
@@ -37,7 +37,7 @@ def process_build(build, current_status)
return
false
unless
Statuseable
::
COMPLETED_STATUSES
.
include?
(
current_status
)
if
valid_statuses_for_when
(
build
.
when
).
include?
(
current_status
)
build
.
queue
build
.
en
queue
true
else
build
.
skip
...
...
spec/models/build_spec.rb
View file @
0b79dd93
...
...
@@ -886,8 +886,10 @@ def create_mr(build, pipeline, factory: :merge_request, created_at: Time.now)
is_expected
.
to
eq
(
build
)
end
context
'for success build'
do
before
{
build
.
queue
}
context
'for successful build'
do
before
do
build
.
success
end
it
'creates a new build'
do
is_expected
.
to
be_pending
...
...
spec/models/ci/pipeline_spec.rb
View file @
0b79dd93
...
...
@@ -143,7 +143,7 @@
expect
(
pipeline
.
reload
.
started_at
).
not_to
be_nil
end
it
'do not update on transitioning to success'
do
it
'do
es
not update on transitioning to success'
do
build
.
success
expect
(
pipeline
.
reload
.
started_at
).
to
be_nil
...
...
@@ -157,7 +157,7 @@
expect
(
pipeline
.
reload
.
finished_at
).
not_to
be_nil
end
it
'do not update on transitioning to running'
do
it
'do
es
not update on transitioning to running'
do
build
.
run
expect
(
pipeline
.
reload
.
finished_at
).
to
be_nil
...
...
@@ -257,14 +257,16 @@
subject
{
pipeline
.
reload
.
status
}
context
'on queuing'
do
before
{
build
.
queue
}
before
do
build
.
enqueue
end
it
{
is_expected
.
to
eq
(
'pending'
)
}
end
context
'on run'
do
before
do
build
.
queue
build
.
en
queue
build
.
run
end
...
...
@@ -294,5 +296,18 @@
it
{
is_expected
.
to
eq
(
'canceled'
)
}
end
context
'on failure and build retry'
do
before
do
build
.
drop
Ci
::
Build
.
retry
(
build
)
end
# We are changing a state: created > failed > running
# Instead of: created > failed > pending
# Since the pipeline already run, so it should not be pending anymore
it
{
is_expected
.
to
eq
(
'running'
)
}
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