deliver/lib/deliver/upload_screenshots.rb in fastlane-2.156.1 vs deliver/lib/deliver/upload_screenshots.rb in fastlane-2.157.0

- old
+ new

@@ -177,27 +177,46 @@ end # Verify all screenshots states on App Store Connect are okay def retry_upload_screenshots_if_needed(iterator, states, number_of_screenshots, tries, localizations, screenshots_per_language) is_failure = states.fetch("FAILED", 0) > 0 - is_missing_screenshot = states.reduce(0) { |sum, (k, v)| sum + v } != number_of_screenshots && !screenshots_per_language.empty? + is_missing_screenshot = !screenshots_per_language.empty? && !verify_local_screenshots_are_uploaded(iterator, screenshots_per_language) + return unless is_failure || is_missing_screenshot - if is_failure || is_missing_screenshot - if tries.zero? - incomplete_screenshot_count = states.reject { |k, v| k == 'COMPLETE' }.reduce(0) { |sum, (k, v)| sum + v } - UI.user_error!("Failed verification of all screenshots uploaded... #{incomplete_screenshot_count} incomplete screenshot(s) still exist") - else - UI.error("Failed to upload all screenshots... Tries remaining: #{tries}") - # Delete bad entries before retry - iterator.each_app_screenshot do |_, _, app_screenshot| - app_screenshot.delete! unless app_screenshot.complete? - end - upload_screenshots(localizations, screenshots_per_language, tries: tries) + if tries.zero? + iterator.each_app_screenshot.select { |_, _, app_screenshot| app_screenshot.error? }.each do |localization, _, app_screenshot| + UI.error("#{app_screenshot.file_name} for #{localization.locale} has error(s) - #{app_screenshot.error_messages.join(', ')}") end + incomplete_screenshot_count = states.reject { |k, v| k == 'COMPLETE' }.reduce(0) { |sum, (k, v)| sum + v } + UI.user_error!("Failed verification of all screenshots uploaded... #{incomplete_screenshot_count} incomplete screenshot(s) still exist") + else + UI.error("Failed to upload all screenshots... Tries remaining: #{tries}") + # Delete bad entries before retry + iterator.each_app_screenshot do |_, _, app_screenshot| + app_screenshot.delete! unless app_screenshot.complete? + end + upload_screenshots(localizations, screenshots_per_language, tries: tries) end end + # Return `true` if all the local screenshots are uploaded to App Store Connect + def verify_local_screenshots_are_uploaded(iterator, screenshots_per_language) + # Check if local screenshots' checksum exist on App Store Connect + checksum_to_app_screenshot = iterator.each_app_screenshot.map { |_, _, app_screenshot| [app_screenshot.source_file_checksum, app_screenshot] }.to_h + + missing_local_screenshots = iterator.each_local_screenshot(screenshots_per_language).select do |_, _, local_screenshot, index| + checksum = UploadScreenshots.calculate_checksum(local_screenshot.path) + checksum_to_app_screenshot[checksum].nil? && index < 10 # if index is more than 10, it's skipped + end + + missing_local_screenshots.each do |_, _, screenshot, _| + UI.error("#{screenshot.path} is missing on App Store Connect.") + end + + missing_local_screenshots.empty? + end + def sort_screenshots(localizations) iterator = AppScreenshotIterator.new(localizations) # Re-order screenshots within app_screenshot_set worker = QueueWorker.new(NUMBER_OF_THREADS) do |app_screenshot_set| @@ -283,14 +302,12 @@ return screenshots end # helper method so Spaceship::Tunes.client.available_languages is easier to test def self.available_languages - if Helper.test? - FastlaneCore::Languages::ALL_LANGUAGES - else - Spaceship::Tunes.client.available_languages - end + # 2020-08-24 - Available locales are not available as an endpoint in App Store Connect + # Update with Spaceship::Tunes.client.available_languages.sort (as long as endpoint is avilable) + Deliver::Languages::ALL_LANGUAGES end # helper method to mock this step in tests def self.calculate_checksum(path) bytes = File.binread(path)