Skip to content

Commit

Permalink
support app_identifier on upload_sourcemap and create_release
Browse files Browse the repository at this point in the history
  • Loading branch information
hjanuschka committed May 15, 2017
1 parent f218edd commit d2d22d6
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 7 deletions.
11 changes: 10 additions & 1 deletion lib/fastlane/plugin/sentry/actions/sentry_create_release.rb
Expand Up @@ -8,6 +8,8 @@ def self.run(params)
Helper::SentryConfig.parse_api_params(params)

version = params[:version]
version = "#{params[:app_identifier]}-#{params[:version]}" if params[:app_identifier]

finalize_arg = params[:finalize] ? ' --finalize' : ''

command = "sentry-cli releases new '#{Shellwords.escape(version)}' #{finalize_arg}"
Expand Down Expand Up @@ -39,7 +41,14 @@ def self.available_options
description: "Whether to finalize the release. If not provided or false, the release can be finalized using the finalize_release action",
default_value: false,
is_string: false,
optional: true)
optional: true),
FastlaneCore::ConfigItem.new(key: :app_identifier,
short_option: "-a",
env_name: "SENTRY_APP_IDENTIFIER",
description: "App Bundle Identifier",
optional: true,
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier))

]
end

Expand Down
11 changes: 10 additions & 1 deletion lib/fastlane/plugin/sentry/actions/sentry_upload_sourcemap.rb
Expand Up @@ -10,6 +10,8 @@ def self.run(params)
version = params[:version]
sourcemap = params[:sourcemap]

version = "#{params[:app_identifier]}-#{params[:version]}" if params[:app_identifier]

rewrite_arg = params[:rewrite] ? '--rewrite' : ''
strip_prefix_arg = params[:strip_prefix] ? '--strip-prefix' : ''
strip_common_prefix_arg = params[:strip_common_prefix] ? '--strip-common-prefix' : ''
Expand Down Expand Up @@ -79,7 +81,14 @@ def self.available_options
optional: true),
FastlaneCore::ConfigItem.new(key: :url_prefix,
description: "Sets a URL prefix in front of all files",
optional: true)
optional: true),
FastlaneCore::ConfigItem.new(key: :app_identifier,
short_option: "-a",
env_name: "SENTRY_APP_IDENTIFIER",
description: "App Bundle Identifier",
optional: true,
default_value: CredentialsManager::AppfileConfig.try_fetch_value(:app_identifier))

]
end

Expand Down
18 changes: 18 additions & 0 deletions spec/sentry_create_release_spec.rb
@@ -0,0 +1,18 @@
describe Fastlane do
describe Fastlane::FastFile do
describe "create release" do
it "accepts app_identifier" do
expect(Fastlane::Helper::SentryHelper).to receive(:check_sentry_cli!).and_return(true)
allow(CredentialsManager::AppfileConfig).to receive(:try_fetch_value).with(:app_identifier).and_return(false)
expect(Fastlane::Helper::SentryConfig).to receive(:parse_api_params).and_return(true)
expect(Fastlane::Helper::SentryHelper).to receive(:call_sentry_cli).with("sentry-cli releases new 'app.idf-1.0' ").and_return(true)

Fastlane::FastFile.new.parse("lane :test do
sentry_create_release(
version: '1.0',
app_identifier: 'app.idf')
end").runner.execute(:test)
end
end
end
end
7 changes: 3 additions & 4 deletions spec/sentry_upload_file_spec.rb
Expand Up @@ -15,13 +15,12 @@
end
it "accepts app_identifier" do
expect(Fastlane::Helper::SentryHelper).to receive(:check_sentry_cli!).and_return(true)
allow(File).to receive(:exist?).with("./fastlane/Appfile").and_return(false)
allow(File).to receive(:exist?).with("./.fastlane/Appfile").and_return(false)
allow(File).to receive(:exist?).with("./Appfile").and_return(false)
expect(File).to receive(:exist?).with("demo.file").and_return(true)
allow(CredentialsManager::AppfileConfig).to receive(:try_fetch_value).with(:app_identifier).and_return(false)
expect(Fastlane::Helper::SentryConfig).to receive(:parse_api_params).and_return(true)
expect(Fastlane::Helper::SentryHelper).to receive(:call_sentry_cli).with("sentry-cli releases files 'app.idf-1.0' upload demo.file --dist 'dem'").and_return(true)

expect(File).to receive(:exist?).with("demo.file").and_return(true)

Fastlane::FastFile.new.parse("lane :test do
sentry_upload_file(
org_slug: 'some_org',
Expand Down
20 changes: 19 additions & 1 deletion spec/sentry_upload_sourcemap_spec.rb
@@ -1,6 +1,6 @@
describe Fastlane do
describe Fastlane::FastFile do
describe "sentry" do
describe "upload_sourcemap" do
it "fails with invalid sourcemap path" do
sourcemap_path = File.absolute_path './assets/this_does_not_exist.js.map'
expect do
Expand All @@ -13,6 +13,24 @@
end").runner.execute(:test)
end.to raise_error("Could not find sourcemap at path '#{sourcemap_path}'")
end
it "accepts app_identifier" do
expect(Fastlane::Helper::SentryHelper).to receive(:check_sentry_cli!).and_return(true)
allow(CredentialsManager::AppfileConfig).to receive(:try_fetch_value).with(:app_identifier).and_return(false)
expect(Fastlane::Helper::SentryConfig).to receive(:parse_api_params).and_return(true)
expect(Fastlane::Helper::SentryHelper).to receive(:call_sentry_cli).with("sentry-cli releases files 'app.idf-1.0' upload-sourcemaps 1.map --dist 'dem'").and_return(true)
expect(File).to receive(:exist?).with("1.map").and_return(true)

Fastlane::FastFile.new.parse("lane :test do
sentry_upload_sourcemap(
org_slug: 'some_org',
api_key: 'something123',
project_slug: 'some_project',
version: '1.0',
dist: 'dem',
sourcemap: '1.map',
app_identifier: 'app.idf')
end").runner.execute(:test)
end
end
end
end

0 comments on commit d2d22d6

Please sign in to comment.