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

Fix issue that uploading aab with mapping file #12856

Merged
merged 3 commits into from
Jul 22, 2018
Merged
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
26 changes: 14 additions & 12 deletions supply/lib/supply/uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@ def perform_upload
end
end

upload_binaries unless Supply.config[:skip_upload_apk]
upload_bundles unless Supply.config[:skip_upload_aab]
apk_version_codes = []
apk_version_codes.concat(upload_apks) unless Supply.config[:skip_upload_apk]
apk_version_codes.concat(upload_bundles) unless Supply.config[:skip_upload_aab]
upload_mapping(apk_version_codes)

# Only update tracks if we have version codes
# Updating a track with empty version codes can completely clear out a track
update_track(apk_version_codes) unless apk_version_codes.empty?

promote_track if Supply.config[:track_promote_to]

Expand Down Expand Up @@ -120,7 +126,7 @@ def upload_screenshots(language)
end
end

def upload_binaries
def upload_apks
apk_paths = [Supply.config[:apk]] unless (apk_paths = Supply.config[:apk_paths])
apk_paths.compact!

Expand All @@ -130,28 +136,24 @@ def upload_binaries
apk_version_codes.push(upload_binary_data(apk_path))
end

return apk_version_codes
end

def upload_mapping(apk_version_codes)
mapping_paths = [Supply.config[:mapping]] unless (mapping_paths = Supply.config[:mapping_paths])
mapping_paths.zip(apk_version_codes).each do |mapping_path, version_code|
if mapping_path
client.upload_mapping(mapping_path, version_code)
end
end

# Only update tracks if we have version codes
# Updating a track with empty version codes can completely clear out a track
update_track(apk_version_codes) unless apk_version_codes.empty?
end

def upload_bundles
aab_path = Supply.config[:aab]
return unless aab_path

UI.message("Preparing aab at path '#{aab_path}' for upload...")
apk_version_codes = [client.upload_bundle(aab_path)]

# Only update tracks if we have version codes
# Updating a track with empty version codes can completely clear out a track
update_track(apk_version_codes) unless apk_version_codes.empty?
return [client.upload_bundle(aab_path)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't updating tracks still necessary here? (Random drive by comment, but I'm curious as to why this function differs from the logic in the newly split upload_apks)

Copy link
Member

Choose a reason for hiding this comment

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

Same thoughts/concern there ^

@tmtrademarked Thanks for drive by commenting 😊

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The original logic sequence is below.

If uploading binary is apks

  1. Upload apks
  2. Upload mapping files
  3. Update track
  4. Upload bundle (not executed)
  5. Update track (not executed because of empty apk version codes)

If uploading binary is bundle

  1. Upload apks (not executed)
  2. Upload mapping (error caused by empty apk version codes)
  3. Update track (not executed because of empty apk version codes)
  4. Upload bundle
  5. Update track

Update track should be executed after upload apks or bundle and only once.
So, I split upload mapping and updating track function to execute after uploading both apk and bundle.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After fixing,

  1. Upload apks if upload type is apks
  2. Upload bundle if upload type is bundle
  3. Upload mapping
  4. Update track

I think that uploading logic order is not changed 😃

Copy link
Member

Choose a reason for hiding this comment

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

@chibatching Thanks for the explanation! I think the confusing thing was this diff removed update_track but never re-added it in back in. But looking at the whole file it looks like it its actually in the upload_mapping method - https://github.com/chibatching/fastlane/blob/49e2b1d6373efe9156ad7a3ad82932c043bf30fc/supply/lib/supply/uploader.rb#L146-L148

Thoughts on moving that to line 30 under the call to upload_mapping? I think that would make things easier to follow in this file since I don't think it has anything to do with mapping 😊

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you comments and I agree with you 😄
I fixed at b7e91f0!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@joshdholtz Could you review this?

end

private
Expand Down