Skip to content

Commit

Permalink
Merge pull request #12089 from vpereira/fix_issue_11975
Browse files Browse the repository at this point in the history
Report multibuild flavors if package is multibuild
  • Loading branch information
vpereira committed Jan 20, 2022
2 parents 686b83b + 7943936 commit da29bd8
Show file tree
Hide file tree
Showing 212 changed files with 83,079 additions and 13,126 deletions.
22 changes: 17 additions & 5 deletions src/api/app/models/workflow/step.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ def target_project_name
end

def target_package
Package.find_by_project_and_name(target_project_name, target_package_name)
Package.get_by_project_and_name(target_project_name, target_package_name, follow_multibuild: true)
rescue Project::Errors::UnknownObjectError, Package::Errors::UnknownObjectError
# We rely on Package.get_by_project_and_name since it's the only way to work with multibuild packages.
# It's possible for a package to not exist, so we simply rescue and do nothing. The package will be created later in the step.
end

def create_or_update_subscriptions(package, workflow_filters)
Expand All @@ -43,7 +46,7 @@ def create_or_update_subscriptions(package, workflow_filters)
enabled: true,
token: @token,
package: package)
subscription.update!(payload: scm_webhook.payload.merge({ workflow_filters: workflow_filters, short_package_name: target_package_name(short_commit_sha: true) }))
subscription.update!(payload: scm_webhook.payload.merge({ workflow_filters: workflow_filters }))
end
end

Expand All @@ -68,6 +71,10 @@ def source_project_name
step_instructions[:source_project]
end

def target_package_names
[target_package_name(short_commit_sha: true)] + multibuild_flavors
end

def target_package_name(short_commit_sha: false)
package_name = step_instructions[:target_package] || source_package_name

Expand All @@ -88,6 +95,10 @@ def target_package_name(short_commit_sha: false)

private

def multibuild_flavors
target_package.multibuild_flavors.collect { |flavor| "#{target_package_name}:#{flavor}" }
end

def target_project_base_name
raise AbstractMethodCalled
end
Expand Down Expand Up @@ -156,9 +167,10 @@ def report_to_scm(workflow_filters)
workflow_repositories(target_project_name, workflow_filters).each do |repository|
# TODO: Fix n+1 queries
workflow_architectures(repository, workflow_filters).each do |architecture|
# We cannot report multibuild flavors here... so they will be missing from the initial report
SCMStatusReporter.new({ project: target_project_name, package: target_package_name, repository: repository.name, arch: architecture.name },
scm_webhook.payload.merge({ short_package_name: target_package_name(short_commit_sha: true) }), @token.scm_token).call
target_package_names.each do |target_package_name_or_flavor|
SCMStatusReporter.new({ project: target_project_name, package: target_package_name_or_flavor, repository: repository.name, arch: architecture.name },
scm_webhook.payload, @token.scm_token).call
end
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion src/api/app/services/scm_status_reporter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def github?
end

def status_options
{ context: "OBS: #{@event_subscription_payload[:short_package_name]} - #{@event_payload[:repository]}/#{@event_payload[:arch]}",
{ context: "OBS: #{@event_payload[:package]} - #{@event_payload[:repository]}/#{@event_payload[:arch]}",
target_url: Rails.application.routes.url_helpers.package_show_url(@event_payload[:project], @event_payload[:package], host: Configuration.obs_url) }
end

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit da29bd8

Please sign in to comment.