From 68815f93b6343588c7f2c01d9e769a2fef7f9a1b Mon Sep 17 00:00:00 2001 From: Jeremy Green Date: Tue, 17 Oct 2023 16:06:37 -0500 Subject: [PATCH] Add the parallel-ci script --- bin/parallel-ci | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100755 bin/parallel-ci diff --git a/bin/parallel-ci b/bin/parallel-ci new file mode 100755 index 00000000..11920923 --- /dev/null +++ b/bin/parallel-ci @@ -0,0 +1,15 @@ +#!/usr/bin/env ruby + +sha = ENV['GITHUB_SHA'] || `git rev-parse HEAD` +node_total = ENV["CI_NODE_TOTAL"] || 1 +node_index = ENV["CI_NODE_INDEX"] || 0 +tests = Dir["test/**/*_test.rb"]. + sort. + # Add randomization seed based on SHA of each commit + shuffle(random: Random.new(sha.to_i(16))). + select. + with_index do |el, i| + i % node_total.to_i == node_index.to_i + end + +exec "bundle exec rails test #{tests.join(" ")}"