runtime_groups 0.1.1 → 0.1.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 14133d120fc0a29b48cf24973d76504d49c6a3063c09b73c494ebe84d245e929
4
- data.tar.gz: 2c149b3ed4d6ddd3bad32063d99abcd8263262b41886649b1ad96e1f7ab812a0
3
+ metadata.gz: fb6eeb7a45ee1a7dae2072cfa6e6d96b03988ce740a97ab00ce69f564b504f95
4
+ data.tar.gz: ba9764052dd5d0e9ee4987d2e009d7d8ddfd0ec742d4b745cee657c4a7417273
5
5
  SHA512:
6
- metadata.gz: fb3550fb570bef59d0b61b1c8da6647756b7610b6064571462023936678aff347a9ffd285bab4e0bc6eec9a1dd52b5206496f6ed1bc11bf72139724244330ddb
7
- data.tar.gz: 62d5525c8e0ccb1f1ad61d5b77e7352673d0cd7e5b32310f2d95a1ee079b928244178edc098a8ae41b1d1b75fbabc9604efa86b9128b5edffbd2a4667ff95245
6
+ metadata.gz: 5e83bda062f55d886b6fcd0dbdc0fbc3fe6f6d1ecfc5485904a096f17ea2a66c3674d154d104913c76ae279bf8576afef609fe81c97f181d7f4baa8159fea621
7
+ data.tar.gz: b33b9766c0390b24146afd41f0bab97450987853a79c4a30b3163032113b8d89dcf2dd33f93ef5850f65fd6c8fb13d4a2e0f1c6fc42b96441b4fce9d2e472f29
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -30,6 +30,28 @@ Please file a bug if you notice a violation of semantic versioning.
30
30
 
31
31
  ### Security
32
32
 
33
+ ## [0.1.3] - 2026-10-15
34
+
35
+ - TAG: [v0.1.3][0.1.3t]
36
+ - COVERAGE: 99.22% -- 127/128 lines in 6 files
37
+ - BRANCH COVERAGE: 96.88% -- 31/32 branches in 6 files
38
+ - 93.55% documented
39
+
40
+ ### Fixed
41
+
42
+ - Pids#to_a tolerates the ledger file vanishing between the existence guard and the read (TOCTOU with concurrent PidFile teardown during worker untracking, seen on truffleruby as Errno::ENOENT mid-suite); returns an empty ledger instead
43
+
44
+ ## [0.1.2] - 2026-10-15
45
+
46
+ - TAG: [v0.1.2][0.1.2t]
47
+ - COVERAGE: 99.21% -- 125/126 lines in 6 files
48
+ - BRANCH COVERAGE: 96.88% -- 31/32 branches in 6 files
49
+ - 93.55% documented
50
+
51
+ ### Added
52
+
53
+ - Grouping runtime weights accept unknown_runtime: explicit weight for files missing from the runtime log, instead of the default (average of known runtimes, or 1.0 when nothing is known); parity with parallel_tests' --unknown-runtime, consumed by turbo_tests2's --unknown-runtime flag
54
+
33
55
  ## [0.1.1] - 2026-10-15
34
56
 
35
57
  - TAG: [v0.1.1][0.1.1t]
@@ -140,7 +162,11 @@ Please file a bug if you notice a violation of semantic versioning.
140
162
  legacy manual bundle install path, avoiding setup-time Bundler full-index
141
163
  failures against `gem.coop`.
142
164
 
143
- [Unreleased]: https://github.com/galtzo-floss/runtime_groups/compare/v0.1.1...HEAD
165
+ [Unreleased]: https://github.com/galtzo-floss/runtime_groups/compare/v0.1.3...HEAD
166
+ [0.1.3]: https://github.com/galtzo-floss/runtime_groups/compare/v0.1.2...v0.1.3
167
+ [0.1.3t]: https://github.com/galtzo-floss/runtime_groups/releases/tag/v0.1.3
168
+ [0.1.2]: https://github.com/galtzo-floss/runtime_groups/compare/v0.1.1...v0.1.2
169
+ [0.1.2t]: https://github.com/galtzo-floss/runtime_groups/releases/tag/v0.1.2
144
170
  [0.1.1]: https://github.com/galtzo-floss/runtime_groups/compare/v0.1.0...v0.1.1
145
171
  [0.1.1t]: https://github.com/galtzo-floss/runtime_groups/releases/tag/v0.1.1
146
172
  [0.1.0]: https://github.com/galtzo-floss/runtime_groups/compare/e8764d41152b587dbc972e0abe97098794232b36...v0.1.0
data/README.md CHANGED
@@ -562,7 +562,7 @@ Thanks for RTFM. ☺️
562
562
  [📌gitmoji]: https://gitmoji.dev
563
563
  [📌gitmoji-img]: https://img.shields.io/badge/gitmoji_commits-%20%F0%9F%98%9C%20%F0%9F%98%8D-34495e.svg?style=flat-square
564
564
  [🧮kloc]: https://www.youtube.com/watch?v=dQw4w9WgXcQ
565
- [🧮kloc-img]: https://img.shields.io/badge/KLOC-0.125-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue
565
+ [🧮kloc-img]: https://img.shields.io/badge/KLOC-0.128-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue
566
566
  [🔐security]: https://github.com/galtzo-floss/runtime_groups/blob/main/SECURITY.md
567
567
  [🔐security-img]: https://img.shields.io/badge/security-policy-259D6C.svg?style=flat
568
568
  [📄copyright-notice-explainer]: https://opensource.stackexchange.com/questions/5778/why-do-licenses-such-as-the-mit-license-specify-a-single-year
@@ -25,17 +25,20 @@ module RuntimeGroups
25
25
  # @param runtime_log [String, nil] runtime log path (for :runtime)
26
26
  # @param allowed_missing [Float] fraction of files allowed to be missing
27
27
  # from the runtime log before {RuntimeLogTooSmallError} is raised
28
+ # @param unknown_runtime [Float, nil] weight for files missing from the
29
+ # runtime log; nil (default) uses the average of the known runtimes,
30
+ # or 1.0 when nothing is known
28
31
  # @return [Hash{String => Float}] file => weight
29
32
  # @raise [RuntimeGroups::RuntimeLogTooSmallError] when too many files are
30
33
  # missing from the runtime log
31
- def with_size(files, group_by: :runtime, runtime_log: nil, allowed_missing: 1.0)
34
+ def with_size(files, group_by: :runtime, runtime_log: nil, allowed_missing: 1.0, unknown_runtime: nil)
32
35
  case group_by
33
36
  when :found
34
37
  files.each_with_object({}) { |file, memo| memo[file] = 1.0 }
35
38
  when :filesize
36
39
  files.each_with_object({}) { |file, memo| memo[file] = File.stat(file).size.to_f }
37
40
  when :runtime
38
- runtime_weights(files, runtime_log, allowed_missing)
41
+ runtime_weights(files, runtime_log, allowed_missing, unknown_runtime)
39
42
  else
40
43
  raise Error, "invalid group-by mode #{group_by.inspect}; expected one of: runtime, filesize, found"
41
44
  end
@@ -50,11 +53,19 @@ module RuntimeGroups
50
53
  # @param runtime_log [String, nil] runtime log path (for :runtime)
51
54
  # @param allowed_missing [Float] fraction of files allowed to be missing
52
55
  # from the runtime log
56
+ # @param unknown_runtime [Float, nil] weight for files missing from the
57
+ # runtime log (nil = average of known, or 1.0 when nothing is known)
53
58
  # @return [Array<Array<String>>] exactly `num_groups` arrays of file paths
54
59
  # @raise [RuntimeGroups::Error] when num_groups or group_by is invalid
55
- def in_groups(files, num_groups, group_by: :runtime, runtime_log: nil, allowed_missing: 1.0)
60
+ def in_groups(files, num_groups, group_by: :runtime, runtime_log: nil, allowed_missing: 1.0, unknown_runtime: nil)
56
61
  groups = Array.new(RuntimeGroups.parse_count!(num_groups)) { {weight: 0.0, files: []} }
57
- weights = with_size(files, group_by: group_by, runtime_log: runtime_log, allowed_missing: allowed_missing)
62
+ weights = with_size(
63
+ files,
64
+ group_by: group_by,
65
+ runtime_log: runtime_log,
66
+ allowed_missing: allowed_missing,
67
+ unknown_runtime: unknown_runtime
68
+ )
58
69
 
59
70
  files.sort_by { |file| [-weights[file], file] }.each do |file|
60
71
  target = groups.min_by { |group| group[:weight] }
@@ -65,11 +76,11 @@ module RuntimeGroups
65
76
  groups.map { |group| group[:files] }
66
77
  end
67
78
 
68
- # Runtime weights with the missing-file budget and average-fill semantics
79
+ # Runtime weights with the missing-file budget and fill semantics
69
80
  # retained from `parallel_tests`.
70
81
  #
71
82
  # @return [Hash{String => Float}]
72
- def runtime_weights(files, runtime_log, allowed_missing)
83
+ def runtime_weights(files, runtime_log, allowed_missing, unknown_runtime = nil)
73
84
  budget = files.size * allowed_missing
74
85
  runtimes = RuntimeLog.read(runtime_log)
75
86
  known, unknown = [], []
@@ -88,7 +99,8 @@ module RuntimeGroups
88
99
  end
89
100
 
90
101
  weights = known.each_with_object({}) { |(file, seconds), memo| memo[file] = seconds }
91
- fill = known.empty? ? 1.0 : known.map(&:last).sum / known.size
102
+ fill = unknown_runtime ||
103
+ (known.empty? ? 1.0 : known.map(&:last).sum / known.size)
92
104
  unknown.each { |file| weights[file] = fill }
93
105
  weights
94
106
  end
@@ -19,11 +19,19 @@ module RuntimeGroups
19
19
  end
20
20
 
21
21
  # @return [Array<Integer>] the pids currently recorded, deduplicated and
22
- # sorted ascending; empty when the file does not exist yet
22
+ # sorted ascending; empty when the file does not exist (or vanishes
23
+ # mid-read — a ledger owned by {PidFile.with} is deleted concurrently
24
+ # with worker teardown, so the entry guard cannot close that window)
23
25
  def to_a
24
26
  return [] unless File.file?(@path)
25
27
 
26
- File.readlines(@path).map do |line|
28
+ begin
29
+ lines = File.readlines(@path)
30
+ rescue Errno::ENOENT
31
+ return []
32
+ end
33
+
34
+ lines.map do |line|
27
35
  begin
28
36
  Integer(line.strip, 10)
29
37
  rescue ArgumentError
@@ -4,7 +4,7 @@ module RuntimeGroups
4
4
  # Version namespace for this gem.
5
5
  module Version
6
6
  # Current gem version.
7
- VERSION = "0.1.1"
7
+ VERSION = "0.1.3"
8
8
  end
9
9
  # Current gem version exposed at the traditional constant location.
10
10
  VERSION = Version::VERSION # Traditional Constant Location
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runtime_groups
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter H. Boling
@@ -284,10 +284,10 @@ licenses:
284
284
  - MIT
285
285
  metadata:
286
286
  homepage_uri: https://github.com/galtzo-floss/runtime_groups
287
- source_code_uri: https://github.com/galtzo-floss/runtime_groups/tree/v0.1.1
288
- changelog_uri: https://github.com/galtzo-floss/runtime_groups/blob/v0.1.1/CHANGELOG.md
287
+ source_code_uri: https://github.com/galtzo-floss/runtime_groups/tree/v0.1.3
288
+ changelog_uri: https://github.com/galtzo-floss/runtime_groups/blob/v0.1.3/CHANGELOG.md
289
289
  bug_tracker_uri: https://github.com/galtzo-floss/runtime_groups/issues
290
- documentation_uri: https://www.rubydoc.info/gems/runtime_groups/0.1.1
290
+ documentation_uri: https://www.rubydoc.info/gems/runtime_groups/0.1.3
291
291
  funding_uri: https://github.com/sponsors/pboling
292
292
  wiki_uri: https://github.com/galtzo-floss/runtime_groups/wiki
293
293
  news_uri: https://www.railsbling.com/tags/runtime_groups
metadata.gz.sig CHANGED
Binary file