Commit 724ad5b4 authored by Albert Salim's avatar Albert Salim

Merge branch 'ml-include-ops-in-package-and-qa-ff' into 'master'

Include ops when feature flags trigger QA tests

See merge request gitlab-org/gitlab!74470
parents 3c78e214 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 #
......
...@@ -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))
......
...@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment