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

Add manual retries for submissions #719

Merged
merged 13 commits into from
Jan 17, 2025
2 changes: 1 addition & 1 deletion app/components/alert_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<%= render IconComponent.new("info.svg", size: :md) %>
<span class="font-semibold"><%= type.to_s.humanize %>:</span>
</div>
<%= title %>
<div class="flex flex-wrap gap-1 items-start"><%= title %></div>
</div>

<% if dismissible %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@
<% card.with_action do %>
<% if submission.triggerable? %>
<%= render ButtonComponent.new(label: "Send to #{submission.display}",
scheme: :default,
type: :button,
options: trigger_store_submission_path(submission),
html_options: html_opts(:patch, "Are you sure you want to send this submission to #{submission.display}?"),
size: :xxs) do |b| %>
auto_label_case: false,
scheme: :default,
type: :button,
options: trigger_store_submission_path(submission),
html_options: html_opts(:patch, "Are you sure you want to send this submission to #{submission.display}?"),
size: :xxs) do |b| %>
<% b.with_icon(submission_logo_bw, size: :md) %>
<% end %>
<% end %>
<% if submission.retryable? %>
<%= render ButtonComponent.new(label: "Retry sending to #{submission.display}",
scheme: :default,
type: :button,
options: retry_store_submission_path(submission),
html_options: html_opts(:patch, "Are you sure you want to retry the submission to #{submission.display}?"),
size: :xxs) do |b| %>
auto_label_case: false,
scheme: :default,
type: :button,
options: retry_store_submission_path(submission),
html_options: html_opts(:patch, "Are you sure you want to retry the submission to #{submission.display}?"),
size: :xxs) do |b| %>
<% b.with_icon(submission_logo_bw, size: :md) %>
<% end %>
<% end %>
Expand All @@ -41,6 +43,10 @@
<% end %>
</div>

<% if submission.failed? && submission.last_failed_event.present? %>
<%= render V2::AlertComponent.new(type: :error, title: raw(submission.last_failed_event.message), full_screen: false) %>
<% end %>

<%= render partial: "shared/play_store_review_rejected", locals: { show: submission.failed_with_action_required?,
build:,
actionable: true,
Expand All @@ -58,11 +64,11 @@
<% component.with_data_set(title: "Dashboard") do %>
<% if submission.store_link.present? %>
<%= render ButtonComponent.new(scheme: :naked_icon,
type: :link_external,
options: submission.store_link,
html_options: { class: "text-xs" },
authz: false,
size: :none) do |b| %>
type: :link_external,
options: submission.store_link,
html_options: { class: "text-xs" },
authz: false,
size: :none) do |b| %>
<% b.with_icon("external_link.svg", size: :md) %>
<% end %>
<% else %>
Expand Down
107 changes: 56 additions & 51 deletions app/components/live_release/prod_release/submission_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<div class="flex flex-col item-gap-default">
<% if cascading_rollout_actionable? %>
<%= render AlertComponent.new(kind: :announcement,
type: :announce,
title: "There's a pending rollout to complete",
full_screen: false) do %>
type: :announce,
title: "There's a pending rollout to complete",
full_screen: false) do %>

<div class="flex flex-col gap-2 mt-1 text-sm">
<p>
Expand All @@ -27,13 +27,13 @@
) %>

<%= render ButtonComponent.new(label: "Go to previous rollout ↗",
scheme: :link,
type: :link_external,
options: previously_completed_release_link,
html_options: {class: "text-sm"},
authz: false,
size: :none,
arrow: :none) %>
scheme: :link,
type: :link_external,
options: previously_completed_release_link,
html_options: { class: "text-sm" },
authz: false,
size: :none,
arrow: :none) %>
</div>
</div>
<% end %>
Expand All @@ -45,19 +45,19 @@
</div>
<% end %>

<%= render partial: "shared/play_store_review_rejected", locals: {show: show_blocked_message?,
build: current_build,
actionable: false} %>
<%= render partial: "shared/play_store_review_rejected", locals: { show: show_blocked_message?,
build: current_build,
actionable: false } %>

<% if @new_submission_prompt %>
<%= render AlertComponent.new(kind: :announcement, type: :announce, title: "New RC Build is available") do |ann| %>
<% modal = ann.with_announcement_modal(title: "Available builds", subtitle: "Choose a build to send for submission to the store") %>
<% modal.with_button(label: "Start a new submission", scheme: :default, type: :action, size: :xxs) %>
<% modal.with_body do %>
<% render FormComponent.new(model: [release, release_platform_run, release_platform_run.production_releases.new],
scope: :production_release,
url: run_production_path(release_platform_run),
free_form: true) do |form| %>
scope: :production_release,
url: run_production_path(release_platform_run),
free_form: true) do |form| %>
<%= form.F.labeled_select :build_id, "Select a build", build_opts %>
<% form.with_action do %>
<%= form.F.authz_submit "Create submission", "mail.svg" %>
Expand Down Expand Up @@ -99,10 +99,10 @@

<% if @blocked_notice %>
<%= render AlertComponent.new(kind: :banner,
type: :notice,
title: "Release to production is blocked",
full_screen: false,
info: blocked_release_info[:info]) do %>
type: :notice,
title: "Release to production is blocked",
full_screen: false,
info: blocked_release_info[:info]) do %>
<%= blocked_release_info[:message] %>
<% end %>
<% end %>
Expand All @@ -118,9 +118,9 @@
<% button.with_icon("pencil.svg") %>
<% modal.with_body do %>
<%= render FormComponent.new(model: [release, release_platform_run, submission],
scope: :store_submission,
url: store_submission_path(id),
free_form: true) do |form| %>
scope: :store_submission,
url: store_submission_path(id),
free_form: true) do |form| %>
<%= form.F.labeled_select :build_id, "Select a build", build_opts(default: current_build) %>

<% form.with_action do %>
Expand All @@ -145,11 +145,12 @@
<% card.with_action do %>
<% if submission.retryable? %>
<%= render ButtonComponent.new(label: "Retry sending to #{submission.provider.display}",
scheme: :default,
type: :button,
options: retry_store_submission_path(submission),
html_options: html_opts(:patch, "Are you sure you want to retry the submission to #{submission.display}?"),
size: :xxs) do |b| %>
auto_label_case: false,
scheme: :default,
type: :button,
options: retry_store_submission_path(submission),
html_options: html_opts(:patch, "Are you sure you want to retry the submission to #{submission.display}?"),
size: :xxs) do |b| %>
<% b.with_icon(submission_logo_bw, size: :md) %>
<% end %>
<% end %>
Expand All @@ -164,10 +165,10 @@
<div class="flex flex-col gap-6">
<%= render LiveRelease::PreviewSubmissionComponent.new(submission) %>
<%= render ButtonComponent.new(scheme: :default,
type: :button,
label: "Submit for review",
options: submit_for_review_store_submission_path(id),
html_options: {method: :patch, data: {turbo_method: :patch}}) %>
type: :button,
label: "Submit for review",
options: submit_for_review_store_submission_path(id),
html_options: { method: :patch, data: { turbo_method: :patch } }) %>
</div>
<% end %>
<% end %>
Expand All @@ -176,28 +177,32 @@

<div class="flex flex-col item-gap-default text-secondary text-xs">
<%= render LiveRelease::BuildComponent.new(current_build,
show_metadata: false,
show_ci: false,
show_activity: false,
show_commit: false,
show_compact_metadata: true) %>
show_metadata: false,
show_ci: false,
show_activity: false,
show_commit: false,
show_compact_metadata: true) %>

<div class="flex flex-row gap-2 items-center">
<%= render IconComponent.new(store_icon, size: :xl) %>
<%= render BadgeComponent.new(**status) %>
</div>

<% if submission.failed? && submission.last_failed_event.present? %>
<%= render V2::AlertComponent.new(type: :error, title: raw(submission.last_failed_event.message), full_screen: false) %>
<% end %>

<%= render LiveRelease::BuildComponent.new(current_build,
show_number: false,
show_metadata: true,
show_ci: false,
show_activity: false,
show_commit: true) %>
show_number: false,
show_metadata: true,
show_ci: false,
show_activity: false,
show_commit: true) %>

<%= render partial: "shared/play_store_review_rejected", locals: {show: submission.failed_with_action_required?,
build: current_build,
actionable: true,
channel_name: submission.submission_channel.name} %>
<%= render partial: "shared/play_store_review_rejected", locals: { show: submission.failed_with_action_required?,
build: current_build,
actionable: true,
channel_name: submission.submission_channel.name } %>

<%= render SectionComponent.new(style: :titled, title: "External info", size: :micro) do %>
<div class="flex">
Expand All @@ -206,11 +211,11 @@
<% component.with_data_set(title: "Dashboard") do %>
<% if external_link.present? %>
<%= render ButtonComponent.new(scheme: :naked_icon,
type: :link_external,
options: external_link,
html_options: {class: "text-xs"},
authz: false,
size: :none) do |b| %>
type: :link_external,
options: external_link,
html_options: { class: "text-xs" },
authz: false,
size: :none) do |b| %>
<% b.with_icon("external_link.svg", size: :md) %>
<% end %>
<% else %>
Expand Down
7 changes: 5 additions & 2 deletions app/models/app_store_submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# approved_at :datetime
# config :jsonb
# failure_reason :string
# last_stable_status :string
# name :string
# parent_release_type :string indexed => [parent_release_id]
# prepared_at :datetime
Expand Down Expand Up @@ -90,7 +91,7 @@ class AppStoreSubmission < StoreSubmission
transitions from: :preparing, to: :prepared
end

event :fail_prepare, before: :set_failure_reason, after_commit: :on_fail_prepare! do
event :fail_prepare, before: :set_failure_context, after_commit: :on_fail_prepare! do
transitions from: :preparing, to: :failed_prepare
end

Expand Down Expand Up @@ -121,13 +122,15 @@ class AppStoreSubmission < StoreSubmission
transitions from: [:submitted_for_review, :approved, :cancelling], to: :cancelled
end

event :fail, before: :set_failure_reason, after_commit: :on_fail! do
event :fail, before: :set_failure_context, after_commit: :on_fail! do
transitions to: :failed
end
end

after_create_commit :poll_external_status

def retryable? = failed?

def pre_review? = PRE_PREPARE_STATES.include?(status)

def change_build? = CHANGEABLE_STATES.include?(status) && editable?
Expand Down
1 change: 1 addition & 0 deletions app/models/deprecated_submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# approved_at :datetime
# config :jsonb
# failure_reason :string
# last_stable_status :string
# name :string
# parent_release_type :string indexed => [parent_release_id]
# prepared_at :datetime
Expand Down
14 changes: 10 additions & 4 deletions app/models/google_firebase_submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# approved_at :datetime
# config :jsonb
# failure_reason :string
# last_stable_status :string
# name :string
# parent_release_type :string indexed => [parent_release_id]
# prepared_at :datetime
Expand Down Expand Up @@ -56,8 +57,8 @@ class GoogleFirebaseSubmission < StoreSubmission
state :created, initial: true
state(*STATES.keys)

event :preprocess do
transitions from: :created, to: :preprocessing
event :preprocess, after_commit: :on_preprocess! do
transitions from: [:created, :failed], to: :preprocessing
end

event :prepare, after_commit: :on_prepare! do
Expand All @@ -69,11 +70,13 @@ class GoogleFirebaseSubmission < StoreSubmission
transitions to: :finished
end

event :fail, before: :set_failure_reason, after_commit: :on_fail! do
event :fail, before: :set_failure_context, after_commit: :on_fail! do
transitions to: :failed
end
end

def retryable? = failed?

def trigger!
return unless actionable?
return unless may_prepare?
Expand All @@ -82,7 +85,6 @@ def trigger!
# return mock_upload_to_firebase if sandbox_mode?

preprocess!
StoreSubmissions::GoogleFirebase::UploadJob.perform_later(id)
end

def upload_build!
Expand Down Expand Up @@ -157,6 +159,10 @@ def prepare_and_update!(release_info, build_status = nil)
end
end

def on_preprocess!
StoreSubmissions::GoogleFirebase::UploadJob.perform_later(id)
end

def on_prepare!
StoreSubmissions::GoogleFirebase::PrepareForReleaseJob.perform_later(id)
end
Expand Down
Loading
Loading