From 72ae7afefac26558e5726d9dd0772a55a8c0eb75 Mon Sep 17 00:00:00 2001 From: Furkan Ayhan <furkanayhn@gmail.com> Date: Wed, 7 Feb 2024 10:26:47 +0100 Subject: [PATCH] Enable refactoring Project.has_ci_config_file? This commit removes the feature flag `ci_refactor_has_ci_config_file`. Related to https://gitlab.com/gitlab-com/gl-infra/production/-/issues/17406 Changelog: other --- app/models/project.rb | 8 +-- app/models/repository.rb | 1 - .../ci_refactor_has_ci_config_file.yml | 9 --- spec/models/project_spec.rb | 55 +++++-------------- 4 files changed, 17 insertions(+), 56 deletions(-) delete mode 100644 config/feature_flags/gitlab_com_derisk/ci_refactor_has_ci_config_file.yml diff --git a/app/models/project.rb b/app/models/project.rb index 7f1c3cd475c2..8cf4795d97ec 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -2390,12 +2390,8 @@ def has_ci? end def has_ci_config_file? - if ::Feature.enabled?(:ci_refactor_has_ci_config_file, self, type: :gitlab_com_derisk) - strong_memoize(:has_ci_config_file) do - ci_config_for('HEAD').present? - end - else - repository.gitlab_ci_yml.present? + strong_memoize(:has_ci_config_file) do + ci_config_for('HEAD').present? end end diff --git a/app/models/repository.rb b/app/models/repository.rb index cd3c4f7500ff..1c052db44847 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -675,7 +675,6 @@ def gitignore cache_method :gitignore # Deprecated, use `project.has_ci_config_file?` instead. - # Can be removed with the FF `ci_refactor_has_ci_config_file`. def gitlab_ci_yml file_on_head(:gitlab_ci) end diff --git a/config/feature_flags/gitlab_com_derisk/ci_refactor_has_ci_config_file.yml b/config/feature_flags/gitlab_com_derisk/ci_refactor_has_ci_config_file.yml deleted file mode 100644 index b083a7873f1c..000000000000 --- a/config/feature_flags/gitlab_com_derisk/ci_refactor_has_ci_config_file.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -name: ci_refactor_has_ci_config_file -feature_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/26169 -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/141990 -rollout_issue_url: https://gitlab.com/gitlab-com/gl-infra/production/-/issues/17406 -milestone: '16.9' -group: group::pipeline authoring -type: gitlab_com_derisk -default_enabled: false diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 3d5ccbc6feb1..a275f080b1fd 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -5347,57 +5347,32 @@ def has_external_wiki describe '#has_ci_config_file?' do subject(:has_ci_config_file) { project.has_ci_config_file? } - # Extract these from `shared_examples` when the FF ci_refactor_has_ci_config_file is removed. - shared_examples '#has_ci_config_file?' do - context 'when the repository does not exist' do - let_it_be(:project) { create(:project) } - - it { is_expected.to be_falsey } - end - - context 'when the repository has a .gitlab-ci.yml file' do - let_it_be(:project) { create(:project, :small_repo, files: { '.gitlab-ci.yml' => 'test' }) } + context 'when the repository does not exist' do + let_it_be(:project) { create(:project) } - it { is_expected.to be_truthy } - end + it { is_expected.to be_falsey } + end - context 'when the repository does not have a .gitlab-ci.yml file' do - let_it_be(:project) { create(:project, :small_repo, files: { 'README.md' => 'hello' }) } + context 'when the repository has a .gitlab-ci.yml file' do + let_it_be(:project) { create(:project, :small_repo, files: { '.gitlab-ci.yml' => 'test' }) } - it { is_expected.to be_falsey } - end + it { is_expected.to be_truthy } end - context 'when the FF ci_refactor_has_ci_config_file is enabled' do - it_behaves_like '#has_ci_config_file?' - - context 'when the repository has a custom CI config file' do - let_it_be(:project) { create(:project, :small_repo, files: { 'my_ci_file.yml' => 'test' }) } + context 'when the repository does not have a .gitlab-ci.yml file' do + let_it_be(:project) { create(:project, :small_repo, files: { 'README.md' => 'hello' }) } - before do - project.ci_config_path = 'my_ci_file.yml' - end - - it { is_expected.to be_truthy } - end + it { is_expected.to be_falsey } end - context 'when the FF ci_refactor_has_ci_config_file is disabled' do + context 'when the repository has a custom CI config file' do + let_it_be(:project) { create(:project, :small_repo, files: { 'my_ci_file.yml' => 'test' }) } + before do - stub_feature_flags(ci_refactor_has_ci_config_file: false) + project.ci_config_path = 'my_ci_file.yml' end - it_behaves_like '#has_ci_config_file?' - - context 'when the repository has a custom CI config file' do - let_it_be(:project) { create(:project, :small_repo, files: { 'my_ci_file.yml' => 'test' }) } - - before do - project.ci_config_path = 'my_ci_file.yml' - end - - it { is_expected.to be_falsey } - end + it { is_expected.to be_truthy } end end -- GitLab