Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[action][swiftlint] Adds '--progress' flag #21922

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion fastlane/lib/fastlane/actions/swiftlint.rb
Expand Up @@ -57,6 +57,7 @@ def self.optional_flags(params)
command << supported_option_switch(params, :format, "0.11.0", true) if params[:mode] == :autocorrect
command << supported_no_cache_option(params) if params[:no_cache]
command << " --compiler-log-path #{params[:compiler_log_path].shellescape}" if params[:compiler_log_path]
command << supported_option_switch(params, :progress, "0.49.1", true) if params[:progress]
return command
end

Expand Down Expand Up @@ -182,7 +183,13 @@ def self.available_options
optional: true,
verify_block: proc do |value|
UI.user_error!("Couldn't find compiler_log_path '#{File.expand_path(value)}'") unless File.exist?(value)
end)
end),
FastlaneCore::ConfigItem.new(key: :progress,
env_name: "FL_SWIFTLINT_PROGRESS",
description: "Show a live-updating progress bar instead of each file being processed",
default_value: false,
type: Boolean,
optional: true)
]
end

Expand Down
39 changes: 39 additions & 0 deletions fastlane/spec/actions_specs/swiftlint_spec.rb
Expand Up @@ -503,6 +503,45 @@
end.to raise_error(/Couldn't find compiler_log_path '.*#{path}'/)
end
end

context "when specifying progress option" do
it "adds progress option" do
allow(Fastlane::Actions::SwiftlintAction).to receive(:swiftlint_version).and_return(Gem::Version.new('0.49.1'))

result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
progress: true
)
end").runner.execute(:test)

expect(result).to eq("swiftlint lint --progress")
end

it "omits progress option if swiftlint does not support it" do
allow(Fastlane::Actions::SwiftlintAction).to receive(:swiftlint_version).and_return(Gem::Version.new('0.49.0'))
expect(FastlaneCore::UI).to receive(:important).with(/Your version of swiftlint \(0.49.0\) does not support/)

result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
progress: true
)
end").runner.execute(:test)

expect(result).to eq("swiftlint lint")
end
end

context "when specify false for progress option" do
it "doesn't add progress option" do
result = Fastlane::FastFile.new.parse("lane :test do
swiftlint(
progress: false
)
end").runner.execute(:test)

expect(result).to eq("swiftlint lint")
end
end
end
end
end