Skip to content
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- [BUGFIX: example](https://github.com/fastruby/next_rails/pull/<number>)

- [BUGFIX: Compare mode now checks only buckets the current process ran, fixing parallel test support](https://github.com/fastruby/next_rails/pull/179)
- [FEATURE: Add `deprecations merge` command to combine parallel CI shards](https://github.com/fastruby/next_rails/pull/177)
- [FEATURE: Add parallel CI support for DeprecationTracker](https://github.com/fastruby/next_rails/pull/176)
- [CHORE: Add Ruby 4.0 to the test matrix](https://github.com/fastruby/next_rails/pull/178)
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ RSpec.configure do |config|
end
```

When `node_index` is set, the tracker writes to a shard file (e.g. `deprecation_warning.shitlist.node-0.json`) instead of the canonical file.
The `node_index` option is only used in save mode. When set, the tracker writes to a shard file (e.g. `deprecation_warning.shitlist.node-0.json`) instead of the canonical file. Compare mode does not support `node_index` and will raise an error if passed—compare should only run after merging shards on the final canonical shitlist.

#### Merging shards

Expand Down Expand Up @@ -200,9 +200,9 @@ DEPRECATION_TRACKER=save CI_NODE_INDEX=$NODE bundle exec rspec <subset>
# 2. Merge phase — fan-in step, runs once after all nodes finish
deprecations merge --delete-shards

# 3. Compare phase — each parallel node checks its buckets
# against the merged canonical file
DEPRECATION_TRACKER=compare CI_NODE_INDEX=$NODE bundle exec rspec <subset>
# 3. Compare phase — each parallel node checks only its own buckets
# against the merged canonical file (no CI_NODE_INDEX needed)
DEPRECATION_TRACKER=compare bundle exec rspec <subset>
```

### `deprecations` command
Expand Down
11 changes: 4 additions & 7 deletions lib/deprecation_tracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ def initialize(shitlist_path, transform_message = nil, mode = :save, node_index:
@transform_message = transform_message || -> (message) { message }
@deprecation_messages = {}
@mode = mode ? mode.to_sym : :save
if @mode == :compare && node_index
raise ArgumentError, "node_index cannot be used with compare mode"
end
@node_index = node_index
end

Expand Down Expand Up @@ -180,14 +183,8 @@ def compare
stored = read_json(shitlist_path)

changed_buckets = []
buckets_to_check = if parallel?
# In parallel mode, only check buckets that this node actually ran
normalized_deprecation_messages.select { |bucket, _| deprecation_messages.key?(bucket) }
else
normalized_deprecation_messages
end

buckets_to_check.each do |bucket, messages|
normalized_deprecation_messages.each do |bucket, messages|
if stored[bucket] != messages
changed_buckets << bucket
end
Expand Down
16 changes: 11 additions & 5 deletions spec/deprecation_tracker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def self.behavior
end

describe "#compare" do
it "only checks buckets that this node ran" do
it "only checks buckets that this process ran (without node_index)" do
# Set up canonical shitlist with two buckets
setup_tracker = DeprecationTracker.new(shitlist_path)
setup_tracker.bucket = "bucket 1"
Expand All @@ -370,21 +370,27 @@ def self.behavior
setup_tracker.add("b")
setup_tracker.save

# Parallel node only runs bucket 2 with matching deprecations
tracker = DeprecationTracker.new(shitlist_path, nil, :compare, node_index: "0")
# Process only runs bucket 2 with matching deprecations, no node_index needed
tracker = DeprecationTracker.new(shitlist_path, nil, :compare)
tracker.bucket = "bucket 2"
tracker.add("b")

expect { tracker.compare }.not_to raise_error
end

it "raises when this node's buckets have changed" do
it "raises error when node_index is passed with compare mode" do
expect do
DeprecationTracker.new(shitlist_path, nil, :compare, node_index: "0")
end.to raise_error(ArgumentError, "node_index cannot be used with compare mode")
end

it "raises when this process's buckets have changed" do
setup_tracker = DeprecationTracker.new(shitlist_path)
setup_tracker.bucket = "bucket 1"
setup_tracker.add("a")
setup_tracker.save

tracker = DeprecationTracker.new(shitlist_path, nil, :compare, node_index: "0")
tracker = DeprecationTracker.new(shitlist_path, nil, :compare)
tracker.bucket = "bucket 1"
tracker.add("different")

Expand Down
Loading