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
1ae7b39b
Commit
1ae7b39b
authored
Aug 05, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
8294d3e3
523e00ab
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
93 additions
and
17 deletions
+93
-17
app/models/commit_status.rb
app/models/commit_status.rb
+4
-0
app/services/ci/process_pipeline_service.rb
app/services/ci/process_pipeline_service.rb
+29
-17
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+16
-0
spec/services/ci/process_pipeline_service_spec.rb
spec/services/ci/process_pipeline_service_spec.rb
+44
-0
No files found.
app/models/commit_status.rb
View file @
1ae7b39b
...
...
@@ -51,6 +51,10 @@ class CommitStatus < ApplicationRecord
where
(
'EXISTS (?)'
,
needs
).
preload
(
:needs
)
end
scope
:without_needs
,
->
do
where
(
'NOT EXISTS (?)'
,
Ci
::
BuildNeed
.
scoped_build
.
select
(
1
))
end
# We use `CommitStatusEnums.failure_reasons` here so that EE can more easily
# extend this `Hash` with new values.
enum_with_nil
failure_reason:
::
CommitStatusEnums
.
failure_reasons
...
...
app/services/ci/process_pipeline_service.rb
View file @
1ae7b39b
...
...
@@ -9,10 +9,7 @@ module Ci
update_retried
success
=
stage_indexes_of_created_processables
.
flat_map
do
|
index
|
process_stage
(
index
)
end
.
any?
success
=
process_stages_without_needs
# we evaluate dependent needs,
# only when the another job has finished
...
...
@@ -25,18 +22,19 @@ module Ci
private
def
process_stage
(
index
)
def
process_stages_without_needs
stage_indexes_of_created_processables_without_needs
.
flat_map
do
|
index
|
process_stage_without_needs
(
index
)
end
.
any?
end
def
process_stage_without_needs
(
index
)
current_status
=
status_for_prior_stages
(
index
)
return
if
HasStatus
::
BLOCKED_STATU
S
.
include?
(
current_status
)
return
unless
HasStatus
::
COMPLETED_STATUSE
S
.
include?
(
current_status
)
if
HasStatus
::
COMPLETED_STATUSES
.
include?
(
current_status
)
created_processables_in_stage
(
index
).
select
do
|
build
|
Gitlab
::
OptimisticLocking
.
retry_lock
(
build
)
do
|
subject
|
Ci
::
ProcessBuildService
.
new
(
project
,
@user
)
.
execute
(
build
,
current_status
)
end
end
created_processables_in_stage_without_needs
(
index
).
select
do
|
build
|
process_build
(
build
,
current_status
)
end
end
...
...
@@ -56,6 +54,10 @@ module Ci
return
unless
HasStatus
::
COMPLETED_STATUSES
.
include?
(
current_status
)
process_build
(
build
,
current_status
)
end
def
process_build
(
build
,
current_status
)
Gitlab
::
OptimisticLocking
.
retry_lock
(
build
)
do
|
subject
|
Ci
::
ProcessBuildService
.
new
(
project
,
@user
)
.
execute
(
subject
,
current_status
)
...
...
@@ -75,17 +77,27 @@ module Ci
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
stage_indexes_of_created_processables
created_processables
.
order
(
:stage_idx
).
pluck
(
Arel
.
sql
(
'DISTINCT stage_idx'
))
def
stage_indexes_of_created_processables_without_needs
created_processables_without_needs
.
order
(
:stage_idx
)
.
pluck
(
Arel
.
sql
(
'DISTINCT stage_idx'
))
end
# rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def
created_processables_in_stage
(
index
)
created_processables
.
where
(
stage_idx:
index
)
def
created_processables_in_stage_without_needs
(
index
)
created_processables_without_needs
.
where
(
stage_idx:
index
)
end
# rubocop: enable CodeReuse/ActiveRecord
def
created_processables_without_needs
if
Feature
.
enabled?
(
:ci_dag_support
,
project
)
pipeline
.
processables
.
created
.
without_needs
else
pipeline
.
processables
.
created
end
end
def
created_processables
pipeline
.
processables
.
created
end
...
...
spec/models/ci/build_spec.rb
View file @
1ae7b39b
...
...
@@ -208,6 +208,22 @@ describe Ci::Build do
end
end
describe
'.without_needs'
do
let!
(
:build
)
{
create
(
:ci_build
)
}
subject
{
described_class
.
without_needs
}
context
'when no build_need is created'
do
it
{
is_expected
.
to
contain_exactly
(
build
)
}
end
context
'when a build_need is created'
do
let!
(
:need_a
)
{
create
(
:ci_build_need
,
build:
build
)
}
it
{
is_expected
.
to
be_empty
}
end
end
describe
'#enqueue'
do
let
(
:build
)
{
create
(
:ci_build
,
:created
)
}
...
...
spec/services/ci/process_pipeline_service_spec.rb
View file @
1ae7b39b
...
...
@@ -786,6 +786,50 @@ describe Ci::ProcessPipelineService, '#execute' do
expect
(
builds
.
pending
).
to
contain_exactly
(
deploy
)
end
end
context
'when one of the jobs is run on a failure'
do
let!
(
:linux_notify
)
{
create_build
(
'linux:notify'
,
stage:
'deploy'
,
stage_idx:
2
,
when:
'on_failure'
)
}
let!
(
:linux_notify_on_build
)
{
create
(
:ci_build_need
,
build:
linux_notify
,
name:
'linux:build'
)
}
context
'when another job in build phase fails first'
do
context
'when ci_dag_support is enabled'
do
it
'does skip linux:notify'
do
expect
(
process_pipeline
).
to
be_truthy
mac_build
.
reset
.
drop!
linux_build
.
reset
.
success!
expect
(
linux_notify
.
reset
).
to
be_skipped
end
end
context
'when ci_dag_support is disabled'
do
before
do
stub_feature_flags
(
ci_dag_support:
false
)
end
it
'does run linux:notify'
do
expect
(
process_pipeline
).
to
be_truthy
mac_build
.
reset
.
drop!
linux_build
.
reset
.
success!
expect
(
linux_notify
.
reset
).
to
be_pending
end
end
end
context
'when linux:build job fails first'
do
it
'does run linux:notify'
do
expect
(
process_pipeline
).
to
be_truthy
linux_build
.
reset
.
drop!
expect
(
linux_notify
.
reset
).
to
be_pending
end
end
end
end
def
process_pipeline
...
...
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