...
 
Commits (3)
......@@ -19,6 +19,7 @@ module ReleaseTools
def_delegator :client, :update_variable
def_delegator :client, :create_commit
def_delegator :client, :create_tag
end
class MissingMilestone
......
# frozen_string_literal: true
require 'active_support/core_ext/string/access'
module ReleaseTools
class PassingBuild
attr_reader :project, :ref
......@@ -23,17 +25,34 @@ module ReleaseTools
$stdout.puts "#{component}: #{version}".indent(4)
end
trigger_build(versions) if args.trigger_build
# TODO: Move up to Rake task so it's explicit, and isolate $stdout
if args.trigger_build
commit = update_omnibus(versions)
tag_omnibus(commit, versions)
end
end
def trigger_build(version_map)
commit = ReleaseTools::ComponentVersions.update_omnibus(ref, version_map)
def update_omnibus(version_map)
ReleaseTools::ComponentVersions.update_omnibus(ref, version_map).tap do |commit|
url = commit_url(ReleaseTools::Project::OmnibusGitlab, commit.short_id)
$stdout.puts "Updated Omnibus versions at #{url}".indent(4)
end
end
url = commit_url(ReleaseTools::Project::OmnibusGitlab, commit.short_id)
def tag_omnibus(commit, versions)
prod_client = ReleaseTools::GitlabClient
$stdout.puts "Updated Omnibus versions at #{url}".indent(4)
tag_name = ReleaseTools::AutoDeploy::Naming.tag(
ee_ref: versions['VERSION'],
omnibus_ref: commit.id
)
# TODO: Tagging
prod_client.create_tag(
ReleaseTools::Project::OmnibusGitlab,
tag_name,
commit.id
)
end
private
......
......@@ -24,7 +24,7 @@ describe ReleaseTools::PassingBuild do
.to raise_error(/Unable to find a passing/)
end
it 'fetches component versions', :silence_stdout do
it 'updates and tags Omnibus when `trigger_build` is true', :silence_stdout do
expect(fake_commits).to receive(:latest_dev_green_build_commit)
.and_return(fake_commit)
......@@ -32,26 +32,17 @@ describe ReleaseTools::PassingBuild do
.to receive(:get).with(project, fake_commit.id)
.and_return(version_map)
expect(service).not_to receive(:trigger_build)
service.execute(double(trigger_build: false))
end
it 'triggers a build when specified', :silence_stdout do
expect(fake_commits).to receive(:latest_dev_green_build_commit)
expect(service).to receive(:update_omnibus)
.with(version_map)
.and_return(fake_commit)
expect(ReleaseTools::ComponentVersions)
.to receive(:get).with(project, fake_commit.id)
.and_return(version_map)
expect(service).to receive(:trigger_build).with(version_map)
expect(service).to receive(:tag_omnibus)
.with(fake_commit, version_map)
service.execute(double(trigger_build: true))
end
end
describe '#trigger_build' do
describe '#update_omnibus' do
let(:fake_client) { spy }
it 'updates Omnibus versions', :silence_stdout do
......@@ -59,7 +50,11 @@ describe ReleaseTools::PassingBuild do
.to receive(:update_omnibus).with('master', version_map)
.and_return(double('Commit', short_id: 'abcdefg'))
service.trigger_build(version_map)
service.update_omnibus(version_map)
end
end
describe '#tag_omnibus' do
# TODO (rspeicher): All of it!
end
end