Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 55 additions & 2 deletions lib/pyxis/commands/components.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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],
Expand Down
2 changes: 1 addition & 1 deletion lib/pyxis/commands/release.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
32 changes: 32 additions & 0 deletions lib/pyxis/managed_versioning/component_comparer.rb
Original file line number Diff line number Diff line change
@@ -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
Loading