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][spm] add parallel option #21665

Merged
merged 3 commits into from Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 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,
optional: true),
rogerluan marked this conversation as resolved.
Show resolved Hide resolved
FastlaneCore::ConfigItem.new(key: :build_path,
env_name: "FL_SPM_BUILD_PATH",
description: "Specify build/cache directory [default: ./.build]",
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