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
Tatuya Kamada
gitlab-ce
Commits
ea4ac578
Commit
ea4ac578
authored
Aug 12, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use event `enqueue` instead of `queue`
parent
d7b68151
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
34 additions
and
23 deletions
+34
-23
app/models/ci/build.rb
app/models/ci/build.rb
+2
-2
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+7
-13
app/models/commit_status.rb
app/models/commit_status.rb
+1
-1
app/services/ci/process_pipeline_service.rb
app/services/ci/process_pipeline_service.rb
+1
-1
spec/models/build_spec.rb
spec/models/build_spec.rb
+4
-2
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+19
-4
No files found.
app/models/ci/build.rb
View file @
ea4ac578
...
...
@@ -59,7 +59,7 @@ module Ci
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 @@ module Ci
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 @
ea4ac578
...
...
@@ -20,7 +20,7 @@ module Ci
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 @@ module Ci
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 @
ea4ac578
...
...
@@ -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 @
ea4ac578
...
...
@@ -37,7 +37,7 @@ module Ci
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 @
ea4ac578
...
...
@@ -886,8 +886,10 @@ describe Ci::Build, models: true do
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 @
ea4ac578
...
...
@@ -143,7 +143,7 @@ describe Ci::Pipeline, models: true do
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 @@ describe Ci::Pipeline, models: true do
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 @@ describe Ci::Pipeline, models: true do
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 @@ describe Ci::Pipeline, models: true do
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