Commit bd3ad449 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Merge branch...

Merge branch 'improve-the-contorability-on-ci_disable_validates_dependencies-feature-flag' into 'master'

Allow the dependency validation feature flag to be selectively disabled

See merge request gitlab-org/gitlab!51563
parents a516e4d1 619cd4a5
......@@ -103,7 +103,7 @@ module Ci
end
def valid_local?
return true if Feature.enabled?(:ci_disable_validates_dependencies)
return true unless Gitlab::Ci::Features.validate_build_dependencies?(project)
local.all?(&:valid_dependency?)
end
......
---
name: ci_validate_build_dependencies
introduced_by_url: https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/14009
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/257852
milestone: '10.3'
type: development
group: group::continuous integration
default_enabled: true
---
name: ci_disable_validates_dependencies
name: ci_validate_build_dependencies_override
introduced_by_url: https://gitlab.com/gitlab-org/gitlab-foss/-/merge_requests/14009
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/257847
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/257852
milestone: '10.3'
type: development
group: group::continuous integration
......
......@@ -375,7 +375,7 @@ default artifacts expiration setting, which you can find in the [CI/CD Admin set
> Introduced in GitLab 10.3.
To disable [the dependencies validation](../ci/yaml/README.md#when-a-dependent-job-fails),
you can enable the `ci_disable_validates_dependencies` feature flag from a Rails console.
you can enable the `ci_validate_build_dependencies_override` feature flag from a Rails console.
**In Omnibus installations:**
......@@ -388,7 +388,7 @@ you can enable the `ci_disable_validates_dependencies` feature flag from a Rails
1. Enable the feature flag to disable the validation:
```ruby
Feature.enable(:ci_disable_validates_dependencies)
Feature.enable(:ci_validate_build_dependencies_override)
```
**In installations from source:**
......@@ -403,7 +403,7 @@ you can enable the `ci_disable_validates_dependencies` feature flag from a Rails
1. Enable the feature flag to disable the validation:
```ruby
Feature.enable(:ci_disable_validates_dependencies)
Feature.enable(:ci_validate_build_dependencies_override)
```
## Set the maximum file size of the artifacts
......
......@@ -70,6 +70,11 @@ module Gitlab
def self.rules_variables_enabled?(project)
::Feature.enabled?(:ci_rules_variables, project, default_enabled: true)
end
def self.validate_build_dependencies?(project)
::Feature.enabled?(:ci_validate_build_dependencies, default_enabled: :yaml) &&
::Feature.disabled?(:ci_validate_build_dependencies_override, project)
end
end
end
end
......@@ -18,6 +18,10 @@ RSpec.describe Ci::BuildDependencies do
let!(:rubocop_test) { create(:ci_build, pipeline: pipeline, name: 'rubocop', stage_idx: 1, stage: 'test') }
let!(:staging) { create(:ci_build, pipeline: pipeline, name: 'staging', stage_idx: 2, stage: 'deploy') }
before do
stub_feature_flags(ci_validate_build_dependencies_override: false)
end
describe '#local' do
subject { described_class.new(job).local }
......@@ -360,4 +364,28 @@ RSpec.describe Ci::BuildDependencies do
expect(subject).to contain_exactly(1, 2, 3, 4)
end
end
describe '#valid?' do
subject { described_class.new(job).valid? }
let(:job) { rspec_test }
it { is_expected.to eq(true) }
context 'when a local dependency is invalid' do
before do
build.update_column(:erased_at, Time.current)
end
it { is_expected.to eq(false) }
context 'when ci_validate_build_dependencies_override feature flag is enabled' do
before do
stub_feature_flags(ci_validate_build_dependencies_override: job.project)
end
it { is_expected.to eq(true) }
end
end
end
end
......@@ -3605,7 +3605,7 @@ RSpec.describe Ci::Build do
context 'when validates for dependencies is enabled' do
before do
stub_feature_flags(ci_disable_validates_dependencies: false)
stub_feature_flags(ci_validate_build_dependencies_override: false)
end
let!(:pre_stage_job) { create(:ci_build, :success, pipeline: pipeline, name: 'test', stage_idx: 0) }
......@@ -3633,7 +3633,7 @@ RSpec.describe Ci::Build do
let(:options) { { dependencies: ['test'] } }
before do
stub_feature_flags(ci_disable_validates_dependencies: true)
stub_feature_flags(ci_validate_build_dependencies_override: true)
end
it_behaves_like 'validation is not active'
......
......@@ -455,7 +455,7 @@ module Ci
end
before do
stub_feature_flags(ci_disable_validates_dependencies: false)
stub_feature_flags(ci_validate_build_dependencies_override: false)
end
let!(:pre_stage_job) { create(:ci_build, :success, pipeline: pipeline, name: 'test', stage_idx: 0) }
......@@ -470,7 +470,7 @@ module Ci
context 'when validates for dependencies is enabled' do
before do
stub_feature_flags(ci_disable_validates_dependencies: false)
stub_feature_flags(ci_validate_build_dependencies_override: false)
end
it_behaves_like 'validation is active'
......@@ -478,7 +478,7 @@ module Ci
context 'when validates for dependencies is disabled' do
before do
stub_feature_flags(ci_disable_validates_dependencies: true)
stub_feature_flags(ci_validate_build_dependencies_override: true)
end
it_behaves_like 'validation is not active'
......
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