Skip to content

Commit

Permalink
Add internal submission finished notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
nid90 committed Nov 14, 2024
1 parent d7d28bc commit c12fd96
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 3 deletions.
1 change: 1 addition & 0 deletions app/components/notification_settings_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class NotificationSettingsComponent < ViewComponent::Base
internal_release_finished: {icon: "v2/sparkles.svg", description: "The release finished successfully"},
internal_release_failed: {icon: "v2/alert_circle.svg", description: "The release failed"},
beta_submission_finished: {icon: "v2/sparkles.svg", description: "The beta submission finished successfully"},
internal_submission_finished: {icon: "v2/sparkles.svg", description: "The internal submission finished successfully"},
submission_failed: {icon: "v2/alert_circle.svg", description: "The beta submission failed"},
production_submission_started: {icon: "v2/play.svg", description: "A production submission started"},
production_submission_in_review: {icon: "v2/clipboard_list.svg", description: "A production submission is in review"},
Expand Down
1 change: 1 addition & 0 deletions app/libs/notifiers/slack/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Builder
internal_release_finished: Renderers::InternalReleaseFinished,
internal_release_failed: Renderers::InternalReleaseFailed,
beta_submission_finished: Renderers::BetaSubmissionFinished,
internal_submission_finished: Renderers::InternalSubmissionFinished,
submission_failed: Renderers::SubmissionFailed,
production_submission_started: Renderers::ProductionSubmissionStarted,
production_submission_in_review: Renderers::ProductionSubmissionInReview,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Notifiers
module Slack
class Renderers::InternalSubmissionFinished < Renderers::Base
TEMPLATE_FILE = "internal_submission_finished.json.erb".freeze
end
end
end
5 changes: 3 additions & 2 deletions app/models/google_firebase_submission.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class GoogleFirebaseSubmission < StoreSubmission
include Displayable

MAX_NOTES_LENGTH = 16_380
DEEP_LINK = Addressable::Template.new("https://appdistribution.firebase.google.com/testerapps/{platform}/releases/{external_release_id}")
DEEP_LINK = "https://appdistribution.firebase.google.com/testerapps/"
UploadNotComplete = Class.new(StandardError)

STAMPABLE_REASONS = %w[
Expand Down Expand Up @@ -200,7 +200,8 @@ def external_id

def deep_link
return if external_id.blank?
DEEP_LINK.expand(platform:, external_release_id: external_id).to_s
parsed_external_id = external_id.split("apps/").last
DEEP_LINK + parsed_external_id
end

def stamp_data(failure_message: nil)
Expand Down
5 changes: 5 additions & 0 deletions app/models/internal_release.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ def finish!
end
end

def rollout_complete!(submission)
notify!("Internal submission finished", :internal_submission_finished, submission.notification_params)
super
end

def tester_notes? = true

def release_notes? = false
Expand Down
1 change: 1 addition & 0 deletions app/models/notification_setting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class NotificationSetting < ApplicationRecord
internal_release_finished: "internal_release_finished",
internal_release_failed: "internal_release_failed",
beta_submission_finished: "beta_submission_finished",
internal_submission_finished: "internal_submission_finished",
submission_failed: "submission_failed",
production_submission_started: "production_submission_started",
production_submission_in_review: "production_submission_in_review",
Expand Down
11 changes: 11 additions & 0 deletions app/views/notifiers/slack/internal_submission_finished.json.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":sparkles: The internal build *<%= @release_version %> (<%= @build_number %>)* for commit <<%= @commit_url %>|<%= @commit_sha %>> has been sent to <%= @submission_channel %>."
}
}
]
}
1 change: 1 addition & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ en:
internal_release_finished: "Internal release finished"
internal_release_failed: "Internal release failed"
beta_submission_finished: "Beta submission finished"
internal_submission_finished: "Internal submission finished"
submission_failed: "Submission failed"
production_submission_started: "Production submission started"
production_submission_in_review: "Production submission in review"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# frozen_string_literal: true

class AddInternalSubmissionNotificationSetting < ActiveRecord::Migration[7.2]
def up
ActiveRecord::Base.transaction do
Train.all.where.not(notification_channel: nil).each do |train|
next if train.notification_settings.empty?

setting = train.notification_settings.find_by(kind: NotificationSetting.kinds[:internal_submission_finished])
next if setting.present?
internal_release_finished_setting = train.notification_settings.find_by(kind: NotificationSetting.kinds[:internal_release_finished])

train.notification_settings.create!(
kind: NotificationSetting.kinds[:internal_submission_finished],
notification_channels: internal_release_finished_setting.notification_channels,
active: internal_release_finished_setting.active
)
end
end
end

def down
raise ActiveRecord::IrreversibleMigration
end
end
2 changes: 1 addition & 1 deletion db/data_schema.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
DataMigrate::Data.define(version: 20241010215923)
DataMigrate::Data.define(version: 20241114183647)

0 comments on commit c12fd96

Please sign in to comment.