Skip to content

Commit d422ee9

Browse files
authored
feat: Improve path parameter default behavior in sentry_debug_files_upload (#377)
The path parameter now intelligently defaults to DSYM_OUTPUT_PATH from fastlane's lane context when available (automatically set by actions like build_app or ipa), which narrows the search scope and improves performance. If not available, it falls back to '.' (current directory). - Update sentry_debug_files_upload to use DSYM_OUTPUT_PATH as default - Add comprehensive tests for DSYM_OUTPUT_PATH behavior - Update README.md documentation - Update CHANGELOG.md with improvement note This addresses issue #290 by providing a smarter default that narrows the search path when running in typical fastlane workflows.
1 parent 8355581 commit d422ee9

File tree

4 files changed

+83
-4
lines changed

4 files changed

+83
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Due to sentry-cli 3.0.0 upgrade, the following breaking changes have been made (
88

99
- **`sentry_upload_file` action has been removed**: The `releases files` commands were removed in sentry-cli 3.0.0. Users should migrate to `sentry_upload_sourcemap` for source maps or other specialized upload actions.
1010
- **`android_manifest_path` parameter in `sentry_upload_proguard` has been removed**: The `--android-manifest` argument was removed in sentry-cli 3.0.0 and is no longer needed. Any Fastfiles still using this parameter will need to remove it.
11+
- **`path` parameter default behavior changed in `sentry_debug_files_upload`**: The `path` parameter now defaults to `DSYM_OUTPUT_PATH` from fastlane's lane context if available (set by actions like `build_app` or `ipa`), otherwise falls back to `'.'` (current directory). This changes the default behavior when `DSYM_OUTPUT_PATH` is set, which may affect users who were relying on the previous behavior of always searching from the current directory. Users can explicitly specify `path: '.'` to maintain the previous behavior. This addresses issue [#377](https://github.com/getsentry/sentry-fastlane-plugin/issues/377).
1112
- **`api_key` parameter has been removed**: The `api_key` parameter has been removed in favor of `auth_token`. All actions now require `auth_token` for authentication. Users should update their Fastfiles to use `auth_token` instead of `api_key`. ([#376](https://github.com/getsentry/sentry-fastlane-plugin/pull/376))
1213
- **`force_foreground` parameter has been removed**: This parameter was deprecated as a no-op since v1.26.0 and has now been removed from `sentry_debug_files_upload`. Users should remove this parameter from their Fastfiles. ([#376](https://github.com/getsentry/sentry-fastlane-plugin/pull/376))
1314
- **`sentry_upload_dsym` action has been removed**: This action has been deprecated in favor of `sentry_debug_files_upload`. Users should migrate to `sentry_debug_files_upload` with the appropriate `path` parameter. ([#375](https://github.com/getsentry/sentry-fastlane-plugin/pull/375))

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ sentry_debug_files_upload(
6262
auth_token: '...',
6363
org_slug: '...',
6464
project_slug: '...',
65-
path: '/path/to/files', # Optional. Defaults to '.' when no value is provided. Path(s) can be a string, a comma-separated string, or an array of strings.
65+
path: '/path/to/files', # Optional. Defaults to DSYM_OUTPUT_PATH from fastlane context if available, otherwise '.' (current directory). Path(s) can be a string, a comma-separated string, or an array of strings.
6666
)
6767
```
6868

lib/fastlane/plugin/sentry/actions/sentry_debug_files_upload.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ def self.run(params)
77
Helper::SentryConfig.parse_api_params(params)
88

99
paths = params[:path]
10-
paths = ['.'] if paths.nil?
10+
# Use DSYM_OUTPUT_PATH from fastlane context if available, otherwise default to current directory
11+
if paths.nil?
12+
dsym_path = Actions.lane_context[SharedValues::DSYM_OUTPUT_PATH]
13+
if dsym_path && !dsym_path.to_s.empty?
14+
paths = [dsym_path]
15+
else
16+
paths = ['.']
17+
end
18+
end
1119

1220
command = [
1321
"debug-files",
@@ -52,7 +60,7 @@ def self.details
5260
def self.available_options
5361
Helper::SentryConfig.common_api_config_items + [
5462
FastlaneCore::ConfigItem.new(key: :path,
55-
description: "Path or an array of paths to search recursively for symbol files",
63+
description: "Path or an array of paths to search recursively for symbol files. Defaults to DSYM_OUTPUT_PATH from fastlane context if available, otherwise '.' (current directory)",
5664
type: Array,
5765
optional: true),
5866
FastlaneCore::ConfigItem.new(key: :type,

spec/sentry_debug_files_upload_spec.rb

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,77 @@
3939
expect(Fastlane::Helper::SentryHelper).to receive(:call_sentry_cli).with(anything, ["debug-files", "upload", "."]).and_return(true)
4040

4141
Fastlane::FastFile.new.parse("lane :test do
42-
sentry_debug_files_upload()
42+
sentry_debug_files_upload(
43+
auth_token: 'fixture-auth-token'
44+
)
45+
end").runner.execute(:test)
46+
end
47+
48+
it "uses DSYM_OUTPUT_PATH from lane context when path is not provided" do
49+
require 'fastlane'
50+
mock_dsym_path = './assets/SwiftExample.app.dSYM.zip'
51+
52+
# Set the shared value on the correct module BEFORE parsing the lane
53+
Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::DSYM_OUTPUT_PATH] = mock_dsym_path
54+
55+
expect(Fastlane::Helper::SentryConfig).to receive(:parse_api_params).and_return(true)
56+
expect(Fastlane::Helper::SentryHelper).to receive(:call_sentry_cli).with(anything, ["debug-files", "upload", mock_dsym_path]).and_return(true)
57+
58+
Fastlane::FastFile.new.parse("lane :test do
59+
sentry_debug_files_upload(
60+
auth_token: 'fixture-auth-token'
61+
)
62+
end").runner.execute(:test)
63+
end
64+
65+
it "falls back to '.' when DSYM_OUTPUT_PATH is empty string" do
66+
require 'fastlane'
67+
68+
# Set the shared value to empty string
69+
Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::DSYM_OUTPUT_PATH] = ''
70+
71+
expect(Fastlane::Helper::SentryConfig).to receive(:parse_api_params).and_return(true)
72+
expect(Fastlane::Helper::SentryHelper).to receive(:call_sentry_cli).with(anything, ["debug-files", "upload", "."]).and_return(true)
73+
74+
Fastlane::FastFile.new.parse("lane :test do
75+
sentry_debug_files_upload(
76+
auth_token: 'fixture-auth-token'
77+
)
78+
end").runner.execute(:test)
79+
end
80+
81+
it "falls back to '.' when DSYM_OUTPUT_PATH is nil" do
82+
require 'fastlane'
83+
84+
# Set the shared value to nil explicitly
85+
Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::DSYM_OUTPUT_PATH] = nil
86+
87+
expect(Fastlane::Helper::SentryConfig).to receive(:parse_api_params).and_return(true)
88+
expect(Fastlane::Helper::SentryHelper).to receive(:call_sentry_cli).with(anything, ["debug-files", "upload", "."]).and_return(true)
89+
90+
Fastlane::FastFile.new.parse("lane :test do
91+
sentry_debug_files_upload(
92+
auth_token: 'fixture-auth-token'
93+
)
94+
end").runner.execute(:test)
95+
end
96+
97+
it "uses explicitly provided path over DSYM_OUTPUT_PATH" do
98+
require 'fastlane'
99+
mock_dsym_path = './assets/SwiftExample.app.dSYM.zip'
100+
explicit_path = './explicit/path'
101+
102+
# Set the shared value, but explicit path should override it
103+
Fastlane::Actions.lane_context[Fastlane::Actions::SharedValues::DSYM_OUTPUT_PATH] = mock_dsym_path
104+
105+
expect(Fastlane::Helper::SentryConfig).to receive(:parse_api_params).and_return(true)
106+
expect(Fastlane::Helper::SentryHelper).to receive(:call_sentry_cli).with(anything, ["debug-files", "upload", explicit_path]).and_return(true)
107+
108+
Fastlane::FastFile.new.parse("lane :test do
109+
sentry_debug_files_upload(
110+
auth_token: 'fixture-auth-token',
111+
path: '#{explicit_path}'
112+
)
43113
end").runner.execute(:test)
44114
end
45115

0 commit comments

Comments
 (0)