polyrun 2.2.4 → 2.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +28 -0
  3. data/README.md +4 -1
  4. data/docs/SETUP_PROFILE.md +1 -0
  5. data/lib/polyrun/cli/database_commands.rb +21 -7
  6. data/lib/polyrun/cli/default_run.rb +28 -6
  7. data/lib/polyrun/cli/help.rb +4 -2
  8. data/lib/polyrun/cli/helpers.rb +41 -6
  9. data/lib/polyrun/cli/plan_command.rb +10 -29
  10. data/lib/polyrun/cli/run_queue_command.rb +10 -1
  11. data/lib/polyrun/cli/run_shards_command.rb +2 -8
  12. data/lib/polyrun/cli/run_shards_parallel_children.rb +52 -39
  13. data/lib/polyrun/cli/run_shards_parallel_wait.rb +2 -2
  14. data/lib/polyrun/cli/run_shards_plan_boot_phases.rb +3 -0
  15. data/lib/polyrun/cli/run_shards_planning.rb +16 -29
  16. data/lib/polyrun/cli/run_shards_run.rb +1 -1
  17. data/lib/polyrun/cli/run_shards_worker_interrupt.rb +16 -14
  18. data/lib/polyrun/cli/start_bootstrap.rb +51 -22
  19. data/lib/polyrun/cli.rb +8 -1
  20. data/lib/polyrun/config.rb +9 -4
  21. data/lib/polyrun/coverage/example_diff.rb +6 -7
  22. data/lib/polyrun/coverage/merge/formatters_html.rb +20 -2
  23. data/lib/polyrun/coverage/merge.rb +9 -3
  24. data/lib/polyrun/coverage/merge_fragment_meta.rb +6 -1
  25. data/lib/polyrun/coverage/rails.rb +1 -1
  26. data/lib/polyrun/database/clone_shards.rb +28 -5
  27. data/lib/polyrun/database/provision.rb +15 -9
  28. data/lib/polyrun/database/url_builder/connection/infer.rb +4 -0
  29. data/lib/polyrun/database/url_builder.rb +31 -3
  30. data/lib/polyrun/partition/paths.rb +23 -4
  31. data/lib/polyrun/partition/plan.rb +6 -24
  32. data/lib/polyrun/partition/suite.rb +116 -0
  33. data/lib/polyrun/partition/timing_diagnostics.rb +2 -3
  34. data/lib/polyrun/queue/file_store.rb +133 -30
  35. data/lib/polyrun/queue/file_store_intent.rb +188 -0
  36. data/lib/polyrun/queue/worker_loop.rb +41 -7
  37. data/lib/polyrun/spec_quality/config.rb +1 -1
  38. data/lib/polyrun/spec_quality/profile.rb +0 -1
  39. data/lib/polyrun/spec_quality/report.rb +16 -7
  40. data/lib/polyrun/templates/rails_prepare.polyrun.yml +3 -1
  41. data/lib/polyrun/version.rb +1 -1
  42. data/lib/polyrun/worker_output.rb +30 -13
  43. data/lib/polyrun.rb +1 -0
  44. metadata +3 -1
@@ -158,13 +158,7 @@ module Polyrun
158
158
  violations << "zero_hit_examples=#{analysis[:zero_hit].size} max=#{max_zero}"
159
159
  end
160
160
 
161
- min_unique = cfg["minimum_unique_lines_per_example"]
162
- if min_unique
163
- bad = analysis[:zero_hit].keys
164
- if bad.size.positive?
165
- violations << "examples_below_minimum_unique_lines=#{bad.size} minimum=#{min_unique}"
166
- end
167
- end
161
+ violations.concat(minimum_unique_line_violations(merged, cfg))
168
162
 
169
163
  max_hot = cfg["max_hot_line_overlap"]
170
164
  if max_hot
@@ -175,6 +169,21 @@ module Polyrun
175
169
  violations
176
170
  end
177
171
 
172
+ def minimum_unique_line_violations(merged, cfg)
173
+ violations = []
174
+ min_unique = cfg["minimum_unique_lines_per_example"]
175
+ if min_unique
176
+ threshold = min_unique.to_i
177
+ examples = merged["examples"] || {}
178
+ bad = examples.select { |_loc, row| row["unique_lines"].to_i < threshold }.keys
179
+ if bad.size.positive?
180
+ violations << "examples_below_minimum_unique_lines=#{bad.size} minimum=#{min_unique}"
181
+ end
182
+ end
183
+
184
+ violations
185
+ end
186
+
178
187
  def emit_warnings!(merged, cfg = {})
179
188
  analyze(merged, cfg).fetch(:line_churn, {}).each do |loc, row|
180
189
  Polyrun::Log.warn "polyrun spec-quality line_churn: #{loc} churn=#{row["line_churn"]}"
@@ -22,7 +22,9 @@ prepare:
22
22
  # merge_spec_quality: true
23
23
  # merge_spec_quality_output: coverage/polyrun-spec-quality.json
24
24
 
25
- # Uncomment and edit when using Postgres template + per-shard DB names from polyrun env:
25
+ # Uncomment and edit when using Postgres template + per-shard DB names from polyrun env.
26
+ # CloneShards / polyrun start auto provision is PostgreSQL-only. For mysql2 (or other adapters),
27
+ # keep template_db + shard_db_pattern for URL shaping, set start.databases: false, and provision shards in prepare.
26
28
  # databases:
27
29
  # template_db: my_app_template
28
30
  # shard_db_pattern: "my_app_test_%{shard}"
@@ -1,3 +1,3 @@
1
1
  module Polyrun
2
- VERSION = "2.2.4"
2
+ VERSION = "2.2.6"
3
3
  end
@@ -55,20 +55,37 @@ module Polyrun
55
55
  out_read, out_write = IO.pipe
56
56
  err_read, err_write = IO.pipe
57
57
 
58
- pid =
59
- if hook_cfg.worker_hooks? && !Polyrun::Hooks.disabled?
60
- Process.spawn(
61
- child_env,
62
- "sh",
63
- "-c",
64
- hook_cfg.build_worker_shell_script(cmd, paths),
65
- out: out_write,
66
- err: err_write
67
- )
68
- else
69
- # Array(cmd) so a String command is one argv element (not character-splatted).
70
- Process.spawn(child_env, *Array(cmd), *Array(paths), out: out_write, err: err_write)
58
+ begin
59
+ pid =
60
+ if hook_cfg.worker_hooks? && !Polyrun::Hooks.disabled?
61
+ Process.spawn(
62
+ child_env,
63
+ "sh",
64
+ "-c",
65
+ hook_cfg.build_worker_shell_script(cmd, paths),
66
+ out: out_write,
67
+ err: err_write,
68
+ pgroup: true
69
+ )
70
+ else
71
+ # Array(cmd) so a String command is one argv element (not character-splatted).
72
+ Process.spawn(
73
+ child_env,
74
+ *Array(cmd),
75
+ *Array(paths),
76
+ out: out_write,
77
+ err: err_write,
78
+ pgroup: true
79
+ )
80
+ end
81
+ rescue
82
+ [out_read, out_write, err_read, err_write].each do |io|
83
+ io.close unless io.closed?
84
+ rescue IOError
85
+ nil
71
86
  end
87
+ raise
88
+ end
72
89
 
73
90
  out_write.close
74
91
  err_write.close
data/lib/polyrun.rb CHANGED
@@ -11,6 +11,7 @@ require_relative "polyrun/coverage/reporting"
11
11
  require_relative "polyrun/coverage/rails"
12
12
  require_relative "polyrun/partition/plan"
13
13
  require_relative "polyrun/partition/paths"
14
+ require_relative "polyrun/partition/suite"
14
15
  require_relative "polyrun/partition/paths_build"
15
16
  require_relative "polyrun/queue/file_store"
16
17
  require_relative "polyrun/data/fixtures"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polyrun
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.4
4
+ version: 2.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Makarov
@@ -313,6 +313,7 @@ files:
313
313
  - lib/polyrun/partition/plan_sharding.rb
314
314
  - lib/polyrun/partition/reports.rb
315
315
  - lib/polyrun/partition/stable_shuffle.rb
316
+ - lib/polyrun/partition/suite.rb
316
317
  - lib/polyrun/partition/timing_diagnostics.rb
317
318
  - lib/polyrun/partition/timing_keys.rb
318
319
  - lib/polyrun/prepare/artifacts.rb
@@ -320,6 +321,7 @@ files:
320
321
  - lib/polyrun/process_stdio.rb
321
322
  - lib/polyrun/queue/duration.rb
322
323
  - lib/polyrun/queue/file_store.rb
324
+ - lib/polyrun/queue/file_store_intent.rb
323
325
  - lib/polyrun/queue/file_store_pending.rb
324
326
  - lib/polyrun/queue/worker_loop.rb
325
327
  - lib/polyrun/quick.rb