Skip to content

Commit

Permalink
[action][spm] add parallel option (fastlane#21665)
Browse files Browse the repository at this point in the history
* Add parallel option to spm action

* Add parallel test example

* Change boolean option from optional to default false.

---------

Co-authored-by: Roger Oba <rogerluan.oba@gmail.com>
  • Loading branch information
2 people authored and SubhrajyotiSen committed Jan 17, 2024
1 parent ff22c2e commit f72d2af
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
10 changes: 10 additions & 0 deletions fastlane/lib/fastlane/actions/spm.rb
Expand Up @@ -12,6 +12,7 @@ def self.run(params)
cmd << "--verbose" if params[:verbose]
cmd << params[:command] if package_commands.include?(params[:command])
cmd << "--enable-code-coverage" if params[:enable_code_coverage] && (params[:command] == 'generate-xcodeproj' || params[:command] == 'test')
cmd << "--parallel" if params[:parallel] && params[:command] == 'test'
if params[:xcconfig]
cmd << "--xcconfig-overrides #{params[:xcconfig]}"
end
Expand Down Expand Up @@ -50,6 +51,11 @@ def self.available_options
description: "Enables code coverage for the generated Xcode project when using the 'generate-xcodeproj' and the 'test' command",
type: Boolean,
optional: true),
FastlaneCore::ConfigItem.new(key: :parallel,
env_name: "FL_SPM_PARALLEL",
description: "Enables running tests in parallel when using the 'test' command",
type: Boolean,
default_value: false),
FastlaneCore::ConfigItem.new(key: :build_path,
env_name: "FL_SPM_BUILD_PATH",
description: "Specify build/cache directory [default: ./.build]",
Expand Down Expand Up @@ -116,6 +122,10 @@ def self.example_code
'spm(
command: "generate-xcodeproj",
xcconfig: "Package.xcconfig"
)',
'spm(
command: "test",
parallel: true
)'
]
end
Expand Down
42 changes: 42 additions & 0 deletions fastlane/spec/actions_specs/spm_spec.rb
Expand Up @@ -186,6 +186,48 @@

expect(result).to eq("swift test")
end

it "sets --parallel to true for test" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
command: 'test',
parallel: true
)
end").runner.execute(:test)

expect(result).to eq("swift test --parallel")
end

it "sets --parellel to false for test" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
command: 'test',
parallel: false
)
end").runner.execute(:test)

expect(result).to eq("swift test")
end

it "does not add --parellel by default" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
command: 'test'
)
end").runner.execute(:test)

expect(result).to eq("swift test")
end

it "does not add --parellel for irrelevant commands" do
result = Fastlane::FastFile.new.parse("lane :test do
spm(
parallel: true
)
end").runner.execute(:test)

expect(result).to eq("swift build")
end
end

context "when command is package related" do
Expand Down

0 comments on commit f72d2af

Please sign in to comment.