judges 0.52.2 → 0.53.1

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: f56bba6e87688575085f5b43bfec013b8728b31650f5bde0a3eee1af1f3803fa
4
- data.tar.gz: 0c82d6af9a4d2baecd9227cd2c9946f8469e9699b72485b11a4c2c55f2223688
3
+ metadata.gz: 60345e60cca92c8891851f29e255831796747e5451a14934538f52c764c3322e
4
+ data.tar.gz: 27ecf7b216dc3a1f66267168b8bd77c76531067246716765ee3158f6cd1ae00e
5
5
  SHA512:
6
- metadata.gz: 48a484a62e6a68a8375802adc912c57d53dc3affe0b874ff51cd6835b8975c8af6ff4b4633e390bee0c792648360b96e984019e20e42d3086a80550f1a592249
7
- data.tar.gz: 73b1de98081d97c217d49949d388a016b4dda570ce2c53a2942f13b6632934f116cc2e7aca1d502c43f65d1963298994a88ea4b54d7727e23b62dec379987fec
6
+ metadata.gz: 87e466051c31be7106a95670c4508789fac2a790627135e26afeef970306c3e7f9762e20c13641277048929e0e8f430343427da49dac387d5a2f09e9f0cde625
7
+ data.tar.gz: 9aa334a66a192dc65a1e6f7533d6a539c91c72dcbcb7506a0d85ccd01065d7446d58abdd0174dc15c428079078914bf67f08b5aa43a0222155653f82c643799f
@@ -15,7 +15,7 @@ jobs:
15
15
  timeout-minutes: 15
16
16
  runs-on: ubuntu-24.04
17
17
  steps:
18
- - uses: actions/checkout@v4
18
+ - uses: actions/checkout@v5
19
19
  - name: Download actionlint
20
20
  id: get_actionlint
21
21
  run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
@@ -12,7 +12,7 @@ jobs:
12
12
  timeout-minutes: 15
13
13
  runs-on: ubuntu-24.04
14
14
  steps:
15
- - uses: actions/checkout@v4
15
+ - uses: actions/checkout@v5
16
16
  - uses: ruby/setup-ruby@v1
17
17
  with:
18
18
  ruby-version: 3.3
@@ -15,5 +15,5 @@ jobs:
15
15
  timeout-minutes: 15
16
16
  runs-on: ubuntu-24.04
17
17
  steps:
18
- - uses: actions/checkout@v4
18
+ - uses: actions/checkout@v5
19
19
  - uses: yegor256/copyrights-action@0.0.12
@@ -15,6 +15,6 @@ jobs:
15
15
  timeout-minutes: 15
16
16
  runs-on: ubuntu-24.04
17
17
  steps:
18
- - uses: actions/checkout@v4
18
+ - uses: actions/checkout@v5
19
19
  - run: npm install
20
20
  - run: npx eslint .
@@ -19,5 +19,5 @@ jobs:
19
19
  timeout-minutes: 15
20
20
  runs-on: ubuntu-24.04
21
21
  steps:
22
- - uses: actions/checkout@v4
22
+ - uses: actions/checkout@v5
23
23
  - uses: DavidAnson/markdownlint-cli2-action@v20.0.0
@@ -15,5 +15,5 @@ jobs:
15
15
  timeout-minutes: 15
16
16
  runs-on: ubuntu-24.04
17
17
  steps:
18
- - uses: actions/checkout@v4
18
+ - uses: actions/checkout@v5
19
19
  - uses: volodya-lombrozo/pdd-action@master
@@ -18,7 +18,7 @@ jobs:
18
18
  ruby: [3.3]
19
19
  runs-on: ${{ matrix.os }}
20
20
  steps:
21
- - uses: actions/checkout@v4
21
+ - uses: actions/checkout@v5
22
22
  - uses: ruby/setup-ruby@v1
23
23
  with:
24
24
  ruby-version: ${{ matrix.ruby }}
@@ -15,5 +15,5 @@ jobs:
15
15
  timeout-minutes: 15
16
16
  runs-on: ubuntu-24.04
17
17
  steps:
18
- - uses: actions/checkout@v4
18
+ - uses: actions/checkout@v5
19
19
  - uses: fsfe/reuse-action@v5
@@ -15,5 +15,5 @@ jobs:
15
15
  timeout-minutes: 15
16
16
  runs-on: ubuntu-24.04
17
17
  steps:
18
- - uses: actions/checkout@v4
19
- - uses: crate-ci/typos@v1.35.2
18
+ - uses: actions/checkout@v5
19
+ - uses: crate-ci/typos@v1.35.4
@@ -15,5 +15,5 @@ jobs:
15
15
  timeout-minutes: 15
16
16
  runs-on: ubuntu-24.04
17
17
  steps:
18
- - uses: actions/checkout@v4
18
+ - uses: actions/checkout@v5
19
19
  - uses: g4s8/xcop-action@master
@@ -15,5 +15,5 @@ jobs:
15
15
  timeout-minutes: 15
16
16
  runs-on: ubuntu-24.04
17
17
  steps:
18
- - uses: actions/checkout@v4
18
+ - uses: actions/checkout@v5
19
19
  - uses: ibiqlik/action-yamllint@v3
data/Gemfile CHANGED
@@ -6,21 +6,22 @@
6
6
  source 'https://rubygems.org'
7
7
  gemspec
8
8
 
9
- gem 'base64', '~>0.0'
9
+ gem 'base64', '~>0.3'
10
10
  gem 'cucumber', '~>10.0', require: false
11
+ gem 'diff-lcs', '1.6.2', require: false # GPL
11
12
  gem 'minitest', '~>5.25', require: false
12
13
  gem 'minitest-reporters', '~>1.7', require: false
13
14
  gem 'minitest-retry', '~>0.2', require: false
14
15
  gem 'net-ping', '~>2.0', require: false
15
16
  gem 'online', '~>0.0', require: false
16
17
  gem 'os', '~>1.1', require: false
17
- gem 'qbash', '~>0.0', require: false
18
+ gem 'qbash', '~>0.4', require: false
18
19
  gem 'rake', '~>13.2', require: false
19
- gem 'random-port', '~>0.0', require: false
20
+ gem 'random-port', '~>0.7', require: false
20
21
  gem 'rubocop', '~>1.74', require: false
21
- gem 'rubocop-minitest', '~>0.0', require: false
22
+ gem 'rubocop-minitest', '~>0.38', require: false
22
23
  gem 'rubocop-performance', '~>1.25', require: false
23
- gem 'rubocop-rake', '~>0.0', require: false
24
+ gem 'rubocop-rake', '~>0.7', require: false
24
25
  gem 'simplecov', '~>0.22', require: false
25
26
  gem 'simplecov-cobertura', '~>3.0', require: false
26
27
  gem 'w3c_validators', '~>1.3', require: false
data/Gemfile.lock CHANGED
@@ -28,7 +28,7 @@ GEM
28
28
  ast (2.4.3)
29
29
  backtrace (0.4.1)
30
30
  base64 (0.3.0)
31
- baza.rb (0.10.0)
31
+ baza.rb (0.10.1)
32
32
  backtrace (~> 0.4)
33
33
  elapsed (~> 0.0)
34
34
  faraday (~> 2.13)
@@ -67,7 +67,7 @@ GEM
67
67
  bigdecimal
68
68
  cucumber-gherkin (32.2.0)
69
69
  cucumber-messages (> 25, < 28)
70
- cucumber-html-formatter (21.13.0)
70
+ cucumber-html-formatter (21.14.0)
71
71
  cucumber-messages (> 19, < 28)
72
72
  cucumber-messages (27.2.0)
73
73
  cucumber-tag-expressions (6.1.2)
@@ -80,7 +80,7 @@ GEM
80
80
  ellipsized (0.3.0)
81
81
  ethon (0.16.0)
82
82
  ffi (>= 1.15.0)
83
- factbase (0.14.4)
83
+ factbase (0.15.0)
84
84
  backtrace (~> 0.4)
85
85
  decoor (~> 0.0)
86
86
  ellipsized (~> 0.3)
@@ -176,7 +176,7 @@ GEM
176
176
  rake (13.3.0)
177
177
  random-port (0.7.5)
178
178
  tago (> 0)
179
- regexp_parser (2.11.0)
179
+ regexp_parser (2.11.2)
180
180
  retries (0.0.5)
181
181
  rexml (3.4.1)
182
182
  rubocop (1.79.2)
@@ -221,7 +221,7 @@ GEM
221
221
  total (0.4.1)
222
222
  typhoeus (1.4.1)
223
223
  ethon (>= 0.9.0)
224
- unicode-display_width (3.1.4)
224
+ unicode-display_width (3.1.5)
225
225
  unicode-emoji (~> 4.0, >= 4.0.4)
226
226
  unicode-emoji (4.0.4)
227
227
  uri (1.0.3)
@@ -248,8 +248,9 @@ PLATFORMS
248
248
  x86_64-linux-musl
249
249
 
250
250
  DEPENDENCIES
251
- base64 (~> 0.0)
251
+ base64 (~> 0.3)
252
252
  cucumber (~> 10.0)
253
+ diff-lcs (= 1.6.2)
253
254
  judges!
254
255
  minitest (~> 5.25)
255
256
  minitest-reporters (~> 1.7)
@@ -257,13 +258,13 @@ DEPENDENCIES
257
258
  net-ping (~> 2.0)
258
259
  online (~> 0.0)
259
260
  os (~> 1.1)
260
- qbash (~> 0.0)
261
+ qbash (~> 0.4)
261
262
  rake (~> 13.2)
262
- random-port (~> 0.0)
263
+ random-port (~> 0.7)
263
264
  rubocop (~> 1.74)
264
- rubocop-minitest (~> 0.0)
265
+ rubocop-minitest (~> 0.38)
265
266
  rubocop-performance (~> 1.25)
266
- rubocop-rake (~> 0.0)
267
+ rubocop-rake (~> 0.7)
267
268
  simplecov (~> 0.22)
268
269
  simplecov-cobertura (~> 3.0)
269
270
  w3c_validators (~> 1.3)
@@ -16,9 +16,9 @@ Feature: Test
16
16
  And Exit code is zero
17
17
 
18
18
  Scenario: Factbase version can be set
19
- When I run bin/judges with "--factbase 0.14.4 --verbose test --judge guess ./fixtures"
19
+ When I run bin/judges with "--factbase 0.15.0 --verbose test --judge guess ./fixtures"
20
20
  Then Exit code is zero
21
- And Stdout contains "Factbase version to be used: '0.14.4'"
21
+ And Stdout contains "Factbase version to be used: '0.15.0'"
22
22
 
23
23
  Scenario: Simple test of no judges
24
24
  Given I run bin/judges with "test --judge absent_for_sure ./fixtures"
@@ -55,16 +55,15 @@ Feature: Update
55
55
  """
56
56
  n = $fb.insert
57
57
  n.type = 'first'
58
- sleep 1
58
+ sleep 0.9
59
59
  """
60
60
  Then I have a "second/second.rb" file with content:
61
61
  """
62
62
  n = $fb.insert
63
63
  n.type = 'second'
64
64
  """
65
- Then I run bin/judges with "--verbose update --quiet --lifetime 1 --max-cycles 5 . simple.fb"
66
- Then Stdout contains "The 'second' judge skipped, no time left"
67
- Then Stdout contains "Update completed in 1 cycle(s), did 1i/0d/1a"
65
+ Then I run bin/judges with "--verbose update --lifetime 1 --max-cycles 5 . simple.fb"
66
+ Then Stdout contains "Update completed in 1 cycle(s), did 2i/0d/2a"
68
67
  And Exit code is zero
69
68
 
70
69
  Scenario: Use options from a file
data/judges.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
9
9
  s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
10
10
  s.required_ruby_version = '>=3.2'
11
11
  s.name = 'judges'
12
- s.version = '0.52.2'
12
+ s.version = '0.53.1'
13
13
  s.license = 'MIT'
14
14
  s.summary = 'Command-Line Tool for a Factbase'
15
15
  s.description =
@@ -42,11 +42,11 @@ class Judges::Update
42
42
  raise 'Exactly two arguments required' unless args.size == 2
43
43
  dir = args[0]
44
44
  raise "The directory is absent: #{dir.to_rel}" unless File.exist?(dir)
45
- start = Time.now
46
45
  impex = Judges::Impex.new(@loog, args[1])
47
46
  fb = impex.import(strict: false)
48
47
  fb = Factbase::Logged.new(fb, @loog) if opts['log']
49
- options = Judges::Options.new(opts['option'])
48
+ options = Judges::Options.new(timeout: opts['timeout'], lifetime: opts['lifetime'])
49
+ options += Judges::Options.new(opts['option'])
50
50
  if opts['options-file']
51
51
  options += Judges::Options.new(
52
52
  File.readlines(opts['options-file'])
@@ -61,8 +61,19 @@ class Judges::Update
61
61
  else
62
62
  @loog.debug("The following options provided:\n\t#{options.to_s.gsub("\n", "\n\t")}")
63
63
  end
64
- judges = Judges::Judges.new(dir, opts['lib'], @loog, start:, shuffle: opts['shuffle'], boost: opts['boost'],
65
- demote: opts['demote'])
64
+ judges = Judges::Judges.new(
65
+ dir, opts['lib'], @loog,
66
+ start: @start, shuffle: opts['shuffle'], boost: opts['boost'],
67
+ demote: opts['demote']
68
+ )
69
+ Timeout.timeout(opts['lifetime']) do
70
+ loop_them(impex, judges, fb, opts, options)
71
+ end
72
+ end
73
+
74
+ private
75
+
76
+ def loop_them(impex, judges, fb, opts, options)
66
77
  c = 0
67
78
  churn = Factbase::Churn.new
68
79
  errors = []
@@ -79,14 +90,14 @@ class Judges::Update
79
90
  loop do
80
91
  c += 1
81
92
  if c > 1
82
- if opts['lifetime'] && Time.now - @start > opts['lifetime']
93
+ if opts['lifetime'] && Time.now - @start > opts['lifetime'] * 0.51
83
94
  @loog.info("Not starting cycle ##{c}, no time left")
84
95
  c -= 1
85
96
  break
86
97
  end
87
98
  @loog.info("\nStarting cycle ##{c}#{" (out of #{opts['max-cycles']})" if opts['max-cycles']}...")
88
99
  end
89
- delta = cycle(opts, judges, fb, options, start, errors)
100
+ delta = cycle(opts, judges, fb, options, errors)
90
101
  churn += delta
91
102
  impex.export(fb)
92
103
  if delta.zero?
@@ -106,26 +117,23 @@ class Judges::Update
106
117
  throw :"šŸ‘ Update completed in #{c} cycle(s), did #{churn}"
107
118
  end
108
119
  return unless %w[add append].include?(opts['summary'])
109
- summarize(fb, churn, errors, start, c)
120
+ summarize(fb, churn, errors, c)
110
121
  impex.export(fb)
111
122
  end
112
123
 
113
- private
114
-
115
124
  # Update the summary.
116
125
  # @param [Factbase] fb The factbase
117
126
  # @param [Churn] churn The churn
118
127
  # @param [Array<String>] errors List of errors
119
- # @param [Time] start When we started
120
128
  # @param [Integer] cycles How many cycles
121
- def summarize(fb, churn, errors, start, cycles)
129
+ def summarize(fb, churn, errors, cycles)
122
130
  before = fb.query('(eq what "judges-summary")').each.to_a
123
131
  if before.empty?
124
132
  s = fb.insert
125
133
  s.what = 'judges-summary'
126
134
  s.when = Time.now
127
135
  s.version = Judges::VERSION
128
- s.seconds = Time.now - start
136
+ s.seconds = Time.now - @start
129
137
  s.cycles = cycles
130
138
  s.inserted = churn.inserted.size
131
139
  s.deleted = churn.deleted.size
@@ -152,10 +160,9 @@ class Judges::Update
152
160
  # @param [Judges::Judges] judges The judges
153
161
  # @param [Factbase] fb The factbase
154
162
  # @param [Judges::Options] options The options
155
- # @param [Float] start When we started
156
163
  # @param [Array<String>] errors List of errors
157
164
  # @return [Factbase::Churn] How many modifications have been made
158
- def cycle(opts, judges, fb, options, start, errors)
165
+ def cycle(opts, judges, fb, options, errors)
159
166
  churn = Factbase::Churn.new
160
167
  global = {}
161
168
  used = 0
@@ -167,7 +174,7 @@ class Judges::Update
167
174
  next
168
175
  end
169
176
  next unless include?(opts, judge.name)
170
- @loog.info("\nšŸ‘‰ Running #{judge.name} (##{i}) at #{judge.dir.to_rel} (#{start.ago} already)...")
177
+ @loog.info("\nšŸ‘‰ Running #{judge.name} (##{i}) at #{judge.dir.to_rel} (#{@start.ago} already)...")
171
178
  used += 1
172
179
  elapsed(@loog, level: Logger::INFO) do
173
180
  c = one_judge(opts, fb, judge, global, options, errors)
@@ -86,9 +86,14 @@ class Judges::Options
86
86
  # # token → "supe****oken"
87
87
  def to_s
88
88
  to_h.map do |k, v|
89
- v = v.to_s
90
- v = "#{v[0..3]}#{'*' * (v.length - 8)}#{v[-4..]}" if v.length > 8
91
- "#{k} → \"#{v}\""
89
+ v = "#{v[0..3]}#{'*' * (v.length - 8)}#{v[-4..]}" if v.is_a?(String) && v.length > 8
90
+ v =
91
+ if v.is_a?(String)
92
+ "\"#{v}\""
93
+ else
94
+ "#{v} (#{v.class.name})"
95
+ end
96
+ "#{k} → #{v}"
92
97
  end.sort.join("\n")
93
98
  end
94
99
 
data/lib/judges.rb CHANGED
@@ -8,5 +8,5 @@
8
8
  # Copyright:: Copyright (c) 2024-2025 Yegor Bugayenko
9
9
  # License:: MIT
10
10
  module Judges
11
- VERSION = '0.52.2' unless const_defined?(:VERSION)
11
+ VERSION = '0.53.1' unless const_defined?(:VERSION)
12
12
  end
@@ -4,6 +4,7 @@
4
4
  # SPDX-License-Identifier: MIT
5
5
 
6
6
  require 'loog'
7
+ require 'loog/tee'
7
8
  require 'nokogiri'
8
9
  require 'factbase/to_xml'
9
10
  require_relative '../test__helper'
@@ -88,6 +89,30 @@ class TestUpdate < Minitest::Test
88
89
  end
89
90
  end
90
91
 
92
+ def test_terminates_on_lifetime
93
+ Dir.mktmpdir do |d|
94
+ save_it(File.join(d, 'foo/foo.rb'), 'sleep 999')
95
+ file = File.join(d, 'base.fb')
96
+ log = Loog::Buffer.new
97
+ assert_raises(StandardError) do
98
+ Judges::Update.new(Loog::Tee.new(log, Loog::NULL)).run({ 'lifetime' => 0.1 }, [d, file])
99
+ end
100
+ assert_includes(log.to_s, 'execution expired')
101
+ end
102
+ end
103
+
104
+ def test_passes_timeout_and_lifetime_through
105
+ %w[lifetime timeout].each do |o|
106
+ Dir.mktmpdir do |d|
107
+ save_it(File.join(d, 'foo/foo.rb'), "$loog.info '#{o}=' + $options.#{o}.to_s")
108
+ file = File.join(d, 'base.fb')
109
+ log = Loog::Buffer.new
110
+ Judges::Update.new(Loog::Tee.new(log, Loog::NULL)).run({ o => 666 }, [d, file])
111
+ assert_includes(log.to_s, "#{o}=666")
112
+ end
113
+ end
114
+ end
115
+
91
116
  def test_update_with_error_no_quiet
92
117
  assert_raises(StandardError) do
93
118
  Dir.mktmpdir do |d|
data/test/test_options.rb CHANGED
@@ -63,7 +63,7 @@ class TestOptions < Minitest::Test
63
63
  def test_converts_to_string
64
64
  opts = Judges::Options.new('foo' => 44, 'bar' => 'long-string-maybe-secret')
65
65
  s = opts.to_s
66
- assert_includes(s, 'FOO → "44"', s)
66
+ assert_includes(s, 'FOO → 44 (Integer)', s)
67
67
  assert_includes(s, '"long****************cret"', s)
68
68
  end
69
69
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: judges
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.52.2
4
+ version: 0.53.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
@@ -358,7 +358,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
358
358
  - !ruby/object:Gem::Version
359
359
  version: '0'
360
360
  requirements: []
361
- rubygems_version: 3.6.7
361
+ rubygems_version: 3.6.9
362
362
  specification_version: 4
363
363
  summary: Command-Line Tool for a Factbase
364
364
  test_files: []