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
4b3f721a
Commit
4b3f721a
authored
Nov 17, 2021
by
Mark Lapierre
Committed by
Albert Salim
Nov 17, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include ops when feature flags trigger QA tests
parent
ffbd0852
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
26 deletions
+32
-26
.gitlab/ci/rules.gitlab-ci.yml
.gitlab/ci/rules.gitlab-ci.yml
+1
-1
scripts/changed-feature-flags
scripts/changed-feature-flags
+1
-1
spec/scripts/changed-feature-flags_spec.rb
spec/scripts/changed-feature-flags_spec.rb
+30
-24
No files found.
.gitlab/ci/rules.gitlab-ci.yml
View file @
4b3f721a
...
@@ -438,7 +438,7 @@
...
@@ -438,7 +438,7 @@
-
"
vendor/assets/javascripts/**/*"
-
"
vendor/assets/javascripts/**/*"
.feature-flag-development-config-patterns
:
&feature-flag-development-config-patterns
.feature-flag-development-config-patterns
:
&feature-flag-development-config-patterns
-
"
{,ee/}config/feature_flags/
development
/*.yml"
-
"
{,ee/}config/feature_flags/
{development,ops}
/*.yml"
################
################
# Shared rules #
# Shared rules #
...
...
scripts/changed-feature-flags
View file @
4b3f721a
...
@@ -19,7 +19,7 @@ class GetFeatureFlagsFromFiles
...
@@ -19,7 +19,7 @@ class GetFeatureFlagsFromFiles
def
extracted_flags
def
extracted_flags
files
.
each_with_object
([])
do
|
file_path
,
all
|
files
.
each_with_object
([])
do
|
file_path
,
all
|
next
unless
file_path
=~
%r{/feature_flags/
development
/.*
\.
yml}
next
unless
file_path
=~
%r{/feature_flags/
(development|ops)
/.*
\.
yml}
next
unless
File
.
exist?
(
file_path
)
next
unless
File
.
exist?
(
file_path
)
ff_yaml
=
YAML
.
safe_load
(
File
.
read
(
file_path
))
ff_yaml
=
YAML
.
safe_load
(
File
.
read
(
file_path
))
...
...
spec/scripts/changed-feature-flags_spec.rb
View file @
4b3f721a
...
@@ -6,8 +6,6 @@ load File.expand_path('../../scripts/changed-feature-flags', __dir__)
...
@@ -6,8 +6,6 @@ load File.expand_path('../../scripts/changed-feature-flags', __dir__)
RSpec
.
describe
'scripts/changed-feature-flags'
do
RSpec
.
describe
'scripts/changed-feature-flags'
do
describe
GetFeatureFlagsFromFiles
do
describe
GetFeatureFlagsFromFiles
do
let
(
:ff_dir
)
{
FileUtils
.
mkdir_p
(
File
.
join
(
Dir
.
tmpdir
,
'feature_flags'
,
'development'
))
}
let
(
:feature_flag_definition1
)
do
let
(
:feature_flag_definition1
)
do
file
=
Tempfile
.
new
(
'foo.yml'
,
ff_dir
)
file
=
Tempfile
.
new
(
'foo.yml'
,
ff_dir
)
file
.
write
(
<<~
YAML
)
file
.
write
(
<<~
YAML
)
...
@@ -30,43 +28,51 @@ RSpec.describe 'scripts/changed-feature-flags' do
...
@@ -30,43 +28,51 @@ RSpec.describe 'scripts/changed-feature-flags' do
file
file
end
end
let
(
:feature_flag_definition_invalid_path
)
do
file
=
Tempfile
.
new
(
'foobar.yml'
)
file
.
write
(
<<~
YAML
)
---
name: not a feature flag
YAML
file
.
rewind
file
end
after
do
after
do
FileUtils
.
remove_entry
(
ff_dir
,
true
)
FileUtils
.
remove_entry
(
ff_dir
,
true
)
end
end
describe
'.extracted_flags'
do
describe
'.extracted_flags'
do
it
'returns feature flags'
do
shared_examples
'extract feature flags'
do
subject
=
described_class
.
new
({
files:
[
feature_flag_definition1
.
path
,
feature_flag_definition2
.
path
]
})
it
'returns feature flags on their own'
do
subject
=
described_class
.
new
({
files:
[
feature_flag_definition1
.
path
,
feature_flag_definition2
.
path
]
})
expect
(
subject
.
extracted_flags
).
to
eq
(
'foo_flag,bar_flag'
)
end
it
'returns feature flags and their state as enabled'
do
subject
=
described_class
.
new
({
files:
[
feature_flag_definition1
.
path
,
feature_flag_definition2
.
path
],
state:
'enabled'
})
expect
(
subject
.
extracted_flags
).
to
eq
(
'foo_flag,bar_flag'
)
expect
(
subject
.
extracted_flags
).
to
eq
(
'foo_flag=enabled,bar_flag=enabled'
)
end
it
'returns feature flags and their state as disabled'
do
subject
=
described_class
.
new
({
files:
[
feature_flag_definition1
.
path
,
feature_flag_definition2
.
path
],
state:
'disabled'
})
expect
(
subject
.
extracted_flags
).
to
eq
(
'foo_flag=disabled,bar_flag=disabled'
)
end
end
end
it
'returns feature flags and their state as enabled
'
do
context
'with definition files in the development directory
'
do
subject
=
described_class
.
new
({
files:
[
feature_flag_definition1
.
path
,
feature_flag_definition2
.
path
],
state:
'enabled'
})
let
(
:ff_dir
)
{
FileUtils
.
mkdir_p
(
File
.
join
(
Dir
.
tmpdir
,
'feature_flags'
,
'development'
))
}
expect
(
subject
.
extracted_flags
).
to
eq
(
'foo_flag=enabled,bar_flag=enabled'
)
it_behaves_like
'extract feature flags'
end
end
it
'returns feature flags and their state as disabled
'
do
context
'with definition files in the ops directory
'
do
subject
=
described_class
.
new
({
files:
[
feature_flag_definition1
.
path
,
feature_flag_definition2
.
path
],
state:
'disabled'
})
let
(
:ff_dir
)
{
FileUtils
.
mkdir_p
(
File
.
join
(
Dir
.
tmpdir
,
'feature_flags'
,
'ops'
))
}
expect
(
subject
.
extracted_flags
).
to
eq
(
'foo_flag=disabled,bar_flag=disabled'
)
it_behaves_like
'extract feature flags'
end
end
it
'ignores files that are not in the feature_flags/development directory'
do
context
'with definition files in the experiment directory'
do
subject
=
described_class
.
new
({
files:
[
feature_flag_definition_invalid_path
.
path
]
})
let
(
:ff_dir
)
{
FileUtils
.
mkdir_p
(
File
.
join
(
Dir
.
tmpdir
,
'feature_flags'
,
'experiment'
))
}
it
'ignores the files'
do
subject
=
described_class
.
new
({
files:
[
feature_flag_definition1
.
path
,
feature_flag_definition2
.
path
]
})
expect
(
subject
.
extracted_flags
).
to
eq
(
''
)
expect
(
subject
.
extracted_flags
).
to
eq
(
''
)
end
end
end
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