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

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

diff --git a/.rspec b/.rspec
index 53607ea..49e9bca 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 ce74844..e689c79 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

GitHub sha: edffd009

2 Likes