Commit 69c52b77 authored by drew's avatar drew Committed by Shinya Maeda

Remove CHANGED_PATH/URL CI variable code

This code was part of a proof-of-concept that lived behind a
feature flag that was never turned on. We don't need it, and
we should remove to code so as to prevent its use.
parent d762147b
......@@ -526,7 +526,6 @@ module Ci
.concat(job_jwt_variables)
.concat(scoped_variables)
.concat(job_variables)
.concat(environment_changed_page_variables)
.concat(persisted_environment_variables)
.to_runner_variables
end
......@@ -563,15 +562,6 @@ module Ci
end
end
def environment_changed_page_variables
Gitlab::Ci::Variables::Collection.new.tap do |variables|
break variables unless environment_status && Feature.enabled?(:modifed_path_ci_variables, project)
variables.append(key: 'CI_MERGE_REQUEST_CHANGED_PAGE_PATHS', value: environment_status.changed_paths.join(','))
variables.append(key: 'CI_MERGE_REQUEST_CHANGED_PAGE_URLS', value: environment_status.changed_urls.join(','))
end
end
def deploy_token_variables
Gitlab::Ci::Variables::Collection.new.tap do |variables|
break variables unless gitlab_deploy_token
......
......@@ -72,14 +72,6 @@ class EnvironmentStatus
.merge_request_diff_files.where(deleted_file: false)
end
def changed_paths
changes.map { |change| change[:path] }
end
def changed_urls
changes.map { |change| change[:external_url] }
end
def has_route_map?
project.route_map_for(sha).present?
end
......
---
name: modifed_path_ci_variables
introduced_by_url:
rollout_issue_url:
group:
type: development
default_enabled: false
......@@ -2554,94 +2554,6 @@ RSpec.describe Ci::Build do
end
end
describe 'CHANGED_PAGES variables' do
let(:route_map_yaml) do
<<~ROUTEMAP
- source: 'bar/branch-test.txt'
public: '/bar/branches'
- source: 'with space/README.md'
public: '/README'
ROUTEMAP
end
before do
allow_any_instance_of(Project)
.to receive(:route_map_for).with(/.+/)
.and_return(Gitlab::RouteMap.new(route_map_yaml))
end
context 'with a deployment environment and a merge request' do
let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let(:environment) { create(:environment, project: merge_request.project, name: "foo-#{project.default_branch}") }
let(:build) { create(:ci_build, pipeline: pipeline, environment: environment.name) }
let(:full_urls) do
[
File.join(environment.external_url, '/bar/branches'),
File.join(environment.external_url, '/README')
]
end
it 'populates CI_MERGE_REQUEST_CHANGED_PAGES_* variables' do
expect(subject).to include(
{
key: 'CI_MERGE_REQUEST_CHANGED_PAGE_PATHS',
value: '/bar/branches,/README',
public: true,
masked: false
},
{
key: 'CI_MERGE_REQUEST_CHANGED_PAGE_URLS',
value: full_urls.join(','),
public: true,
masked: false
}
)
end
context 'with a deployment environment and no merge request' do
let(:environment) { create(:environment, project: project, name: "foo-#{project.default_branch}") }
let(:build) { create(:ci_build, pipeline: pipeline, environment: environment.name) }
it 'does not append CHANGED_PAGES variables' do
ci_variables = subject.select { |var| var[:key] =~ /MERGE_REQUEST_CHANGED_PAGES/ }
expect(ci_variables).to be_empty
end
end
context 'with no deployment environment and a present merge request' do
let(:merge_request) { create(:merge_request, :with_detached_merge_request_pipeline, source_project: project, target_project: project) }
let(:build) { create(:ci_build, pipeline: merge_request.all_pipelines.take) }
it 'does not append CHANGED_PAGES variables' do
ci_variables = subject.select { |var| var[:key] =~ /MERGE_REQUEST_CHANGED_PAGES/ }
expect(ci_variables).to be_empty
end
end
context 'with no deployment environment and no merge request' do
it 'does not append CHANGED_PAGES variables' do
ci_variables = subject.select { |var| var[:key] =~ /MERGE_REQUEST_CHANGED_PAGES/ }
expect(ci_variables).to be_empty
end
end
end
context 'with the :modified_path_ci_variables feature flag disabled' do
before do
stub_feature_flags(modified_path_ci_variables: false)
end
it 'does not set CI_MERGE_REQUEST_CHANGED_PAGES_* variables' do
expect(subject.find { |var| var[:key] == 'CI_MERGE_REQUEST_CHANGED_PAGE_PATHS' }).to be_nil
expect(subject.find { |var| var[:key] == 'CI_MERGE_REQUEST_CHANGED_PAGE_URLS' }).to be_nil
end
end
end
context 'when build has user' do
let(:user_variables) do
[
......
......@@ -66,18 +66,6 @@ RSpec.describe EnvironmentStatus do
end
end
describe '#changed_paths' do
subject { environment_status.changed_urls }
it { is_expected.to contain_exactly("#{environment.external_url}/ruby-style-guide.html", "#{environment.external_url}/html/page.html") }
end
describe '#changed_urls' do
subject { environment_status.changed_paths }
it { is_expected.to contain_exactly('ruby-style-guide.html', 'html/page.html') }
end
describe '.for_merge_request' do
let(:admin) { create(:admin) }
let!(:pipeline) { create(:ci_pipeline, sha: sha, merge_requests_as_head_pipeline: [merge_request]) }
......
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