BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
d8aed6a2
Commit
d8aed6a2
authored
Oct 26, 2016
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix optimistic locking
parent
47b2add4
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
27 additions
and
16 deletions
+27
-16
commit_status.rb
app/models/commit_status.rb
+6
-6
process_pipeline_service.rb
app/services/ci/process_pipeline_service.rb
+4
-2
safe_model_attributes.yml
spec/lib/gitlab/import_export/safe_model_attributes.yml
+2
-0
pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+9
-6
builds_spec.rb
spec/requests/api/builds_spec.rb
+2
-0
register_build_service_spec.rb
spec/services/ci/register_build_service_spec.rb
+2
-2
merge_when_build_succeeds_service_spec.rb
.../merge_requests/merge_when_build_succeeds_service_spec.rb
+2
-0
No files found.
app/models/commit_status.rb
View file @
d8aed6a2
...
@@ -73,16 +73,16 @@ class CommitStatus < ActiveRecord::Base
...
@@ -73,16 +73,16 @@ class CommitStatus < ActiveRecord::Base
transition
[
:created
,
:pending
,
:running
]
=>
:canceled
transition
[
:created
,
:pending
,
:running
]
=>
:canceled
end
end
after
_transition
created:
[
:pending
,
:running
]
do
|
commit_status
|
before
_transition
created:
[
:pending
,
:running
]
do
|
commit_status
|
commit_status
.
update_attributes
queued_at:
Time
.
now
commit_status
.
queued_at
=
Time
.
now
end
end
after
_transition
[
:created
,
:pending
]
=>
:running
do
|
commit_status
|
before
_transition
[
:created
,
:pending
]
=>
:running
do
|
commit_status
|
commit_status
.
update_attributes
started_at:
Time
.
now
commit_status
.
started_at
=
Time
.
now
end
end
after
_transition
any
=>
[
:success
,
:failed
,
:canceled
]
do
|
commit_status
|
before
_transition
any
=>
[
:success
,
:failed
,
:canceled
]
do
|
commit_status
|
commit_status
.
update_attributes
finished_at:
Time
.
now
commit_status
.
finished_at
=
Time
.
now
end
end
after_transition
do
|
commit_status
,
transition
|
after_transition
do
|
commit_status
,
transition
|
...
...
app/services/ci/process_pipeline_service.rb
View file @
d8aed6a2
...
@@ -40,10 +40,12 @@ module Ci
...
@@ -40,10 +40,12 @@ module Ci
def
process_build
(
build
,
current_status
)
def
process_build
(
build
,
current_status
)
if
valid_statuses_for_when
(
build
.
when
).
include?
(
current_status
)
if
valid_statuses_for_when
(
build
.
when
).
include?
(
current_status
)
build
.
enqueue
r
=
build
.
enqueue
puts
"process_build:
#{
build
.
id
}
: enqueue:
#{
build
.
status
}
=>
#{
r
}
"
true
true
else
else
build
.
skip
r
=
build
.
skip
puts
"process_build:
#{
build
.
id
}
: skip:
#{
build
.
status
}
=>
#{
r
}
"
false
false
end
end
end
end
...
...
spec/lib/gitlab/import_export/safe_model_attributes.yml
View file @
d8aed6a2
...
@@ -178,6 +178,7 @@ Ci::Pipeline:
...
@@ -178,6 +178,7 @@ Ci::Pipeline:
-
finished_at
-
finished_at
-
duration
-
duration
-
user_id
-
user_id
-
lock_version
CommitStatus
:
CommitStatus
:
-
id
-
id
-
project_id
-
project_id
...
@@ -217,6 +218,7 @@ CommitStatus:
...
@@ -217,6 +218,7 @@ CommitStatus:
-
yaml_variables
-
yaml_variables
-
queued_at
-
queued_at
-
token
-
token
-
lock_version
Ci::Variable
:
Ci::Variable
:
-
id
-
id
-
project_id
-
project_id
...
...
spec/models/ci/pipeline_spec.rb
View file @
d8aed6a2
...
@@ -138,9 +138,9 @@ describe Ci::Pipeline, models: true do
...
@@ -138,9 +138,9 @@ describe Ci::Pipeline, models: true do
describe
'state machine'
do
describe
'state machine'
do
let
(
:current
)
{
Time
.
now
.
change
(
usec:
0
)
}
let
(
:current
)
{
Time
.
now
.
change
(
usec:
0
)
}
let
(
:build
)
{
create_build
(
'build1'
,
current
,
1
0
)
}
let
(
:build
)
{
create_build
(
'build1'
,
0
)
}
let
(
:build_b
)
{
create_build
(
'build2'
,
current
,
2
0
)
}
let
(
:build_b
)
{
create_build
(
'build2'
,
0
)
}
let
(
:build_c
)
{
create_build
(
'build3'
,
current
+
50
,
1
0
)
}
let
(
:build_c
)
{
create_build
(
'build3'
,
0
)
}
describe
'#duration'
do
describe
'#duration'
do
before
do
before
do
...
@@ -163,11 +163,12 @@ describe Ci::Pipeline, models: true do
...
@@ -163,11 +163,12 @@ describe Ci::Pipeline, models: true do
build_c
.
success
build_c
.
success
end
end
pipeline
.
drop
# We have to reload pipeline, because its status is updated by processing builds
pipeline
.
reload
.
drop
end
end
it
'matches sum of builds duration'
do
it
'matches sum of builds duration'
do
pipeline
.
reload
binding
.
pry
expect
(
pipeline
.
duration
).
to
eq
(
40
)
expect
(
pipeline
.
duration
).
to
eq
(
40
)
end
end
...
@@ -455,7 +456,9 @@ describe Ci::Pipeline, models: true do
...
@@ -455,7 +456,9 @@ describe Ci::Pipeline, models: true do
context
'when all builds succeed'
do
context
'when all builds succeed'
do
before
do
before
do
build_a
.
success
build_a
.
success
build_b
.
success
# We have to reload build_b as this is in next stage and it gets triggered by PipelineProcessWorker
build_b
.
reload
.
success
end
end
it
'receives a success event once'
do
it
'receives a success event once'
do
...
...
spec/requests/api/builds_spec.rb
View file @
d8aed6a2
...
@@ -277,6 +277,7 @@ describe API::API, api: true do
...
@@ -277,6 +277,7 @@ describe API::API, api: true do
context
'with regular branch'
do
context
'with regular branch'
do
before
do
before
do
pipeline
.
reload
pipeline
.
update
(
ref:
'master'
,
pipeline
.
update
(
ref:
'master'
,
sha:
project
.
commit
(
'master'
).
sha
)
sha:
project
.
commit
(
'master'
).
sha
)
...
@@ -288,6 +289,7 @@ describe API::API, api: true do
...
@@ -288,6 +289,7 @@ describe API::API, api: true do
context
'with branch name containing slash'
do
context
'with branch name containing slash'
do
before
do
before
do
pipeline
.
reload
pipeline
.
update
(
ref:
'improve/awesome'
,
pipeline
.
update
(
ref:
'improve/awesome'
,
sha:
project
.
commit
(
'improve/awesome'
).
sha
)
sha:
project
.
commit
(
'improve/awesome'
).
sha
)
end
end
...
...
spec/services/ci/register_build_service_spec.rb
View file @
d8aed6a2
...
@@ -101,11 +101,11 @@ module Ci
...
@@ -101,11 +101,11 @@ module Ci
it
'equalises number of running builds'
do
it
'equalises number of running builds'
do
# after finishing the first build for project 1, get a second build from the same project
# after finishing the first build for project 1, get a second build from the same project
expect
(
service
.
execute
(
shared_runner
)).
to
eq
(
build1_project1
)
expect
(
service
.
execute
(
shared_runner
)).
to
eq
(
build1_project1
)
build1_project1
.
success
build1_project1
.
reload
.
success
expect
(
service
.
execute
(
shared_runner
)).
to
eq
(
build2_project1
)
expect
(
service
.
execute
(
shared_runner
)).
to
eq
(
build2_project1
)
expect
(
service
.
execute
(
shared_runner
)).
to
eq
(
build1_project2
)
expect
(
service
.
execute
(
shared_runner
)).
to
eq
(
build1_project2
)
build1_project2
.
success
build1_project2
.
reload
.
success
expect
(
service
.
execute
(
shared_runner
)).
to
eq
(
build2_project2
)
expect
(
service
.
execute
(
shared_runner
)).
to
eq
(
build2_project2
)
expect
(
service
.
execute
(
shared_runner
)).
to
eq
(
build1_project3
)
expect
(
service
.
execute
(
shared_runner
)).
to
eq
(
build1_project3
)
expect
(
service
.
execute
(
shared_runner
)).
to
eq
(
build3_project1
)
expect
(
service
.
execute
(
shared_runner
)).
to
eq
(
build3_project1
)
...
...
spec/services/merge_requests/merge_when_build_succeeds_service_spec.rb
View file @
d8aed6a2
...
@@ -147,6 +147,7 @@ describe MergeRequests::MergeWhenBuildSucceedsService do
...
@@ -147,6 +147,7 @@ describe MergeRequests::MergeWhenBuildSucceedsService do
expect
(
MergeWorker
).
not_to
receive
(
:perform_async
)
expect
(
MergeWorker
).
not_to
receive
(
:perform_async
)
build
.
success
build
.
success
test
.
reload
test
.
drop
test
.
drop
end
end
...
@@ -154,6 +155,7 @@ describe MergeRequests::MergeWhenBuildSucceedsService do
...
@@ -154,6 +155,7 @@ describe MergeRequests::MergeWhenBuildSucceedsService do
expect
(
MergeWorker
).
to
receive
(
:perform_async
)
expect
(
MergeWorker
).
to
receive
(
:perform_async
)
build
.
success
build
.
success
test
.
reload
test
.
success
test
.
success
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