Skip to content

Commit

Permalink
[fastlane-core] recommends to retry uploading when AltoolTransporterE…
Browse files Browse the repository at this point in the history
…xecutor crashes (fastlane#21536)

* Force FastlanePty.spawn to return exit code if it ends up being nil for whatever reason

* Actually, let's implement the fix right where the problem occurs, and add a test

* Update fastlane_core/lib/fastlane_core/itunes_transporter.rb

Co-authored-by: Aaron Brager <getaaron@gmail.com>

* Remove unneeded nil catch given fastlane#21618

* Write more accurate test

---------

Co-authored-by: Aaron Brager <getaaron@gmail.com>
  • Loading branch information
2 people authored and SubhrajyotiSen committed Jan 17, 2024
1 parent fe281f4 commit 3ed58be
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions fastlane_core/lib/fastlane_core/itunes_transporter.rb
Expand Up @@ -215,6 +215,8 @@ class AltoolTransporterExecutor < TransporterExecutor

private_constant :ERROR_REGEX

attr_reader :errors

def execute(command, hide_output)
if Helper.test?
yield(nil) if block_given?
Expand Down Expand Up @@ -244,6 +246,7 @@ def execute(command, hide_output)
end

@errors << "The call to the altool completed with a non-zero exit status: #{exit_status}. This indicates a failure." unless exit_status.zero?
@errors << "-1 indicates altool exited abnormally; try retrying (see https://github.com/fastlane/fastlane/issues/21535)" if exit_status == -1

unless @errors.empty? || @all_lines.empty?
# Print the last lines that appear after the last error from the logs
Expand Down
17 changes: 17 additions & 0 deletions fastlane_core/spec/itunes_transporter_spec.rb
Expand Up @@ -1396,4 +1396,21 @@ def xcrun_download_command(provider_short_name = nil, jwt: nil)
end
end
end

describe FastlaneCore::AltoolTransporterExecutor do
let(:upload_cmd) { "xcrun altool --upload-app --apiKey #{api_key[:key_id]} --apiIssuer #{api_key[:issuer_id]} -t macos -f /tmp/my.app.id.itmsp -k 100000" }
let(:instance) { described_class.new }
describe "#execute" do
it "logs specific info about altool crash if exit code is -1" do
# remove test behavior, we actually want FastlanePty.spawn to be called here
allow(FastlaneCore::Helper).to receive(:test?).and_return(false)
# force the nil return of FastlanePty.spawn
allow(FastlaneCore::FastlanePty).to receive(:spawn).and_return(-1)
expect(instance.execute(upload_cmd, false)).to eq(false)
expect(instance.errors).to include(
"-1 indicates altool exited abnormally; try retrying (see https://github.com/fastlane/fastlane/issues/21535)"
)
end
end
end
end

0 comments on commit 3ed58be

Please sign in to comment.