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
Léo-Paul Géneau
gitlab-ce
Commits
fc3d2141
Commit
fc3d2141
authored
May 29, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a feature flag for switching pipeline stages
parent
8a3aa3a6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
92 additions
and
7 deletions
+92
-7
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+10
-6
app/serializers/pipeline_details_entity.rb
app/serializers/pipeline_details_entity.rb
+1
-1
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+81
-0
No files found.
app/models/ci/pipeline.rb
View file @
fc3d2141
...
@@ -250,13 +250,17 @@ module Ci
...
@@ -250,13 +250,17 @@ module Ci
end
end
##
##
# TODO consider switching to persisted stages only in pipelines table
# TODO We do not completely switch to persisted stages because of
# (not necessairly in the show pipeline page because of #23257.
# race conditions with setting statuses gitlab-ce#23257.
# Hide this behind two feature flags - enabled / disabled and only
# gitlab-ce / everywhere.
#
#
def
stages
def
ordered_stages
super
return
legacy_stages
unless
complete?
if
Feature
.
enabled?
(
'ci_pipeline_persisted_stages'
)
stages
else
legacy_stages
end
end
end
def
legacy_stages
def
legacy_stages
...
...
app/serializers/pipeline_details_entity.rb
View file @
fc3d2141
class
PipelineDetailsEntity
<
PipelineEntity
class
PipelineDetailsEntity
<
PipelineEntity
expose
:details
do
expose
:details
do
expose
:stages
,
using:
StageEntity
expose
:
ordered_stages
,
as: :
stages
,
using:
StageEntity
expose
:artifacts
,
using:
BuildArtifactEntity
expose
:artifacts
,
using:
BuildArtifactEntity
expose
:manual_actions
,
using:
BuildActionEntity
expose
:manual_actions
,
using:
BuildActionEntity
end
end
...
...
spec/models/ci/pipeline_spec.rb
View file @
fc3d2141
...
@@ -500,6 +500,87 @@ describe Ci::Pipeline, :mailer do
...
@@ -500,6 +500,87 @@ describe Ci::Pipeline, :mailer do
end
end
end
end
end
end
describe
'#stages'
do
before
do
create
(
:ci_stage_entity
,
project:
project
,
pipeline:
pipeline
,
name:
'build'
)
end
it
'returns persisted stages'
do
expect
(
pipeline
.
stages
).
not_to
be_empty
expect
(
pipeline
.
stages
).
to
all
(
be_persisted
)
end
end
describe
'#ordered_stages'
do
before
do
create
(
:ci_stage_entity
,
project:
project
,
pipeline:
pipeline
,
position:
4
,
name:
'deploy'
)
create
(
:ci_build
,
project:
project
,
pipeline:
pipeline
,
stage:
'test'
,
stage_idx:
3
,
name:
'test'
)
create
(
:ci_build
,
project:
project
,
pipeline:
pipeline
,
stage:
'build'
,
stage_idx:
2
,
name:
'build'
)
create
(
:ci_stage_entity
,
project:
project
,
pipeline:
pipeline
,
position:
1
,
name:
'sanity'
)
create
(
:ci_stage_entity
,
project:
project
,
pipeline:
pipeline
,
position:
5
,
name:
'cleanup'
)
end
subject
{
pipeline
.
ordered_stages
}
context
'when using legacy stages'
do
before
do
stub_feature_flags
(
ci_pipeline_persisted_stages:
false
)
end
it
'returns legacy stages in valid order'
do
expect
(
subject
.
map
(
&
:name
)).
to
eq
%w[build test]
end
end
context
'when using persisted stages'
do
before
do
stub_feature_flags
(
ci_pipeline_persisted_stages:
true
)
end
context
'when pipelines is not complete'
do
it
'still returns legacy stages'
do
expect
(
subject
).
to
all
(
be_a
Ci
::
LegacyStage
)
expect
(
subject
.
map
(
&
:name
)).
to
eq
%w[build test]
end
end
context
'when pipeline is complete'
do
before
do
pipeline
.
succeed!
end
it
'returns stages in valid order'
do
expect
(
subject
).
to
all
(
be_a
Ci
::
Stage
)
expect
(
subject
.
map
(
&
:name
))
.
to
eq
%w[sanity build test deploy cleanup]
end
end
end
end
end
end
describe
'state machine'
do
describe
'state machine'
do
...
...
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