Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 && total_shards && total_shards > 1
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition shard && total_shards && total_shards > 1 will fail when shard is 0 because 0 is falsy in Ruby. This means shard 0 (the first shard in the matrix) will incorrectly test all collections instead of just every 4th collection starting at index 0. The condition should check for nil explicitly instead: !shard.nil? && !total_shards.nil? && total_shards > 1.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 198d465 — switched to explicit nil checks: !shard.nil? && !total_shards.nil? && total_shards > 1. This also avoids the falsy-zero bug for shard 0. Thanks for the catch!


# 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