diff --git a/config/feature_flags/development/ci_support_include_rules_when_never.yml b/config/feature_flags/development/ci_support_include_rules_when_never.yml deleted file mode 100644 index 594da30ec971f020ef4d8e035c012a7020969935..0000000000000000000000000000000000000000 --- a/config/feature_flags/development/ci_support_include_rules_when_never.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -name: ci_support_include_rules_when_never -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/122810 -rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/414517 -milestone: '16.1' -type: development -group: group::pipeline authoring -default_enabled: false diff --git a/doc/ci/yaml/includes.md b/doc/ci/yaml/includes.md index 69595b62de2107d1321084933e9725d21970a0a5..6a616854c0b3ab60a44391b1bc5e1888f9b6bffe 100644 --- a/doc/ci/yaml/includes.md +++ b/doc/ci/yaml/includes.md @@ -418,7 +418,8 @@ these keywords: ### `include` with `rules:if` -> Support for `when: never` and `when:always` [introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/348146) in GitLab 16.1 [with a flag](../../administration/feature_flags.md) named `ci_support_include_rules_when_never`. Disabled by default. +> - Support for `when: never` and `when:always` [introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/348146) in GitLab 16.1 [with a flag](../../administration/feature_flags.md) named `ci_support_include_rules_when_never`. Disabled by default. +> - Support for `when: never` and `when:always` [generally available](https://gitlab.com/gitlab-org/gitlab/-/issues/414517) in GitLab 16.2. Feature flag `ci_support_include_rules_when_never` removed. Use [`rules:if`](index.md#rulesif) to conditionally include other configuration files based on the status of CI/CD variables. For example: @@ -447,7 +448,8 @@ test: ### `include` with `rules:exists` -> Support for `when: never` and `when:always` [introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/348146) in GitLab 16.1 [with a flag](../../administration/feature_flags.md) named `ci_support_include_rules_when_never`. Disabled by default. +> - Support for `when: never` and `when:always` [introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/348146) in GitLab 16.1 [with a flag](../../administration/feature_flags.md) named `ci_support_include_rules_when_never`. Disabled by default. +> - Support for `when: never` and `when:always` [generally available](https://gitlab.com/gitlab-org/gitlab/-/issues/414517) in GitLab 16.2. Feature flag `ci_support_include_rules_when_never` removed. Use [`rules:exists`](index.md#rulesexists) to conditionally include other configuration files based on the existence of files. For example: diff --git a/lib/gitlab/ci/config/external/rules.rb b/lib/gitlab/ci/config/external/rules.rb index 134306332e6c9b8cceef2f0565a90156aefb4b41..59e666b8bb5dae6cc4b15a43ade3ebd5e57964c9 100644 --- a/lib/gitlab/ci/config/external/rules.rb +++ b/lib/gitlab/ci/config/external/rules.rb @@ -17,16 +17,12 @@ def initialize(rule_hashes) end def evaluate(context) - if Feature.enabled?(:ci_support_include_rules_when_never, context.project) - if @rule_list.nil? - Result.new('always') - elsif matched_rule = match_rule(context) - Result.new(matched_rule.attributes[:when]) - else - Result.new('never') - end + if @rule_list.nil? + Result.new('always') + elsif matched_rule = match_rule(context) + Result.new(matched_rule.attributes[:when]) else - LegacyResult.new(@rule_list.nil? || match_rule(context)) + Result.new('never') end end @@ -55,12 +51,6 @@ def pass? self.when != 'never' end end - - LegacyResult = Struct.new(:result) do - def pass? - !!result - end - end end end end diff --git a/spec/lib/gitlab/ci/config/external/mapper/filter_spec.rb b/spec/lib/gitlab/ci/config/external/mapper/filter_spec.rb index 4da3e7e51a7b32f5bade6569e4b2e53f48b2351d..1a2a6c5beebaff85794d45378e5016207f57848c 100644 --- a/spec/lib/gitlab/ci/config/external/mapper/filter_spec.rb +++ b/spec/lib/gitlab/ci/config/external/mapper/filter_spec.rb @@ -29,18 +29,5 @@ [{ local: 'config/.gitlab-ci.yml', rules: [{ if: '$VARIABLE1' }] }] ) end - - context 'when FF `ci_support_include_rules_when_never` is disabled' do - before do - stub_feature_flags(ci_support_include_rules_when_never: false) - end - - it 'filters locations according to rules ignoring when:' do - is_expected.to eq( - [{ local: 'config/.gitlab-ci.yml', rules: [{ if: '$VARIABLE1' }] }, - { remote: 'https://testing.com/.gitlab-ci.yml', rules: [{ if: '$VARIABLE1', when: 'never' }] }] - ) - end - end end end diff --git a/spec/lib/gitlab/ci/config/external/rules_spec.rb b/spec/lib/gitlab/ci/config/external/rules_spec.rb index 1ba5caa1d4bcdc2610059b300fd8e36fd743e17d..25b7998ef5ea18c2f597dd921e70c10d8c0743f9 100644 --- a/spec/lib/gitlab/ci/config/external/rules_spec.rb +++ b/spec/lib/gitlab/ci/config/external/rules_spec.rb @@ -3,8 +3,7 @@ require 'spec_helper' RSpec.describe Gitlab::Ci::Config::External::Rules, feature_category: :pipeline_composition do - # Remove `project` property when FF `ci_support_include_rules_when_never` is removed - let(:context) { double(variables_hash: {}, project: nil) } + let(:context) { double(variables_hash: {}) } let(:rule_hashes) { [{ if: '$MY_VAR == "hello"' }] } subject(:rules) { described_class.new(rule_hashes) } @@ -19,11 +18,6 @@ end shared_examples 'when there is a rule with if' do |rule_matched_result = true, rule_not_matched_result = false| - # Remove this `before` block when FF `ci_support_include_rules_when_never` is removed - before do - allow(context).to receive(:project).and_return(nil) - end - context 'when the rule matches' do let(:context) { double(variables_hash: { 'MY_VAR' => 'hello' }) } @@ -70,28 +64,12 @@ let(:rule_hashes) { [{ if: '$MY_VAR == "hello"', when: 'never' }] } it_behaves_like 'when there is a rule with if', false, false - - context 'when FF `ci_support_include_rules_when_never` is disabled' do - before do - stub_feature_flags(ci_support_include_rules_when_never: false) - end - - it_behaves_like 'when there is a rule with if' - end end context 'with when: always' do let(:rule_hashes) { [{ if: '$MY_VAR == "hello"', when: 'always' }] } it_behaves_like 'when there is a rule with if' - - context 'when FF `ci_support_include_rules_when_never` is disabled' do - before do - stub_feature_flags(ci_support_include_rules_when_never: false) - end - - it_behaves_like 'when there is a rule with if' - end end context 'with when: <invalid string>' do @@ -115,28 +93,12 @@ let(:rule_hashes) { [{ exists: 'Dockerfile', when: 'never' }] } it_behaves_like 'when there is a rule with exists', false, false - - context 'when FF `ci_support_include_rules_when_never` is disabled' do - before do - stub_feature_flags(ci_support_include_rules_when_never: false) - end - - it_behaves_like 'when there is a rule with exists' - end end context 'with when: always' do let(:rule_hashes) { [{ exists: 'Dockerfile', when: 'always' }] } it_behaves_like 'when there is a rule with exists' - - context 'when FF `ci_support_include_rules_when_never` is disabled' do - before do - stub_feature_flags(ci_support_include_rules_when_never: false) - end - - it_behaves_like 'when there is a rule with exists' - end end context 'with when: <invalid string>' do