Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report multibuild flavors if package is multibuild #12089

Merged
merged 2 commits into from
Jan 20, 2022
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
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) }))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use short_package_name anymore in ReportToScmJob where this payload is used, so this why we remove this key from the payload.

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