Skip to content

A platform for community discussion. Free, open, simple.

DEV: Support running Ruby tests in parallel (#7087)

Penar Musarajedffd0097fc6
diff --git a/.rspec b/.rspec
index 53607ea52b7..49e9bca297d 100644
--- a/.rspec
+++ b/.rspec
@@ -1 +1,3 @@
--colour
+--profile
+--fail-fast
diff --git a/lib/tasks/docker.rake b/lib/tasks/docker.rake
index ce748441142..e689c7986ba 100644
--- a/lib/tasks/docker.rake
+++ b/lib/tasks/docker.rake
@@ -124,6 +124,18 @@ task 'docker:test' do
if ENV["RSPEC_SEED"]
params << "--seed #{ENV["RSPEC_SEED"]}"
end
+
+ if ENV['PARALLEL']
+ parts = ENV['PARALLEL'].split("/")
+ total = parts[1].to_i
+ subset = parts[0].to_i - 1
+
+ spec_partials = Dir["spec/**/*_spec.rb"].sort.in_groups(total, false)
+ params << spec_partials[subset].join(' ')
+
+ puts "Running spec subset #{subset + 1} of #{total}"
+ end
+
@good &&= run_or_fail("bundle exec rspec #{params.join(' ')}".strip)
end