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,22 +28,13 @@ RSpec.describe 'scripts/changed-feature-flags' do ...@@ -30,22 +28,13 @@ 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
it 'returns feature flags on their own' do
subject = described_class.new({ files: [feature_flag_definition1.path, feature_flag_definition2.path] }) subject = described_class.new({ files: [feature_flag_definition1.path, feature_flag_definition2.path] })
expect(subject.extracted_flags).to eq('foo_flag,bar_flag') expect(subject.extracted_flags).to eq('foo_flag,bar_flag')
...@@ -62,12 +51,29 @@ RSpec.describe 'scripts/changed-feature-flags' do ...@@ -62,12 +51,29 @@ RSpec.describe 'scripts/changed-feature-flags' do
expect(subject.extracted_flags).to eq('foo_flag=disabled,bar_flag=disabled') expect(subject.extracted_flags).to eq('foo_flag=disabled,bar_flag=disabled')
end end
end
it 'ignores files that are not in the feature_flags/development directory' do context 'with definition files in the development 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', 'development')) }
it_behaves_like 'extract feature flags'
end
context 'with definition files in the ops directory' do
let(:ff_dir) { FileUtils.mkdir_p(File.join(Dir.tmpdir, 'feature_flags', 'ops')) }
it_behaves_like 'extract feature flags'
end
context 'with definition files in the experiment directory' do
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
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