Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
14 changes: 13 additions & 1 deletion test/collections_test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.nil? && !total_shards.nil? && 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)
Expand Down
Loading