diff --git a/lib/pyxis/commands/components.rb b/lib/pyxis/commands/components.rb index 08f0e8b..0ab5199 100644 --- a/lib/pyxis/commands/components.rb +++ b/lib/pyxis/commands/components.rb @@ -35,9 +35,63 @@ def info result end + desc 'compare', 'Compare component versions of two reticulum builds' + exclusive do + at_least_one do + method_option :first_build, + aliases: '-fb', + desc: 'The first build ID', + required: false, + type: :numeric + method_option :first_container_tag, + aliases: '-fc', + desc: 'The first container tag excluding variant modifiers', + required: false, + type: :string + end + end + exclusive do + at_least_one do + method_option :second_build, + aliases: '-sb', + desc: 'The second build ID', + required: false, + type: :numeric + method_option :second_container_tag, + aliases: '-sc', + desc: 'The second container tag excluding variant modifiers', + required: false, + type: :string + end + end + def compare + comparison = ManagedVersioning::ComponentComparer.new( + ManagedVersioning::ComponentInfo.new( + build_id: options[:first_build], + container_tag: options[:first_container_tag] + ), + ManagedVersioning::ComponentInfo.new( + build_id: options[:second_build], + container_tag: options[:second_container_tag] + ) + ).execute + + raise Pyxis::MessageError, 'One of the builds does not exist' if comparison.nil? + + result = 'Comparison of each component' + comparison.each do |component, component_comparison| + commit_range = Presenter::CommitRange.new( + component_comparison[:project], + component_comparison[:first_version], + component_comparison[:second_version] + ).as_markdown + result += "\n#{component}: #{commit_range}" + end + result + end + desc 'build', 'Start a reticulum build with specific versions' method_option :aquila_sha, desc: 'Commit SHA of aquila to build', type: :string - method_option :draco_sha, desc: 'Commit SHA of draco to build', type: :string method_option :sagittarius_sha, desc: 'Commit SHA of sagittarius to build', type: :string method_option :sculptor_sha, desc: 'Commit SHA of sculptor to build', type: :string method_option :taurus_sha, desc: 'Commit SHA of taurus to build', type: :string @@ -47,7 +101,6 @@ def build version_overrides = { aquila: options[:aquila_sha], - draco: options[:draco_sha], sagittarius: options[:sagittarius_sha], sculptor: options[:sculptor_sha], taurus: options[:taurus_sha], diff --git a/lib/pyxis/commands/release.rb b/lib/pyxis/commands/release.rb index 88ee370..9deaa78 100644 --- a/lib/pyxis/commands/release.rb +++ b/lib/pyxis/commands/release.rb @@ -46,7 +46,7 @@ def create_canary ) if pipeline.response.status != 201 - logger.warn('Failed to create pipeline for canary release', response: response.body) + logger.warn('Failed to create pipeline for canary release', response: pipeline.response.body) raise Pyxis::MessageError, 'Failed to create pipeline' end diff --git a/lib/pyxis/managed_versioning/component_comparer.rb b/lib/pyxis/managed_versioning/component_comparer.rb new file mode 100644 index 0000000..78a91c4 --- /dev/null +++ b/lib/pyxis/managed_versioning/component_comparer.rb @@ -0,0 +1,32 @@ +# frozen_string_literal: true + +module Pyxis + module ManagedVersioning + class ComponentComparer + attr_reader :first_info, :second_info + + def initialize(first_info, second_info) + @first_info = first_info + @second_info = second_info + end + + def execute + first_component_versions = first_info.execute + second_component_versions = second_info.execute + + return nil if first_component_versions.nil? || second_component_versions.nil? + + ([:reticulum] + Project.components).to_h do |component| + [ + component, + { + project: Project.get_project(component), + first_version: first_component_versions[component], + second_version: second_component_versions[component], + } + ] + end + end + end + end +end