diff --git a/CHANGELOG.md b/CHANGELOG.md index e7a560983..9b8dcb475 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,7 +14,7 @@ _None_ ### Bug Fixes -_None_ +- Fix an issue where `prototype_build_details_comment` added some unexpected metadata rows in the comment table if we didn't use `firebase_app_distribution` (e.g. for Prototype Builds uploaded to S3 and not using FAD) [#642] ### Internal Changes diff --git a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/prototype_build_details_comment_action.rb b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/prototype_build_details_comment_action.rb index 5118edef9..09e4b8ebc 100644 --- a/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/prototype_build_details_comment_action.rb +++ b/lib/fastlane/plugin/wpmreleasetoolkit/actions/common/prototype_build_details_comment_action.rb @@ -102,12 +102,15 @@ def self.from_lane_context # @return [Hash] A hash of all the metadata, consolidated from both the explicit and the implicit ones # def self.generate_metadata_hash(params:, release_info:) + # Add explicit metadata provided by the caller metadata = params[:metadata]&.transform_keys(&:to_s) || {} # Add Firebase-specific metadata if available - metadata['Build Number'] ||= "#{release_info&.build_version}" - metadata['Version'] ||= "#{release_info&.display_version}" - metadata[release_info&.os == 'ios' ? 'Bundle ID' : 'Application ID'] ||= "#{release_info&.bundle_id}" + unless release_info.nil? + metadata['Build Number'] ||= "#{release_info.build_version}" + metadata['Version'] ||= "#{release_info.display_version}" + metadata[release_info.os == 'ios' ? 'Bundle ID' : 'Application ID'] ||= "#{release_info.bundle_id}" + end # Add git metadata metadata['Commit'] ||= ENV.fetch('BUILDKITE_COMMIT', nil) || other_action.last_git_commit[:abbreviated_commit_hash] diff --git a/spec/prototype_build_details_comment_action_spec.rb b/spec/prototype_build_details_comment_action_spec.rb index 4ec67a251..f4c7b0638 100644 --- a/spec/prototype_build_details_comment_action_spec.rb +++ b/spec/prototype_build_details_comment_action_spec.rb @@ -111,27 +111,65 @@ end end - describe 'app_icon' do + describe 'app_icon handling' do context 'when providing an URL' do it 'includes the icon in the intro text' do - comment = run_described_fastlane_action( - app_display_name: 'My Cool App', - app_icon: 'https://localhost/foo.png', - download_url: 'https://localhost/foo.apk' - ) - expect(comment).to include "App Icon📲 " + comment = run_described_fastlane_action(base_params.merge(app_icon: valid_app_icon_url)) + expect(comment).to include "App Icon📲 " end end context 'when providing an emoji code' do it 'includes the icon in the intro text' do - comment = run_described_fastlane_action( - app_display_name: 'My Cool App', - app_icon: ':jetpack:', - download_url: 'https://localhost/foo.apk' - ) + comment = run_described_fastlane_action(base_params.merge(app_icon: ':jetpack:')) expect(comment).to include "App Icon📲 " end + + it 'handles emoji codes with special characters' do + comment = run_described_fastlane_action(base_params.merge(app_icon: ':plus-one:')) + expect(comment).to include 'plus-one.png' + end + end + + context 'when no icon is provided' do + context 'when using Firebase App Distribution' do + let(:firebase_release_info) do + { + displayVersion: '28.7', + buildVersion: '1287003', + testingUri: 'https://appdistribution.firebase.google.com/testerapps/1:123456:ios:abcdef/releases/xyz', + firebaseConsoleUri: 'https://console.firebase.google.com/project/apps-test/appdistribution/app/ios:com.example.myapp/releases/xyz' + } + end + + before do + stub_const('Fastlane::Actions::SharedValues::FIREBASE_APP_DISTRO_RELEASE', :firebase_app_distro_release) + allow(Fastlane::Actions).to receive(:lane_context).and_return({ firebase_app_distro_release: firebase_release_info }) + end + + it 'uses the firebase icon' do + comment = run_described_fastlane_action(app_display_name: 'My App') + expect(comment).to include 'firebase.png' + end + end + + context 'when using a Firebase download URL' do + it 'uses the firebase icon' do + comment = run_described_fastlane_action( + app_display_name: 'My App', + download_url: 'https://appdistribution.firebase.google.com/testerapps/1:123456:ios:abcdef/releases/xyz' + ) + expect(comment).to include 'firebase.png' + end + end + + context 'when using a non-Firebase download URL' do + it 'does not include any icon' do + comment = run_described_fastlane_action(base_params.merge(app_icon: nil)) + expect(comment).not_to include 'firebase.png' + expect(comment).to match(/^

📲 You can test/) + end + end end end @@ -301,6 +339,17 @@ expect(comment).to include "Direct Downloadmyapp.apk" end + it 'does not include rows for FAD metadata' do + comment = run_described_fastlane_action( + app_display_name: 'My App', + download_url: 'https://example.com/myapp.apk' + ) + expect(comment).not_to include %r{.*Build Number.*} + expect(comment).not_to include %r{.*Version.*} + expect(comment).not_to include %r{.*Bundle ID.*} + expect(comment).not_to include %r{.*Application ID.*} + end + it 'does not include any default footnote if no explicit footnote is provided' do comment = run_described_fastlane_action( app_display_name: 'My App', @@ -346,15 +395,12 @@

App Icon📲 You can test the changes from this Pull Request in The Best App by scanning the QR code below to install the corresponding build.

- + - - -
App NameThe Best App
Version Name28.2
Version Code1280200108
FlavorDebug
Build Number
Version
Application ID
Commita1b2c3f
Direct Downloadbestapp.apk
@@ -379,14 +425,11 @@
📲 You can test the changes from this Pull Request in The Best App by scanning the QR code below to install the corresponding build. - + - - -
App NameThe Best App
Version Name28.2
Version Code1280200108
Build Number
Version
Application ID
Commita1b2c3f
Direct Downloadbestapp.apk
@@ -395,66 +438,4 @@ EXPECTED_COMMENT end end - - describe 'app_icon handling' do - context 'when providing an URL' do - it 'includes the icon in the intro text' do - comment = run_described_fastlane_action(base_params.merge(app_icon: valid_app_icon_url)) - expect(comment).to include "App Icon📲 " - end - end - - context 'when providing an emoji code' do - it 'includes the icon in the intro text' do - comment = run_described_fastlane_action(base_params.merge(app_icon: ':jetpack:')) - expect(comment).to include "App Icon📲 " - end - - it 'handles emoji codes with special characters' do - comment = run_described_fastlane_action(base_params.merge(app_icon: ':plus-one:')) - expect(comment).to include 'plus-one.png' - end - end - - context 'when no icon is provided' do - context 'when using Firebase App Distribution' do - let(:firebase_release_info) do - { - displayVersion: '28.7', - buildVersion: '1287003', - testingUri: 'https://appdistribution.firebase.google.com/testerapps/1:123456:ios:abcdef/releases/xyz', - firebaseConsoleUri: 'https://console.firebase.google.com/project/apps-test/appdistribution/app/ios:com.example.myapp/releases/xyz' - } - end - - before do - stub_const('Fastlane::Actions::SharedValues::FIREBASE_APP_DISTRO_RELEASE', :firebase_app_distro_release) - allow(Fastlane::Actions).to receive(:lane_context).and_return({ firebase_app_distro_release: firebase_release_info }) - end - - it 'uses the firebase icon' do - comment = run_described_fastlane_action(app_display_name: 'My App') - expect(comment).to include 'firebase.png' - end - end - - context 'when using a Firebase download URL' do - it 'uses the firebase icon' do - comment = run_described_fastlane_action( - app_display_name: 'My App', - download_url: 'https://appdistribution.firebase.google.com/testerapps/1:123456:ios:abcdef/releases/xyz' - ) - expect(comment).to include 'firebase.png' - end - end - - context 'when using a non-Firebase download URL' do - it 'does not include any icon' do - comment = run_described_fastlane_action(base_params.merge(app_icon: nil)) - expect(comment).not_to include 'firebase.png' - expect(comment).to match(/^

📲 You can test/) - end - end - end - end end