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
39704e39
Commit
39704e39
authored
Aug 15, 2019
by
Kamil Trzciński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add feature flag
parent
c6a7e95a
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
46 additions
and
11 deletions
+46
-11
app/models/ci/group.rb
app/models/ci/group.rb
+7
-1
app/models/ci/legacy_stage.rb
app/models/ci/legacy_stage.rb
+0
-1
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+26
-3
app/models/ci/stage.rb
app/models/ci/stage.rb
+3
-2
app/models/concerns/has_status.rb
app/models/concerns/has_status.rb
+7
-3
lib/gitlab/ci/status/composite_status.rb
lib/gitlab/ci/status/composite_status.rb
+3
-1
No files found.
app/models/ci/group.rb
View file @
39704e39
...
...
@@ -23,7 +23,13 @@ module Ci
def
status
strong_memoize
(
:status
)
do
@jobs
.
slow_composite_status
if
Feature
.
enabled?
(
:ci_composite_status
,
default_enabled:
true
)
Gitlab
::
Ci
::
Status
::
GroupedStatuses
.
new
(
@jobs
)
.
one
[
:status
]
else
CommitStatus
.
where
(
id:
@jobs
).
legacy_status
end
end
end
...
...
app/models/ci/legacy_stage.rb
View file @
39704e39
...
...
@@ -31,7 +31,6 @@ module Ci
def
status
@status
||=
statuses
.
latest
.
slow_composite_status
end
def
detailed_status
(
current_user
)
...
...
app/models/ci/pipeline.rb
View file @
39704e39
...
...
@@ -387,9 +387,24 @@ module Ci
end
end
def
legacy_stages
def
legacy_stages
_using_sql
# TODO, this needs refactoring, see gitlab-foss#26481.
stages_query
=
statuses
.
group
(
'stage'
).
select
(
:stage
).
order
(
'max(stage_idx)'
)
status_sql
=
statuses
.
latest
.
where
(
'stage=sg.stage'
).
legacy_status_sql
warnings_sql
=
statuses
.
latest
.
select
(
'COUNT(*)'
)
.
where
(
'stage=sg.stage'
).
failed_but_allowed
.
to_sql
stages_with_statuses
=
CommitStatus
.
from
(
stages_query
,
:sg
)
.
pluck
(
'sg.stage'
,
status_sql
,
"(
#{
warnings_sql
}
)"
)
stages_with_statuses
.
map
do
|
stage
|
Ci
::
LegacyStage
.
new
(
self
,
Hash
[
%i[name status warnings]
.
zip
(
stage
)])
end
def
legacy_stages_using_composite_status
stages
=
Gitlab
::
Ci
::
Status
::
GroupedStatuses
.
new
(
statuses
.
latest
,
:stage
,
:stage_idx
)
.
group
(
:stage
,
:stage_idx
)
...
...
@@ -400,6 +415,13 @@ module Ci
name:
stage
[
:stage
],
status:
stage
[
:status
],
warnings:
stage
[
:warnings
])
end
def
legacy_stages
if
Feature
.
enabled?
(
:ci_composite_status
,
default_enabled:
true
)
legacy_stages_using_composite_status
else
legacy_status_using_sql
end
end
...
...
@@ -633,7 +655,8 @@ module Ci
def
update_status
retry_optimistic_lock
(
self
)
do
case
latest_builds_status
.
to_s
new_status
=
latest_builds_status
.
to_s
case
new_status
when
'created'
then
nil
when
'preparing'
then
prepare
when
'pending'
then
enqueue
...
...
@@ -646,7 +669,7 @@ module Ci
when
'scheduled'
then
delay
else
raise
HasStatus
::
UnknownStatusError
,
"Unknown status `
#{
latest_builds
_status
}
`"
"Unknown status `
#{
new
_status
}
`"
end
end
end
...
...
app/models/ci/stage.rb
View file @
39704e39
...
...
@@ -78,7 +78,8 @@ module Ci
def
update_status
retry_optimistic_lock
(
self
)
do
case
latest_stage_status
new_status
=
latest_stage_status
.
to_s
case
new_status
when
'created'
then
nil
when
'preparing'
then
prepare
when
'pending'
then
enqueue
...
...
@@ -91,7 +92,7 @@ module Ci
when
'skipped'
,
nil
then
skip
else
raise
HasStatus
::
UnknownStatusError
,
"Unknown status `
#{
statuses
.
latest
.
status
}
`"
"Unknown status `
#{
new_
status
}
`"
end
end
end
...
...
app/models/concerns/has_status.rb
View file @
39704e39
...
...
@@ -59,9 +59,13 @@ module HasStatus
end
def
slow_composite_status
Gitlab
::
Ci
::
Status
::
GroupedStatuses
.
new
(
all
)
.
one
[
:status
]
if
Feature
.
enabled?
(
:ci_composite_status
,
default_enabled:
true
)
Gitlab
::
Ci
::
Status
::
GroupedStatuses
.
new
(
all
)
.
one
[
:status
]
else
legacy_status
end
end
def
started_at
...
...
lib/gitlab/ci/status/composite_status.rb
View file @
39704e39
...
...
@@ -15,7 +15,9 @@ module Gitlab
def
status
case
when
none?
||
only_of?
(
:skipped
)
when
none?
:skipped
when
only_of?
(
:skipped
)
warnings?
?
:success
:
:skipped
when
only_of?
(
:success
,
:skipped
)
:success
...
...
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