Skip to content

Add parallel CI support for DeprecationTracker#176

Merged
etagwerker merged 20 commits intomainfrom
feature/parallel-ci-deprecation-tracker
Apr 3, 2026
Merged

Add parallel CI support for DeprecationTracker#176
etagwerker merged 20 commits intomainfrom
feature/parallel-ci-deprecation-tracker

Conversation

@JuanVqz
Copy link
Copy Markdown
Member

@JuanVqz JuanVqz commented Apr 2, 2026

Description

Add support for running deprecation tracking across parallel CI nodes. Each node writes to its own shard file, and compare mode only checks the buckets that the current node ran.

Also adds sensible default values, fixes bugs, and improves naming throughout DeprecationTracker.

Changes

Parallel CI support

  • Add node_index option to constructor and init_tracker
  • In save mode with node_index, write to shard file (e.g., *.node-0.json)
  • In compare mode with node_index, only check buckets this node exercised
  • Extract target_path method for write path resolution

Default values

  • shitlist_path defaults to spec/support/deprecation_warning.shitlist.json
  • mode defaults to ENV["DEPRECATION_TRACKER"] then :save

Bug fixes

  • Fix NoMethodError when mode is nil in constructor
  • Memoize normalized_deprecation_messages to avoid repeated disk reads

Refactors

  • Rename methods: read_shitlistread_json, create_temp_shitlistcreate_temp_file
  • Rename variables: new_shitlisttemp_file, shitliststored
  • Rename constant: DEFAULT_SHITLIST_PATHDEFAULT_PATH
  • Use idiomatic any? instead of length > 0

Usage

# Simplest form — all defaults:
DeprecationTracker.track_rspec(config)

# With parallel CI:
DeprecationTracker.track_rspec(config,
  node_index: ENV["CIRCLE_NODE_INDEX"]
)

How Has This Been Tested?

  • 34 deprecation tracker specs pass (23 existing + 11 new)
  • Full suite passes (71 examples, 0 failures)
  • Manual local simulation of parallel save/compare works correctly

I will abide by the code of conduct

JuanVqz added 19 commits April 2, 2026 01:07
Add node_index option to support running deprecation tracking across
parallel CI nodes. Each node writes to a shard file (e.g.,
*.node-0.json) in save mode, and compares only its own buckets in
compare mode.

Also adds default values for shitlist_path and mode, and a
detect_node_index class method that auto-detects common CI env vars
(CircleCI, Buildkite, Semaphore, GitLab CI).
Users know their CI env vars — they can pass node_index directly
(e.g., node_index: ENV["CIRCLE_NODE_INDEX"]).
The constructor calls mode.to_sym which crashes with NoMethodError
when mode is nil. This happens when calling DeprecationTracker.new
directly without a mode argument (e.g., DeprecationTracker.new("path",
nil, nil)). The init_tracker method has its own fallback, but the
constructor is public and should handle nil gracefully.

Now falls back to :save when mode is nil, matching the documented
default behavior.
In compare mode, normalized_deprecation_messages was called multiple
times: once in compare to build buckets_to_check, and again in diff
via create_temp_file. Each call triggered a read_json disk read and
JSON parse of the same file.

Since this method is only called after the test run completes (via
after_run), the data cannot change between calls. Memoizing it
eliminates redundant file I/O.
The diff method interpolates shitlist_path directly into a backtick
shell command. File paths containing spaces or special characters
cause git diff to fail silently, producing an empty diff in the
error message.

Now uses Shellwords.shellescape to properly quote both file paths
before passing them to the shell.
Consistent with the other renames in this branch that moved away
from the "shitlist" naming in method and variable names.
Array#any? has been available since Ruby 1.8 and is the idiomatic
way to check for a non-empty collection in Ruby.
The ensure keyword inside a block (do...end) without an explicit
begin is only supported in Ruby 2.5+. Wrap with begin/ensure/end
for compatibility with Ruby 2.4 and older.
Removing the Shellwords change and its test to keep this PR focused
on parallel CI support and renames. The spaces-in-path fix can be
addressed in a separate PR.
@JuanVqz JuanVqz marked this pull request as ready for review April 2, 2026 08:08
@JuanVqz JuanVqz requested a review from etagwerker April 2, 2026 08:08
Previously hardcoded .json in chomp/append, which would produce
incorrect shard paths for files with non-.json extensions.
Now uses File.extname to handle any file extension correctly.
@JuanVqz JuanVqz force-pushed the feature/parallel-ci-deprecation-tracker branch from a061cd7 to f8c203d Compare April 2, 2026 08:09
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 These changes look good but I wonder how you're planning to handle the merge process?

@JuanVqz
Copy link
Copy Markdown
Member Author

JuanVqz commented Apr 2, 2026

@JuanVqz These changes look good but I wonder how you're planning to handle the merge process?

@etagwerker
The change should be backwards compatible when no parallelism is configured.

Was thinking on releasing a minor version or probably I can release a dev/pre release version (have to investigate that) to test and once we confirm it works release a stable version?

is that what you mean?
Or what is your concern?

@etagwerker
Copy link
Copy Markdown
Member

@JuanVqz oh, no, I'm sorry. I meant to ask how you're gonna handle the merge process for the JSON files. Is there gonna be utility class or rake task to merge them once the user gets them from CI?

@JuanVqz
Copy link
Copy Markdown
Member Author

JuanVqz commented Apr 2, 2026

@JuanVqz oh, no, I'm sorry. I meant to ask how you're gonna handle the merge process for the JSON files. Is there gonna be utility class or rake task to merge them once the user gets them from CI?

@etagwerker Now I get it, yes I'm going to create a new class to do that I already started it but wanted you to code review this first to don't n make a huge PR and kind of checking if you were interested in the feature first.

I've seeing some work around it I. The past and I know it is a bit complicated.

For first version wanted to merge them locally probably with a command line, then one it's stable, let's try to implementó something that runs in CI.

Thoughts?

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 These changes look good but I wonder how you're planning to handle the merge process?

@etagwerker etagwerker merged commit da42d0d into main Apr 3, 2026
10 checks passed
@etagwerker etagwerker deleted the feature/parallel-ci-deprecation-tracker branch April 3, 2026 01:32
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.

2 participants