Skip to content

Fix compare mode to not check node bucket files#179

Merged
etagwerker merged 6 commits intomainfrom
feature/compare-filter-own-buckets
Apr 28, 2026
Merged

Fix compare mode to not check node bucket files#179
etagwerker merged 6 commits intomainfrom
feature/compare-filter-own-buckets

Conversation

@JuanVqz
Copy link
Copy Markdown
Member

@JuanVqz JuanVqz commented Apr 15, 2026

Summary

Compare mode should only run on the final merged shitlist, not on individual shard files. As Ariel noted, shard-level compare is misleading because adding/removing tests changes file distribution across shards.

This PR enforces that pattern by:

  • Preventing use of node_index with compare mode (raises error)
  • Ensures node_index is only for save mode (writing shard files)
  • Updated README to clarify node_index is save-mode only
  • Updated test to verify compare + node_index rejects with clear error

This forces correct usage: compare only runs after merge command on final results.

JuanVqz added 5 commits April 15, 2026 16:49
Compare mode now always filters to buckets the current process
actually ran, regardless of whether node_index is set. This fixes
parallel test support (e.g. parallel_tests gem) where each process
only sees a subset of specs but compares against the full shitlist.

Previously, this filtering was gated behind the parallel? check
which required node_index. Now node_index is only needed for save
mode (to write shard files).
The filter was a no-op: buckets not run by this process have
identical values in both normalized and stored (both read from
the same shitlist file), so they always compare equal.
When node_index is set during compare, target_path would return the
shard path (which does not exist after merge). This caused
normalized_deprecation_messages to read an empty file instead of
the full shitlist, breaking the comparison for non-run buckets.
Ruby 2.3 parses '@mode == :compare ? nil : node_index' as
'@mode == (:compare ? nil : node_index)'. Adding explicit
parentheses fixes the precedence.
@JuanVqz JuanVqz self-assigned this Apr 15, 2026
@JuanVqz JuanVqz requested review from arielj and etagwerker April 15, 2026 23:02
@JuanVqz JuanVqz marked this pull request as ready for review April 15, 2026 23:02
@arielj
Copy link
Copy Markdown

arielj commented Apr 16, 2026

I'm curious, does it even make sense to use compare for a shard?

what I mean is that if you add a new test file, maybe your files tested in each shard change, rendering the compare kinda useless cause you won't be comparing the same files, or if using the timing function in CircleCI to split tests, if tests are added/removed that will change the times and maybe also change the files executed in each shard

I feel like compare should be done at the end of the process after calling the merge command and not for a single shard?

@JuanVqz
Copy link
Copy Markdown
Member Author

JuanVqz commented Apr 16, 2026

I'm curious, does it even make sense to use compare for a shard?

what I mean is that if you add a new test file, maybe your files tested in each shard change, rendering the compare kinda useless cause you won't be comparing the same files, or if using the timing function in CircleCI to split tests, if tests are added/removed that will change the times and maybe also change the files executed in each shard

I feel like compare should be done at the end of the process after calling the merge command and not for a single shard?

@arielj correct, this is the fix to follow that, compare should be run at the end (we cannot enforce that, can we?), what we can is ignore the node files even if the node_index is added, the compare command is only going to use the “general” shitlist file.

Let me double check the changes 🤔

@JuanVqz JuanVqz changed the title Fix compare mode to only check buckets the current process ran Fix compare mode to not check node bucket files Apr 16, 2026
@etagwerker
Copy link
Copy Markdown
Member

I feel like compare should be done at the end of the process after calling the merge command and not for a single shard?

I agree with this.

Would it make sense to not support compare if there is a node_index present? See:

When running tests across parallel CI nodes, each node can write to its own shard file to avoid conflicts. The tracker auto-detects the node index from common CI environment variables (`CI_NODE_INDEX`, `CIRCLE_NODE_INDEX`, `BUILDKITE_PARALLEL_JOB`, `SEMAPHORE_JOB_INDEX`, `CI_NODE_INDEX` for GitLab), or you can set it explicitly via the `node_index` option.

Comment thread lib/deprecation_tracker.rb Outdated
Prevents node_index in compare mode with error. Compare should only run on
final merged shitlist, not on individual shards—shard-level compare is
misleading because adding/removing tests changes file distribution.

Co-Authored-By: Ariel Juodziulis <ariel@ombulabs.com>
Co-Authored-By: Ernesto Tagwerker <ernesto+github@ombulabs.com>
Copy link
Copy Markdown
Member

@etagwerker etagwerker left a comment

Choose a reason for hiding this comment

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

@JuanVqz Looks good, thanks! 👍🏻

@etagwerker etagwerker merged commit dd3cd15 into main Apr 28, 2026
11 checks passed
@etagwerker etagwerker deleted the feature/compare-filter-own-buckets branch April 28, 2026 21:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants