fastlane-plugin-bugsnag 1.3.4 → 1.4.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
  SHA256:
3
- metadata.gz: 02c60ef7d341ce29ce5d18ec3f5c93362c7ed029e9d3d1ea7d088a71d82c5236
4
- data.tar.gz: e03e1f3969e5b1c41b13ce7c0f92b3e3cd4f09bd684d861f3b5d48099d18455b
3
+ metadata.gz: ad582c6af1ea151c4ac204309b0d3fe48da1aa071eb9274b25ea8dc5ba993835
4
+ data.tar.gz: 5f9526a7383816b5e747fe8f8ba879a911e81a176f589057353158eba93d49c4
5
5
  SHA512:
6
- metadata.gz: 76f80373a17c95b8887cc7cfbd1fbff3e58742c989bb83623277de768eb82ed1a9ef32ef613ab6194f2d719003f762fec780ed2ca56a7bae98cf23f531a3df3d
7
- data.tar.gz: 2e339494643b6e71de5b8c70bcbef48e7d876930009aca03c6236ffbbe58d85f67999bd383cfed2b0330fca7c3d4ad5de80c34ca5c51bcc14b82781f6ffe2737
6
+ metadata.gz: 639170c3dd8dd10827bc50757fcb0aaf2074a864d547dc55943e4540dad4a6c00ed97265aeacc42d21e6d55ca84e234c6b69de763d3214156b0042ba0a8c55ab
7
+ data.tar.gz: bb33da203e7a26e0eb75efc929573140b1bf59236aaba4613263026579864acc61e7bbd485cc3cc12b951220e85390f7f2603003954761c2beec5327799bfb41
data/bugsnag-dsym-upload CHANGED
@@ -15,6 +15,7 @@ function print_usage() {
15
15
  echo
16
16
  echo "-h, --help Displays this message"
17
17
  echo "-v, --verbose Print verbose logging output during execution"
18
+ echo "--api-key API_KEY The API key of the project the dSYM should be applied to"
18
19
  echo "--symbol-maps DIR Path to a directory of bitcode symbol maps. The"
19
20
  echo " dSYM files will be restored with symbols prior to"
20
21
  echo " upload. Requires dsymutil."
@@ -51,6 +52,7 @@ unset dsym_dir
51
52
  unset verbose
52
53
  unset silent
53
54
  unset project_root
55
+ unset api_key
54
56
 
55
57
  while [[ $# -gt 0 ]]; do
56
58
  case $1 in
@@ -71,6 +73,10 @@ while [[ $# -gt 0 ]]; do
71
73
  upload_server=$2
72
74
  shift
73
75
  shift;;
76
+ --api-key)
77
+ api_key=$2
78
+ shift
79
+ shift;;
74
80
  --project-root)
75
81
  project_root=$2
76
82
  shift
@@ -131,12 +137,23 @@ for dsym in $dsym_dir/*.dSYM; do
131
137
  uuid=$(dwarfdump -u $file 2>/dev/null)
132
138
  if [[ $uuid == UUID* ]]; then
133
139
  log Uploading $uuid
140
+
141
+ # Attach the api key and project root parameters if they have been provided
142
+ args=""
134
143
  if [[ ! -z $project_root ]]; then
135
- output=$(curl --silent --show-error $upload_server -F dsym=@\"$file\" -F projectRoot=$project_root)
136
- else
137
- output=$(curl --silent --show-error $upload_server -F dsym=@\"$file\")
144
+ args="-F projectRoot=$project_root "
138
145
  fi
139
- if [ $? -eq 0 ]; then
146
+
147
+ if [[ ! -z $api_key ]]; then
148
+ args="$args-F apiKey=$api_key"
149
+ fi
150
+
151
+ # We need to shell out to perform the curl as there seems to be some indirect
152
+ # wrapping of this script which causes the command to fail if called directly.
153
+ curl_cmd="curl --silent --show-error $upload_server -F dsym=@\"$file\" $args"
154
+ output=$(sh -c "$curl_cmd")
155
+
156
+ if [ $? -eq 0 ] && [ "$output" != "invalid apiKey" ]; then
140
157
  success_count=$((success_count+1))
141
158
  else
142
159
  fail_count=$((fail_count+1))
@@ -6,9 +6,21 @@ module Fastlane
6
6
  File.join(File.dirname(__FILE__), '..', '..', '..', '..', '..', 'bugsnag-dsym-upload'))
7
7
 
8
8
  def self.run(params)
9
+ options = {}
10
+ options = options_from_info_plist(params[:config_file]) if params[:config_file]
11
+
12
+ if (params[:config_file] == default_info_plist_path || options[:apiKey].nil? || options[:apiKey].empty?)
13
+ # Load custom API key if config file has not been overridden or the API key couldn't be found in config files
14
+ options[:apiKey] = params[:api_key] unless params[:api_key].nil?
15
+ else
16
+ # Print which file is populating version and API key information since the value has been
17
+ # overridden
18
+ UI.message("Loading API key from #{params[:config_file]}")
19
+ end
20
+
9
21
  parse_dsym_paths(params[:dsym_path]).each do |dsym_path|
10
22
  if dsym_path.end_with?(".zip") or File.directory?(dsym_path)
11
- args = upload_args(dsym_path, params[:symbol_maps_path], params[:upload_url], params[:project_root], params[:verbose])
23
+ args = upload_args(dsym_path, params[:symbol_maps_path], params[:upload_url], params[:project_root], options[:apiKey], params[:verbose])
12
24
  success = Kernel.system(UPLOAD_SCRIPT_PATH, *args)
13
25
  if success
14
26
  UI.success("Uploaded dSYMs in #{dsym_path}")
@@ -59,7 +71,23 @@ module Fastlane
59
71
  UI.user_error!("Symbol maps file needs to be a directory containing symbol map files")
60
72
  end
61
73
  end
74
+ validate_api_key = proc do |key|
75
+ return if key.nil?
76
+
77
+ unless !key[/\H/] and key.length == 32
78
+ UI.user_error!("API key should be a 32 character hexdeciaml string")
79
+ end
80
+ end
81
+
82
+ options = {}
83
+ options = options_from_info_plist(default_info_plist_path) if file_path = default_info_plist_path
62
84
  [
85
+ FastlaneCore::ConfigItem.new(key: :api_key,
86
+ env_name: "BUGSNAG_API_KEY",
87
+ description: "Bugsnag API Key",
88
+ optional: true,
89
+ default_value: options[:apiKey],
90
+ verify_block: validate_api_key),
63
91
  FastlaneCore::ConfigItem.new(key: :dsym_path,
64
92
  type: Array,
65
93
  env_name: "BUGSNAG_DSYM_PATH",
@@ -83,6 +111,10 @@ module Fastlane
83
111
  description: "Root path of the project",
84
112
  default_value: Dir::pwd,
85
113
  optional: true),
114
+ FastlaneCore::ConfigItem.new(key: :config_file,
115
+ description: "Info.plist location",
116
+ optional: true,
117
+ default_value: options[:config_file]),
86
118
  FastlaneCore::ConfigItem.new(key: :verbose,
87
119
  env_name: "BUGSNAG_VERBOSE",
88
120
  description: "Print helpful debug info",
@@ -93,8 +125,21 @@ module Fastlane
93
125
 
94
126
  private
95
127
 
96
- def self.upload_args dir, symbol_maps_dir, upload_url, project_root, verbose
128
+ def self.default_info_plist_path
129
+ Dir.glob("./{ios/,}*/Info.plist").reject {|path| path =~ /build|test/i }.first
130
+ end
131
+
132
+ def self.options_from_info_plist file_path
133
+ plist_getter = Fastlane::Actions::GetInfoPlistValueAction
134
+ {
135
+ apiKey: plist_getter.run(path: file_path, key: "BugsnagAPIKey"),
136
+ config_file: file_path,
137
+ }
138
+ end
139
+
140
+ def self.upload_args dir, symbol_maps_dir, upload_url, project_root, api_key, verbose
97
141
  args = [verbose ? "--verbose" : "--silent"]
142
+ args += ["--api-key", api_key] unless api_key.nil?
98
143
  args += ["--upload-server", upload_url] unless upload_url.nil?
99
144
  args += ["--symbol-maps", symbol_maps_dir] unless symbol_maps_dir.nil?
100
145
  args += ["--project-root", project_root] unless project_root.nil?
@@ -110,9 +155,10 @@ module Fastlane
110
155
  end
111
156
 
112
157
  def self.default_dsym_path
113
- Actions.lane_context[SharedValues::DSYM_OUTPUT_PATH] ||
114
- Actions.lane_context[SharedValues::DSYM_PATHS] ||
115
- Dir["./**/*.dSYM.zip"] + Dir["./**/*.dSYM"]
158
+ path = Dir["./**/*.dSYM.zip"] + Dir["./**/*.dSYM"]
159
+ dsym_paths = Actions.lane_context[SharedValues::DSYM_PATHS] if defined? SharedValues::DSYM_PATHS
160
+ dsyms_output_path = Actions.lane_context[SharedValues::DSYM_OUTPUT_PATH] if defined? SharedValues::DSYM_OUTPUT_PATH
161
+ dsyms_output_path || dsym_paths || path
116
162
  end
117
163
  end
118
164
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Bugsnag
3
- VERSION = "1.3.4"
3
+ VERSION = "1.4.0"
4
4
  end
5
5
  end
@@ -3,6 +3,11 @@ require 'spec_helper'
3
3
  Action = Fastlane::Actions::UploadSymbolsToBugsnagAction
4
4
 
5
5
  describe Action do
6
+ def load_default_opts
7
+ Action.available_options.map do |x|
8
+ [x.key, x.default_value]
9
+ end.to_h
10
+ end
6
11
 
7
12
  context "the packaged gem" do
8
13
  gem_name = "fastlane-plugin-bugsnag-#{Fastlane::Bugsnag::VERSION}"
@@ -22,57 +27,61 @@ describe Action do
22
27
  describe '#run' do
23
28
  it 'silences script output by default' do
24
29
  expect(Kernel).to receive(:system).with(Action::UPLOAD_SCRIPT_PATH,
25
- "--silent", FIXTURE_PATH).and_return(true)
26
- Action.run({dsym_path: FIXTURE_PATH})
30
+ "--silent",
31
+ "--project-root", Dir::pwd,
32
+ FIXTURE_PATH).and_return(true)
33
+ Action.run(load_default_opts.merge({dsym_path: FIXTURE_PATH}))
27
34
  end
28
35
 
29
36
  it 'prints verbose if verbose flag set' do
30
37
  expect(Kernel).to receive(:system).with(Action::UPLOAD_SCRIPT_PATH,
31
- "--verbose", FIXTURE_PATH).and_return(true)
32
- Action.run({dsym_path: FIXTURE_PATH, verbose: true})
38
+ "--verbose",
39
+ "--project-root", Dir::pwd,
40
+ FIXTURE_PATH).and_return(true)
41
+ Action.run(load_default_opts.merge({dsym_path: FIXTURE_PATH, verbose: true}))
33
42
  end
34
43
 
35
44
  it 'UI.user_error when script fails' do
36
45
  expect(Fastlane::UI).to receive(:user_error!).with("Failed uploading #{FIXTURE_PATH}")
37
46
  expect(Kernel).to receive(:system).with(Action::UPLOAD_SCRIPT_PATH,
38
- "--silent", FIXTURE_PATH).and_return(false)
39
- Action.run({dsym_path: FIXTURE_PATH})
47
+ "--silent", "--project-root", Dir::pwd, FIXTURE_PATH).and_return(false)
48
+ Action.run(load_default_opts.merge({dsym_path: FIXTURE_PATH}))
40
49
  end
41
50
 
42
51
  it 'requires the dSYM file path to exist' do
43
52
  expect(Fastlane::UI).to receive(:user_error!)
44
53
 
45
- Action.run({dsym_path: 'fake/file/path'})
54
+ Action.run(load_default_opts.merge({dsym_path: 'fake/file/path'}))
46
55
  end
47
56
 
48
57
  it 'rejects dSYM files which are not a .zip or a directory' do
49
58
  expect(Fastlane::UI).to receive(:user_error!)
50
59
 
51
- Action.run({dsym_path: File.join(FIXTURE_PATH, 'invalid_file')})
60
+ Action.run(load_default_opts.merge({dsym_path: File.join(FIXTURE_PATH, 'invalid_file')}))
52
61
  end
53
62
 
54
63
  it 'uploads a single .dSYM file' do
55
64
  directory = File.join(FIXTURE_PATH, 'dSYMs')
56
65
  expect(Kernel).to receive(:system).with(Action::UPLOAD_SCRIPT_PATH,
57
- "--silent", directory).and_return(true)
58
- Action.run({dsym_path: File.join(FIXTURE_PATH, 'dSYMs/app.dSYM')})
66
+ "--silent", "--project-root", Dir::pwd, directory).and_return(true)
67
+ Action.run(load_default_opts.merge({dsym_path: File.join(FIXTURE_PATH, 'dSYMs/app.dSYM')}))
59
68
  end
60
69
 
61
70
  it 'uploads a .zip of .dSYM files' do
62
71
  path = File.join(FIXTURE_PATH, 'files.zip')
63
72
  expect(Kernel).to receive(:system).with(Action::UPLOAD_SCRIPT_PATH,
64
- "--silent", path).and_return(true)
65
- Action.run({dsym_path: path})
73
+ "--silent", "--project-root", Dir::pwd, path).and_return(true)
74
+ Action.run(load_default_opts.merge({dsym_path: path}))
66
75
  end
67
76
 
68
77
  it 'uploads multiple .zip files' do
69
78
  zip1 = File.join(FIXTURE_PATH, 'files.zip')
70
79
  zip2 = File.join(FIXTURE_PATH, 'more_files.zip')
71
80
  expect(Kernel).to receive(:system).with(Action::UPLOAD_SCRIPT_PATH,
72
- "--silent", zip1).and_return(true)
81
+ "--silent", "--project-root", Dir::pwd, zip1).and_return(true)
73
82
  expect(Kernel).to receive(:system).with(Action::UPLOAD_SCRIPT_PATH,
74
- "--silent", zip2).and_return(true)
75
- Action.run({dsym_path: [zip1, zip2]})
83
+ "--silent", "--project-root", Dir::pwd, zip2).and_return(true)
84
+ Action.run(load_default_opts.merge({dsym_path: [zip1, zip2]}))
76
85
  end
77
86
 
78
87
  it 'uploads multiple .dSYM files multiple directories' do
@@ -82,10 +91,10 @@ describe Action do
82
91
  dsym4 = File.join(FIXTURE_PATH, 'stuff/app2.dSYM')
83
92
  directories = [File.join(FIXTURE_PATH, 'dSYMs'), File.join(FIXTURE_PATH, 'stuff')]
84
93
  expect(Kernel).to receive(:system).with(Action::UPLOAD_SCRIPT_PATH,
85
- "--silent", directories[0]).and_return(true)
94
+ "--silent", "--project-root", Dir::pwd, directories[0]).and_return(true)
86
95
  expect(Kernel).to receive(:system).with(Action::UPLOAD_SCRIPT_PATH,
87
- "--silent", directories[1]).and_return(true)
88
- Action.run({dsym_path: [dsym1, dsym2, dsym3, dsym4]})
96
+ "--silent", "--project-root", Dir::pwd, directories[1]).and_return(true)
97
+ Action.run(load_default_opts.merge({dsym_path: [dsym1, dsym2, dsym3, dsym4]}))
89
98
  end
90
99
 
91
100
  it 'uploads multiple .dSYM files in a single directory' do
@@ -93,8 +102,8 @@ describe Action do
93
102
  dsym2 = File.join(FIXTURE_PATH, 'dSYMs/app2.dSYM')
94
103
  directory = File.join(FIXTURE_PATH, 'dSYMs')
95
104
  expect(Kernel).to receive(:system).with(Action::UPLOAD_SCRIPT_PATH,
96
- "--silent", directory).and_return(true)
97
- Action.run({dsym_path: [dsym1, dsym2]})
105
+ "--silent", "--project-root", Dir::pwd, directory).and_return(true)
106
+ Action.run(load_default_opts.merge({dsym_path: [dsym1, dsym2]}))
98
107
  end
99
108
 
100
109
  it 'accepts a project root argument' do
@@ -103,7 +112,49 @@ describe Action do
103
112
  "--silent",
104
113
  "--project-root", root_path,
105
114
  FIXTURE_PATH).and_return(true)
106
- Action.run({dsym_path: FIXTURE_PATH, project_root: root_path})
115
+ Action.run(load_default_opts.merge({dsym_path: FIXTURE_PATH, project_root: root_path}))
116
+ end
117
+
118
+ it 'accepts an API key argument' do
119
+ api_key = "1234567890ABCDE"
120
+ expect(Kernel).to receive(:system).with(Action::UPLOAD_SCRIPT_PATH,
121
+ "--silent",
122
+ "--api-key", api_key,
123
+ "--project-root", Dir::pwd,
124
+ FIXTURE_PATH).and_return(true)
125
+ Action.run(load_default_opts.merge({dsym_path: FIXTURE_PATH, api_key: api_key}))
126
+ end
127
+
128
+ it 'accepts an API key argument with no project root' do
129
+ api_key = "1234567890ABCDE"
130
+ expect(Kernel).to receive(:system).with(Action::UPLOAD_SCRIPT_PATH,
131
+ "--silent",
132
+ "--api-key", api_key,
133
+ FIXTURE_PATH).and_return(true)
134
+ Action.run(load_default_opts.merge({dsym_path: FIXTURE_PATH, api_key: api_key, project_root: nil}))
135
+ end
136
+
137
+ it 'uses default API key argument from plist' do
138
+ root_path = "/test/test/test"
139
+ expect(Kernel).to receive(:system).with(Action::UPLOAD_SCRIPT_PATH,
140
+ "--silent",
141
+ "--api-key", "other-key",
142
+ "--project-root", root_path,
143
+ FIXTURE_PATH).and_return(true)
144
+ Dir.chdir(File.join(FIXTURE_PATH, 'ios_proj')) do
145
+ Action.run(load_default_opts.merge({dsym_path: FIXTURE_PATH, project_root: root_path}))
146
+ end
147
+ end
148
+
149
+ it 'allows config file to overwrite parameter' do
150
+ expect(Kernel).to receive(:system).with(Action::UPLOAD_SCRIPT_PATH,
151
+ "--silent",
152
+ "--api-key", "project-key",
153
+ "--project-root", File.join(FIXTURE_PATH, 'ios_proj'),
154
+ FIXTURE_PATH).and_return(true)
155
+ Dir.chdir(File.join(FIXTURE_PATH, 'ios_proj')) do
156
+ Action.run(load_default_opts.merge({dsym_path: FIXTURE_PATH, api_key: "ignored:", config_file: File.join('Project', 'Info.plist')}))
157
+ end
107
158
  end
108
159
 
109
160
  context 'using a private server' do
@@ -111,9 +162,9 @@ describe Action do
111
162
  expect(Kernel).to receive(:system).with(Action::UPLOAD_SCRIPT_PATH,
112
163
  "--silent",
113
164
  "--upload-server", "http://myserver.example.com",
165
+ "--project-root", Dir::pwd,
114
166
  FIXTURE_PATH).and_return(true)
115
- Action.run({dsym_path: FIXTURE_PATH,
116
- upload_url: "http://myserver.example.com"})
167
+ Action.run(load_default_opts.merge({dsym_path: FIXTURE_PATH, upload_url: "http://myserver.example.com"}))
117
168
  end
118
169
  end
119
170
 
@@ -123,8 +174,9 @@ describe Action do
123
174
  expect(Kernel).to receive(:system).with(Action::UPLOAD_SCRIPT_PATH,
124
175
  "--silent",
125
176
  "--symbol-maps", path,
177
+ "--project-root", Dir::pwd,
126
178
  FIXTURE_PATH).and_return(true)
127
- Action.run({dsym_path: FIXTURE_PATH, symbol_maps_path: path})
179
+ Action.run(load_default_opts.merge({dsym_path: FIXTURE_PATH, symbol_maps_path: path}))
128
180
  end
129
181
  end
130
182
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-bugsnag
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Delisa Mason
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-17 00:00:00.000000000 Z
11
+ date: 2018-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xml-simple