fastlane-plugin-sentry 0.1.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 254603126fe136f22cda805b86beb01ac197597a
4
- data.tar.gz: 9acc2fe76b881829c9a8519652002f16176054d5
3
+ metadata.gz: 4e69a9ca0ab83f1dfb1a3945941d1cbdffe7fa3f
4
+ data.tar.gz: 788f571d8827f744c043d9a825ef967389fb5e9b
5
5
  SHA512:
6
- metadata.gz: 6797c97ae2f62222f8600f86862a8d8fb592df44f388d284cb18e74f52dba8dac0f79e85faf5e1a7beb492999fb3e57501093a9be90b835268022c09cd279ff7
7
- data.tar.gz: dcd3933d0e723ade6f6c1955871fda467b444047c6da18b40a540e8cc5b3f578aaf30d5f1faefbaeed7b71408057ab53d4a237458a7c4fd78160a8b0de4862c2
6
+ metadata.gz: ddc48fe46dca0b22e1028037ca06a4933427341d8c9294be7e9f970dcad5ea5c0deb24289d12b72d7c874561bde820d6b680fbbcb9f3545890fe0db7f1dd6a51
7
+ data.tar.gz: e69f9e50393323765acb76d2cbaa50e88f4b24f43775a3da24303c1ec43e45fffd24e5a6fa5dac91f11e26da429558b68898550462b15479aab59c8ab162c80e
@@ -2,17 +2,14 @@ module Fastlane
2
2
  module Actions
3
3
  class SentryUploadDsymAction < Action
4
4
  def self.run(params)
5
-
6
- require 'rest-client'
5
+ check_sentry_cli!
7
6
 
8
7
  # Params - API
9
- host = params[:api_host]
10
- api_key = params[:api_key]
8
+ url = params[:url]
11
9
  auth_token = params[:auth_token]
10
+ api_key = params[:api_key]
12
11
  org = params[:org_slug]
13
12
  project = params[:project_slug]
14
- timeout = params[:timeout]
15
- use_curl = params[:use_curl]
16
13
 
17
14
  # Params - dSYM
18
15
  dsym_path = params[:dsym_path]
@@ -26,82 +23,80 @@ module Fastlane
26
23
  UI.user_error!("No API key or authentication token found for SentryAction given, pass using `api_key: 'key'` or `auth_token: 'token'`")
27
24
  elsif has_api_key && has_auth_token
28
25
  UI.user_error!("Both API key and authentication token found for SentryAction given, please only give one")
26
+ elsif has_api_key && !has_auth_token
27
+ UI.deprecated("Please consider switching to auth_token ... api_key will be removed in the future")
29
28
  end
30
29
 
31
- # Url to post dSYMs to
32
- url = "#{host}/projects/#{org}/#{project}/files/dsyms/"
33
-
34
- UI.message "Will upload dSYM(s) to #{url}"
30
+ ENV['SENTRY_API_KEY'] = api_key unless api_key.to_s.empty?
31
+ ENV['SENTRY_AUTH_TOKEN'] = auth_token unless auth_token.to_s.empty?
32
+ ENV['SENTRY_URL'] = url unless url.to_s.empty?
33
+ ENV['SENTRY_LOG_LEVEL'] = 'info' if $verbose
35
34
 
36
35
  # Verify dsym(s)
37
- dsym_paths += [dsym_path]
36
+ dsym_paths += [dsym_path] unless dsym_path.nil?
38
37
  dsym_paths = dsym_paths.map { |path| File.absolute_path(path) }
39
38
  dsym_paths.each do |path|
40
39
  UI.user_error!("dSYM does not exist at path: #{path}") unless File.exists? path
41
40
  end
42
41
 
43
- # Upload dsym(s)
44
- uploaded_paths = dsym_paths.compact.map do |dsym|
45
- upload_dsym(use_curl, dsym, url, timeout, api_key, auth_token)
46
- end
47
-
48
- # Return uplaoded dSYM paths
49
- uploaded_paths
42
+ UI.success("sentry-cli #{Fastlane::Sentry::CLI_VERSION} installed!")
43
+ call_sentry_cli(dsym_paths, org, project)
44
+ UI.success("Successfully uploaded dSYMs!")
50
45
  end
51
46
 
52
- def self.upload_dsym(use_curl, dsym, url, timeout, api_key, auth_token)
53
- UI.message "Uploading... #{dsym}"
54
- if use_curl
55
- self.upload_dsym_curl(dsym, url, timeout, api_key, auth_token)
56
- else
57
- self.upload_dsym_restclient(dsym, url, timeout, api_key, auth_token)
58
- end
59
- end
60
-
61
- def self.upload_dsym_curl(dsym, url, timeout, api_key, auth_token)
62
- has_api_key = !api_key.to_s.empty?
63
-
64
- status = 0
65
- if has_api_key
66
- status = sh "curl -s -o /dev/null -w '%{response_code}' --max-time #{timeout} --user #{api_key}: -F file=@#{dsym} #{url} | grep -o '[1-4][0-9][0-9]' "
67
- else
68
- status = sh "curl -s -o /dev/null -w '%{response_code}' --max-time #{timeout} -H 'Authorization: Bearer #{auth_token}' -F file=@#{dsym} #{url} | grep -o '[1-4][0-9][0-9]' "
47
+ def self.check_sentry_cli!
48
+ if !`which sentry-cli`.include?('sentry-cli')
49
+ UI.error("You have to install sentry-cli version #{Fastlane::Sentry::CLI_VERSION} to use this plugin")
50
+ UI.error("")
51
+ UI.error("Install it using:")
52
+ UI.command("brew install getsentry/tools/sentry-cli")
53
+ UI.error("OR")
54
+ UI.command("curl -sL https://sentry.io/get-cli/ | bash")
55
+ UI.error("If you don't have homebrew, visit http://brew.sh")
56
+ UI.user_error!("Install sentry-cli and start your lane again!")
69
57
  end
70
-
71
- status = status.to_i
72
- if (200..299).member?(status)
73
- return dsym
74
- else
75
- self.handle_error(nil, status)
58
+
59
+ sentry_cli_version = `sentry-cli --version`.gsub(/[^\d]/, '').to_i
60
+ required_version = Fastlane::Sentry::CLI_VERSION.gsub(/[^\d]/, '').to_i
61
+ if sentry_cli_version < required_version
62
+ UI.user_error!("Your sentry-cli is outdated, please upgrade to at least version #{Fastlane::Sentry::CLI_VERSION} and start your lane again!")
76
63
  end
77
64
  end
78
-
79
- def self.upload_dsym_restclient(dsym, url, timeout, api_key, auth_token)
80
- has_api_key = !api_key.to_s.empty?
81
-
82
- if has_api_key
83
- resource = RestClient::Resource.new( url, user: api_key, password: '', timeout: timeout, open_timeout: timeout )
84
- else
85
- resource = RestClient::Resource.new( url, headers: {Authorization: "Bearer #{auth_token}"}, timeout: timeout, open_timeout: timeout )
86
- end
87
-
88
- begin
89
- resource.post(file: File.new(dsym, 'rb')) unless Helper.test?
90
- UI.success 'dSYM successfully uploaded to Sentry!'
91
- dsym
92
- rescue RestClient::Exception => error
93
- handle_error(error, error.http_code)
94
- rescue => error
95
- handle_error(error)
65
+
66
+ def self.call_sentry_cli(dsym_paths, org, project)
67
+ UI.message "Starting sentry-cli..."
68
+ require 'open3'
69
+ require 'shellwords'
70
+ org = Shellwords.escape(org)
71
+ project = Shellwords.escape(project)
72
+ error = []
73
+ Open3.popen3("sentry-cli upload-dsym '#{dsym_paths.join("','")}' --org #{org} --project #{project}") do |stdin, stdout, stderr, wait_thr|
74
+ while line = stderr.gets do
75
+ error << line.strip!
76
+ end
77
+ while line = stdout.gets do
78
+ UI.message(line.strip!)
79
+ end
80
+ exit_status = wait_thr.value
81
+ unless exit_status.success? && error.empty?
82
+ handle_error(error)
83
+ end
96
84
  end
97
85
  end
98
86
 
99
- def self.handle_error(error, status = 0)
100
- UI.error "Error: #{error}" if error
101
- UI.important "Make sure your api_key or auth_token is configured correctly" if status == 401
102
- UI.important "Make sure the org_slug and project_slug matches exactly what is displayed your admin panel's URL" if status == 404
103
- UI.important "Your upload may have timed out for an unknown reason" if status == 100
104
- UI.user_error! 'Error while trying to upload dSYM to Sentry'
87
+ def self.handle_error(errors)
88
+ fatal = false
89
+ for error in errors do
90
+ if error
91
+ if error.include?('[INFO]')
92
+ UI.verbose("#{error}")
93
+ else
94
+ UI.error("#{error}")
95
+ fatal = true
96
+ end
97
+ end
98
+ end
99
+ UI.user_error!('Error while trying to upload dSYM to Sentry') unless !fatal
105
100
  end
106
101
 
107
102
  #####################################################
@@ -122,21 +117,21 @@ module Fastlane
122
117
 
123
118
  def self.available_options
124
119
  [
125
- FastlaneCore::ConfigItem.new(key: :api_host,
126
- env_name: "SENTRY_HOST",
127
- description: "API host url for Sentry",
120
+ FastlaneCore::ConfigItem.new(key: :url,
121
+ env_name: "SENTRY_URL",
122
+ description: "Url for Sentry",
128
123
  is_string: true,
129
124
  default_value: "https://app.getsentry.com/api/0",
130
125
  optional: true
131
126
  ),
132
- FastlaneCore::ConfigItem.new(key: :api_key,
133
- env_name: "SENTRY_API_KEY",
134
- description: "API key for Sentry",
135
- optional: true),
136
127
  FastlaneCore::ConfigItem.new(key: :auth_token,
137
128
  env_name: "SENTRY_AUTH_TOKEN",
138
129
  description: "Authentication token for Sentry",
139
130
  optional: true),
131
+ FastlaneCore::ConfigItem.new(key: :api_key,
132
+ env_name: "SENTRY_API_KEY",
133
+ description: "API key for Sentry",
134
+ optional: true),
140
135
  FastlaneCore::ConfigItem.new(key: :org_slug,
141
136
  env_name: "SENTRY_ORG_SLUG",
142
137
  description: "Organization slug for Sentry project",
@@ -145,7 +140,7 @@ module Fastlane
145
140
  end),
146
141
  FastlaneCore::ConfigItem.new(key: :project_slug,
147
142
  env_name: "SENTRY_PROJECT_SLUG",
148
- description: "Prgoject slug for Sentry",
143
+ description: "Project slug for Sentry",
149
144
  verify_block: proc do |value|
150
145
  UI.user_error!("No project slug for SentryAction given, pass using `project_slug: 'project'`") unless value and !value.empty?
151
146
  end),
@@ -163,33 +158,15 @@ module Fastlane
163
158
  default_value: Actions.lane_context[SharedValues::DSYM_PATHS],
164
159
  is_string: false,
165
160
  optional: true,
166
- verify_block: proc do |value|
167
- # validation is done in the action
168
- end),
169
- FastlaneCore::ConfigItem.new(key: :timeout,
170
- env_name: "SENTRY_TIMEOUT",
171
- description: "Sentry upload API request timeout (in seconds)",
172
- default_value: 120,
173
- is_string: false,
174
- optional: true,
175
- verify_block: proc do |value|
176
- # validation is done in the action
177
- end),
178
- FastlaneCore::ConfigItem.new(key: :use_curl,
179
- env_name: "SENTRY_USE_CURL",
180
- description: "Shells out the upload to `curl` instead of using `rest-client`. This MAY be needed for really large dSYM file sizes. Use this if you are receving timeouts",
181
- default_value: false,
182
- is_string: false,
183
- optional: true,
184
161
  verify_block: proc do |value|
185
162
  # validation is done in the action
186
163
  end)
187
-
164
+
188
165
  ]
189
166
  end
190
167
 
191
168
  def self.return_value
192
- "The uploaded dSYM path(s)"
169
+ nil
193
170
  end
194
171
 
195
172
  def self.authors
@@ -1,5 +1,6 @@
1
1
  module Fastlane
2
2
  module Sentry
3
- VERSION = "0.1.2"
3
+ VERSION = "1.0.0"
4
+ CLI_VERSION = "0.25.0"
4
5
  end
5
6
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-sentry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Holtz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-28 00:00:00.000000000 Z
11
+ date: 2017-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: rest-client
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 1.6.7
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 1.6.7
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: pry
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -112,9 +98,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
98
  version: '0'
113
99
  requirements: []
114
100
  rubyforge_project:
115
- rubygems_version: 2.5.1
101
+ rubygems_version: 2.5.2
116
102
  signing_key:
117
103
  specification_version: 4
118
104
  summary: Upload symbols to Sentry
119
105
  test_files: []
120
- has_rdoc: