Commit 808e4acd authored by John Jarvis's avatar John Jarvis Committed by Yorick Peterse

Do nothing when there are no version file changes on omnibus

parent fac3e56f
......@@ -22,7 +22,7 @@ module ReleaseTools
def self.update_omnibus(target_branch, version_map)
return if SharedStatus.dry_run?
actions = version_changes(target_branch, version_map).map do |filename, contents|
actions = version_map.map do |filename, contents|
{
action: 'update',
file_path: "/#{filename}",
......@@ -30,13 +30,6 @@ module ReleaseTools
}
end
if actions.empty?
return ReleaseTools::GitlabClient.commit(
ReleaseTools::Project::OmnibusGitlab,
ref: target_branch
)
end
ReleaseTools::GitlabClient.create_commit(
ReleaseTools::Project::OmnibusGitlab,
target_branch,
......@@ -45,7 +38,7 @@ module ReleaseTools
)
end
def self.version_changes(target_branch, version_map)
def self.omnibus_version_changes?(target_branch, version_map)
project = ReleaseTools::Project::OmnibusGitlab
version_map.reject do |filename, contents|
ReleaseTools::GitlabClient.file_contents(
......@@ -53,7 +46,7 @@ module ReleaseTools
"/#{filename}",
target_branch
).chomp == contents
end
end.any?
end
end
end
......@@ -27,18 +27,7 @@ module ReleaseTools
def trigger_build(version_map)
if ref.match?(/\A\d+-\d+-auto-deploy-\d+\z/)
update_omnibus(version_map).tap do |commit|
tag_name = ReleaseTools::AutoDeploy::Naming.tag(
ee_ref: version_map['VERSION'],
omnibus_ref: commit.id
)
tag_message = +"Auto-deploy #{tag_name}\n\n"
tag_message << component_strings(version_map).join("\n")
tag_omnibus(tag_name, tag_message, commit)
tag_deployer(tag_name, tag_message, "master")
end
update_omnibus_for_autodeploy(version_map)
else
trigger_branch_build(version_map)
end
......@@ -46,6 +35,25 @@ module ReleaseTools
private
def update_omnibus_for_autodeploy(version_map)
unless ReleaseTools::ComponentVersions.omnibus_version_changes?(ref, version_map)
$stdout.puts "No version changes for components, not tagging omnibus"
return
end
update_omnibus(version_map).tap do |commit|
tag_name = ReleaseTools::AutoDeploy::Naming.tag(
ee_ref: version_map['VERSION'],
omnibus_ref: commit.id
)
tag_message = +"Auto-deploy #{tag_name}\n\n"
tag_message << component_strings(version_map).join("\n")
tag_omnibus(tag_name, tag_message, commit)
tag_deployer(tag_name, tag_message, "master")
end
end
def component_strings(version_map)
version_map.map { |component, version| "#{component}: #{version}" }
end
......
......@@ -57,21 +57,9 @@ describe ReleaseTools::ComponentVersions do
)
)
end
it 'does not create a commit with a version update without changes' do
allow(described_class).to receive(:version_changes).and_return({})
allow(fake_client).to receive(:commit).with(
ReleaseTools::Project::OmnibusGitlab, ref: 'foo-branch'
).and_return(commit)
expect(fake_client).not_to have_received(:create_commit)
without_dry_run do
expect(described_class.update_omnibus('foo-branch', version_map).id).to be('abcd')
end
end
end
describe '.version_changes' do
describe '.omnibus_version_changes?' do
let(:project) { ReleaseTools::Project::OmnibusGitlab }
let(:version_map) { { 'GITALY_SERVER_VERSION' => '1.33.0' } }
......@@ -80,11 +68,7 @@ describe ReleaseTools::ComponentVersions do
.with(project.path, "/GITALY_SERVER_VERSION", 'foo-branch')
.and_return("1.2.3\n")
expect(described_class.version_changes('foo-branch', version_map)).to match(
a_hash_including(
'GITALY_SERVER_VERSION' => '1.33.0'
)
)
expect(described_class.omnibus_version_changes?('foo-branch', version_map)).to be(true)
end
it 'rejects omnibus versions that have not changed' do
......@@ -92,11 +76,7 @@ describe ReleaseTools::ComponentVersions do
.with(project.path, "/GITALY_SERVER_VERSION", 'foo-branch')
.and_return("1.33.0\n")
expect(described_class.version_changes('foo-branch', version_map)).not_to match(
a_hash_including(
'GITALY_SERVER_VERSION' => '1.33.0'
)
)
expect(described_class.omnibus_version_changes?('foo-branch', version_map)).to be(false)
end
end
end
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