Add latest changes from gitlab-org/gitlab@16-1-stable-ee
This commit is contained in:
parent
6e30710b6d
commit
3dbdaea3d9
|
|
@ -59,6 +59,8 @@ RSpec.describe Tooling::Danger::StableBranch, feature_category: :delivery do
|
|||
end
|
||||
|
||||
context 'when not applicable' do
|
||||
let(:current_stable_branch) { '15-1-stable-ee' }
|
||||
|
||||
where(:stable_branch?, :security_mr?) do
|
||||
true | true
|
||||
false | true
|
||||
|
|
@ -67,7 +69,7 @@ RSpec.describe Tooling::Danger::StableBranch, feature_category: :delivery do
|
|||
|
||||
with_them do
|
||||
before do
|
||||
allow(fake_helper).to receive(:mr_target_branch).and_return(stable_branch? ? '15-1-stable-ee' : 'main')
|
||||
allow(fake_helper).to receive(:mr_target_branch).and_return(stable_branch? ? current_stable_branch : 'main')
|
||||
allow(fake_helper).to receive(:security_mr?).and_return(security_mr?)
|
||||
end
|
||||
|
||||
|
|
@ -239,7 +241,7 @@ RSpec.describe Tooling::Danger::StableBranch, feature_category: :delivery do
|
|||
end
|
||||
|
||||
context 'when not an applicable version' do
|
||||
let(:target_branch) { '14-9-stable-ee' }
|
||||
let(:target_branch) { '15-0-stable-ee' }
|
||||
|
||||
it 'warns about the package-and-test pipeline and the version' do
|
||||
expect(stable_branch).to receive(:warn).with(described_class::WARN_PACKAGE_AND_TEST_MESSAGE)
|
||||
|
|
@ -297,18 +299,6 @@ RSpec.describe Tooling::Danger::StableBranch, feature_category: :delivery do
|
|||
|
||||
it_behaves_like 'without a failure'
|
||||
end
|
||||
|
||||
context 'when too many version API requests are made' do
|
||||
let(:parsed_response) { [{ 'version' => '15.0.0' }] }
|
||||
|
||||
it 'adds a warning' do
|
||||
expect(HTTParty).to receive(:get).and_return(version_response).at_least(10).times
|
||||
expect(stable_branch).to receive(:warn).with(described_class::WARN_PACKAGE_AND_TEST_MESSAGE)
|
||||
expect(stable_branch).to receive(:warn).with(described_class::FAILED_VERSION_REQUEST_MESSAGE)
|
||||
|
||||
subject
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -146,26 +146,20 @@ module Tooling
|
|||
end
|
||||
|
||||
def targeting_patchable_version?
|
||||
raise VersionApiError if last_three_minor_versions.empty?
|
||||
raise VersionApiError if current_stable_version.empty?
|
||||
|
||||
last_three_minor_versions.include?(targeted_version)
|
||||
current_stable_version == targeted_version
|
||||
rescue VersionApiError
|
||||
warn FAILED_VERSION_REQUEST_MESSAGE
|
||||
true
|
||||
end
|
||||
|
||||
def last_three_minor_versions
|
||||
return [] unless versions
|
||||
def current_stable_version
|
||||
return unless versions
|
||||
|
||||
current_version = versions.first.match(VERSION_REGEX)
|
||||
version_1 = previous_minor_version(current_version)
|
||||
version_2 = previous_minor_version(version_1)
|
||||
|
||||
[
|
||||
version_to_minor_string(current_version),
|
||||
version_to_minor_string(version_1),
|
||||
version_to_minor_string(version_2)
|
||||
]
|
||||
version_to_minor_string(current_version)
|
||||
end
|
||||
|
||||
def targeted_version
|
||||
|
|
@ -173,7 +167,7 @@ module Tooling
|
|||
end
|
||||
|
||||
def versions(page = 1)
|
||||
version_api_endpoint = "https://version.gitlab.com/api/v1/versions?per_page=50&page=#{page}"
|
||||
version_api_endpoint = "https://version.gitlab.com/api/v1/versions?per_page=20&page=#{page}"
|
||||
response = HTTParty.get(version_api_endpoint) # rubocop:disable Gitlab/HTTParty
|
||||
|
||||
raise VersionApiError unless response.success?
|
||||
|
|
@ -183,33 +177,6 @@ module Tooling
|
|||
version_list.sort_by { |v| Gem::Version.new(v) }.reverse
|
||||
end
|
||||
|
||||
def previous_minor_version(version)
|
||||
previous_minor = version[:minor].to_i - 1
|
||||
|
||||
return "#{version[:major]}.#{previous_minor}".match(VERSION_REGEX) if previous_minor >= 0
|
||||
|
||||
fetch_last_minor_version_for_major(version[:major].to_i - 1)
|
||||
end
|
||||
|
||||
def fetch_last_minor_version_for_major(major)
|
||||
page = 1
|
||||
last_minor_version = nil
|
||||
|
||||
while last_minor_version.nil?
|
||||
last_minor_version = versions(page).find do |version|
|
||||
version.split('.').first.to_i == major
|
||||
end
|
||||
|
||||
break if page > 10
|
||||
|
||||
page += 1
|
||||
end
|
||||
|
||||
raise VersionApiError if last_minor_version.nil?
|
||||
|
||||
last_minor_version.match(VERSION_REGEX)
|
||||
end
|
||||
|
||||
def version_to_minor_string(version)
|
||||
"#{version[:major]}.#{version[:minor]}"
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue