From c47b44be19a6cb8b134d050049788bbdddec493f Mon Sep 17 00:00:00 2001 From: Justin Kenyon Date: Fri, 13 Feb 2026 15:39:03 -0500 Subject: [PATCH 1/2] Parallelize collection tests into 4 shards Split collection tests across 4 parallel matrix jobs using modular arithmetic on alphabetically sorted collection names. Each shard tests roughly 25 collections instead of all ~100, reducing wall-clock time by ~4x for collection testing. Sharding is controlled by COLLECTION_SHARD and COLLECTION_TOTAL_SHARDS env vars, making it easy to adjust the shard count in the future. --- .github/workflows/test.yml | 21 +++++++++++++++++---- test/collections_test_helper.rb | 14 +++++++++++++- 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 042e62c9ec5..e730b18352e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,10 +16,21 @@ jobs: strategy: fail-fast: false matrix: - test_type: - - collections - - topics - - all + include: + - test_type: topics + - test_type: collections + shard: 0 + total_shards: 4 + - test_type: collections + shard: 1 + total_shards: 4 + - test_type: collections + shard: 2 + total_shards: 4 + - test_type: collections + shard: 3 + total_shards: 4 + - test_type: all runs-on: ubuntu-latest steps: - uses: actions/checkout@v6.0.1 @@ -58,3 +69,5 @@ jobs: TOPIC_FILES: ${{ steps.topics.outputs.changed }} COLLECTION_FILES: ${{ steps.collections.outputs.changed }} TEST_ALL_FILES: ${{ steps.all.outputs.changed }} + COLLECTION_SHARD: ${{ matrix.shard }} + COLLECTION_TOTAL_SHARDS: ${{ matrix.total_shards }} diff --git a/test/collections_test_helper.rb b/test/collections_test_helper.rb index e7b50164b6d..6a7800c3499 100644 --- a/test/collections_test_helper.rb +++ b/test/collections_test_helper.rb @@ -53,7 +53,19 @@ def dirs_to_test end def collections - collection_dirs.map { |dir_path| File.basename(dir_path) } + all = collection_dirs.map { |dir_path| File.basename(dir_path) } + shard_collections(all) +end + +def shard_collections(all_collections) + shard = ENV["COLLECTION_SHARD"]&.to_i + total_shards = ENV["COLLECTION_TOTAL_SHARDS"]&.to_i + + return all_collections unless shard && total_shards && total_shards > 1 + + # Sort alphabetically for deterministic sharding + sorted = all_collections.sort + sorted.select.with_index { |_, i| i % total_shards == shard } end def items_for_collection(collection) From 198d465c421162e96986d51b5acde06a7b470bd8 Mon Sep 17 00:00:00 2001 From: Justin Kenyon Date: Fri, 13 Feb 2026 16:30:04 -0500 Subject: [PATCH 2/2] Use explicit nil checks for shard variables --- test/collections_test_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/collections_test_helper.rb b/test/collections_test_helper.rb index 6a7800c3499..54da53c74d2 100644 --- a/test/collections_test_helper.rb +++ b/test/collections_test_helper.rb @@ -61,7 +61,7 @@ def shard_collections(all_collections) shard = ENV["COLLECTION_SHARD"]&.to_i total_shards = ENV["COLLECTION_TOTAL_SHARDS"]&.to_i - return all_collections unless shard && total_shards && total_shards > 1 + return all_collections unless !shard.nil? && !total_shards.nil? && total_shards > 1 # Sort alphabetically for deterministic sharding sorted = all_collections.sort