Class: Fastlane::Actions::LuciqDsymUploadAction

Inherits:
Action
  • Object
show all
Defined in:
lib/fastlane/plugin/luciq_dsym_upload/actions/luciq_dsym_upload_action.rb

Class Method Summary collapse

Class Method Details

.authorsObject



69
70
71
# File 'lib/fastlane/plugin/luciq_dsym_upload/actions/luciq_dsym_upload_action.rb', line 69

def self.authors
  ['Luciq Inc.']
end

.available_optionsObject



86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/fastlane/plugin/luciq_dsym_upload/actions/luciq_dsym_upload_action.rb', line 86

def self.available_options
  [
    FastlaneCore::ConfigItem.new(key: :api_token,
                                 env_name: 'FL_LUCIQ_API_TOKEN', # The name of the environment variable
                                 description: 'API Token for Luciq', # a short description of this parameter
                                 verify_block: proc do |value|
                                                 unless value && !value.empty?
                                                   UI.user_error!("No API token for LuciqAction given, pass using `api_token: 'token'`")
                                                 end
                                               end),
    FastlaneCore::ConfigItem.new(key: :dsym_array_paths,
                                 type: Array,
                                 optional: true,
                                 description: 'Array of paths to *.dSYM files'),
    FastlaneCore::ConfigItem.new(key: :eu,
                              type: Boolean,
                              optional: true,
                              description: 'Should use the EU cluster or not'),
    FastlaneCore::ConfigItem.new(key: :end_point,
                               type: String,
                               optional: true,
                               description: 'Custom end point to be used to upload the dsyms to')
  ]
end

.build_single_file_command(command, dsym_path) ⇒ Object



141
142
143
144
145
146
147
148
# File 'lib/fastlane/plugin/luciq_dsym_upload/actions/luciq_dsym_upload_action.rb', line 141

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

.cleanup_luciq_directoryObject



121
122
123
124
# File 'lib/fastlane/plugin/luciq_dsym_upload/actions/luciq_dsym_upload_action.rb', line 121

def self.cleanup_luciq_directory
  FileUtils.rm_f "#{@luciq_dsyms_directory}.zip"
  FileUtils.rm_rf @luciq_dsyms_directory
end

.copy_dsym_paths_into_directory(dsym_paths, directory_path) ⇒ Object



130
131
132
133
134
135
136
137
138
139
# File 'lib/fastlane/plugin/luciq_dsym_upload/actions/luciq_dsym_upload_action.rb', line 130

def self.copy_dsym_paths_into_directory(dsym_paths, directory_path)
  dsym_paths.each do |path|
    if File.extname(path) == '.dSYM'
      destination_path = "#{directory_path}/#{File.basename(path)}"
      FileUtils.copy_entry(path, destination_path) if File.exist?(path)
    else
      Actions.sh("unzip -n #{Shellwords.shellescape(path)} -d #{Shellwords.shellescape(directory_path)}")
    end
  end
end

.descriptionObject



59
60
61
# File 'lib/fastlane/plugin/luciq_dsym_upload/actions/luciq_dsym_upload_action.rb', line 59

def self.description
  "Upload dSYM files to Luciq"
end

.detailsObject



63
64
65
66
67
# File 'lib/fastlane/plugin/luciq_dsym_upload/actions/luciq_dsym_upload_action.rb', line 63

def self.details
  "This action is used to upload symbolication files to Luciq. Incase you are not using bitcode, you can use this plug-in
  with `gym` to upload dSYMs generated from your builds. If bitcode is enabled, you can use it with `download_dsyms` to upload dSYMs
  from iTunes connect"
end

.example_codeObject



77
78
79
80
81
82
83
84
# File 'lib/fastlane/plugin/luciq_dsym_upload/actions/luciq_dsym_upload_action.rb', line 77

def self.example_code
  [
    'luciq_dsym_upload(api_token: "<Luciq Token>")',
    'luciq_dsym_upload(api_token: "<Luciq Token>", dsym_array_paths: ["./App1.dSYM.zip", "./App2.dSYM.zip"])',
    'luciq_dsym_upload(api_token: "<Luciq Token>", eu: true)',
    'luciq_dsym_upload(api_token: "<Luciq Token>", end_point: "https://api.instabug.com/api/sdk/v3/symbols_files")'
  ]
end

.generate_luciq_directoryObject



116
117
118
119
# File 'lib/fastlane/plugin/luciq_dsym_upload/actions/luciq_dsym_upload_action.rb', line 116

def self.generate_luciq_directory
  cleanup_luciq_directory
  FileUtils.mkdir_p @luciq_dsyms_directory
end

.is_supported?(platform) ⇒ Boolean

Returns:

  • (Boolean)


111
112
113
114
# File 'lib/fastlane/plugin/luciq_dsym_upload/actions/luciq_dsym_upload_action.rb', line 111

def self.is_supported?(platform)
  platform == :ios
  true
end

.remove_directory(directory_path) ⇒ Object



126
127
128
# File 'lib/fastlane/plugin/luciq_dsym_upload/actions/luciq_dsym_upload_action.rb', line 126

def self.remove_directory(directory_path)
  FileUtils.rm_rf directory_path
end

.return_valueObject



73
74
75
# File 'lib/fastlane/plugin/luciq_dsym_upload/actions/luciq_dsym_upload_action.rb', line 73

def self.return_value
  # If your method provides a return value, you can describe here what it does
end

.run(params) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/fastlane/plugin/luciq_dsym_upload/actions/luciq_dsym_upload_action.rb', line 9

def self.run(params)
  @luciq_dsyms_directory = 'Luciq_dsym_files_fastlane'

  UI.verbose 'Running Luciq Action'
  api_token = params[:api_token]
  eu = params[:eu] || false
  
  default_end_point = 'https://api.instabug.com/api/sdk/v3/symbols_files'
  if eu
      default_end_point = 'https://api-eu.instabug.com/api/sdk/v3/symbols_files'
  end

  endpoint = params[:end_point] || default_end_point
  command = "curl #{endpoint} --write-out %{http_code} --silent --output /dev/null -F os=\"ios\" -F application_token=\"#{api_token}\" -F symbols_file="

  dsym_paths = []
  # Add paths provided by the user
  dsym_paths += (params[:dsym_array_paths] || [])
  # Add dSYMs generaed by `gym`
  dsym_paths += [Actions.lane_context[SharedValues::DSYM_OUTPUT_PATH]] if Actions.lane_context[SharedValues::DSYM_OUTPUT_PATH]
  # Add dSYMs downloaded from iTC
  dsym_paths += Actions.lane_context[SharedValues::DSYM_PATHS] if Actions.lane_context[SharedValues::DSYM_PATHS]

  dsym_paths.uniq!
  UI.verbose 'dsym_paths: ' + dsym_paths.inspect

  if dsym_paths.empty?
    UI.error "Fastlane dSYMs file is not found! make sure you're using Fastlane action [download_dsyms] to download your dSYMs from App Store Connect"
    return
  end

  generate_luciq_directory

  UI.verbose 'Directory name: ' + @luciq_dsyms_directory
  copy_dsym_paths_into_directory(dsym_paths, @luciq_dsyms_directory)

  command = build_single_file_command(command, @luciq_dsyms_directory)

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

  # Cleanup zip file and directory
  cleanup_luciq_directory
end