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

Updated plugin to support array with paths instead of single path #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,36 @@ module Fastlane
module Actions
class InstabugOfficialAction < Action
def self.run(params)
api_token = params[:api_token]

if params[:dsym_path].end_with?('.zip')
dsym_zip_path = params[:dsym_path].shellescape
else
dsym_path = params[:dsym_path]
dsym_zip_path = ZipAction.run(path: dsym_path).shellescape
end

endpoint = 'https://api.instabug.com/api/ios/v1/dsym'

command = "curl #{endpoint} --write-out %{http_code} --silent --output /dev/null -F dsym=@\"#{dsym_zip_path}\" -F token=\"#{api_token}\""

UI.verbose command

return command if Helper.test?

result = Actions.sh(command)
if result == "200"
UI.success 'dSYM is successfully uploaded to Instabug 🤖'
else
UI.error "Something went wrong during Instabug dSYM upload. Status code is #{result}"
end
end
api_token = params[:api_token]

endpoint = "https://api.instabug.com/api/sdk/v3/symbols_files"
command = "curl #{endpoint} --write-out %{http_code} --silent --output /dev/null -F os=\"ios\" -F application_token=\"#{api_token}\" -F symbols_file="

curlCommand = ""
single_path = params[:dsym_path]

if single_path != nil
curlCommand += build_single_file_command(command, single_path)
else
dsym_paths = params[:dsym_array_paths].uniq
Copy link

Choose a reason for hiding this comment

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

First thanks a lot for your contributions🙏. But I have a single question why you did not add then in a zip file and upload it once instead of upload each file separately.

Copy link
Author

Choose a reason for hiding this comment

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

To be honest I didn't thought about that 😂 but even if I did, I wouldn't be sure if that even works. Because I'm also not a ruby developer I tried to achieve the result with minimum effort, which was for me do the pipe for calls.

dsym_paths.each do |file_path|
curlCommand += build_single_file_command(command, file_path)
if file_path != dsym_paths.last
curlCommand += " | "
end
end
end

UI.verbose curlCommand
return curlCommand if Helper.test?

result = Actions.sh(curlCommand)
if result == "200"
UI.success 'dSYM is successfully uploaded to Instabug 🤖'
else
UI.error "Something went wrong during Instabug dSYM upload. Status code is #{result}"
end
end

def self.description
"upload dsyms to fastlane"
Expand All @@ -55,14 +61,19 @@ def self.available_options
verify_block: proc do |value|
UI.user_error!("No API token for InstabugAction given, pass using `api_token: 'token'`") unless value && !value.empty?
end),
FastlaneCore::ConfigItem.new(key: :dsym_array_paths,
type: Array,
optional: true,
description: 'Array of paths to *.dSYM.zip files',
default_value: Actions.lane_context[SharedValues::DSYM_PATHS]),
FastlaneCore::ConfigItem.new(key: :dsym_path,
env_name: 'FL_INSTABUG_DSYM_PATH',
description: 'Path to *.dSYM file',
default_value: Actions.lane_context[SharedValues::DSYM_OUTPUT_PATH],
is_string: true,
optional: true,
verify_block: proc do |value|
UI.user_error!("dSYM file doesn't exists") unless File.exist?(value)
UI.user_error!("dSYM file doesn't exists") unless File.exist?(value)
end)
]
end
Expand All @@ -71,6 +82,17 @@ def self.is_supported?(platform)
platform == :ios
true
end

private

def self.build_single_file_command(command, dsym_path)
if dsym_path.end_with?('.zip')
file_path = dsym_path.shellescape
else
file_path = ZipAction.run(path: dsym_path).shellescape
end
return command + "@\"#{file_path}\""
end
end
end
end