judges 0.42.1 ā 0.44.0
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 +4 -4
- data/.github/workflows/eslint.yml +2 -3
- data/.github/workflows/markdown-lint.yml +1 -1
- data/.gitignore +1 -0
- data/Gemfile.lock +5 -3
- data/assets/index.js +3 -3
- data/bin/judges +49 -45
- data/features/import.feature +1 -1
- data/features/update.feature +5 -5
- data/judges.gemspec +1 -1
- data/lib/judges/commands/eval.rb +2 -2
- data/lib/judges/commands/import.rb +2 -2
- data/lib/judges/commands/inspect.rb +2 -2
- data/lib/judges/commands/join.rb +2 -2
- data/lib/judges/commands/print.rb +4 -3
- data/lib/judges/commands/pull.rb +5 -4
- data/lib/judges/commands/push.rb +3 -2
- data/lib/judges/commands/test.rb +2 -1
- data/lib/judges/commands/trim.rb +4 -3
- data/lib/judges/commands/update.rb +17 -3
- data/lib/judges/judge.rb +1 -1
- data/lib/judges.rb +1 -1
- data/package-lock.json +34 -915
- data/package.json +3 -2
- data/test/commands/test_update.rb +51 -0
- data/test/test__helper.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc9d8bdc800247520e9f42a07f90143c7c3fcf505a4a993221d7aa8437b11611
|
4
|
+
data.tar.gz: 21d88232ebe5299cf672945ab83c702a3c942d984f233bd9f714fb2cdb846609
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb1ac7d1219d4f901c5856e8c2698c4e77eaf5a3b0f8f0658bc94e1304f5597b3cada4a9c1ba85660bbaebd81a2e03cea58a92b7ba8e1a2c820e3403ea269a60
|
7
|
+
data.tar.gz: a9937c3f3d031d3d2c6e1265d8ccc2bf0365ffcda171d539bdf03a22d68d6a3d887a6010beb876c17fd1f2a31cd38d06d0e7473861bc3e6cb2a21b62857041a3
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -78,6 +78,7 @@ GEM
|
|
78
78
|
elapsed (0.0.1)
|
79
79
|
loog (> 0)
|
80
80
|
tago (> 0)
|
81
|
+
erb (5.0.1)
|
81
82
|
ethon (0.16.0)
|
82
83
|
ffi (>= 1.15.0)
|
83
84
|
factbase (0.10.2)
|
@@ -111,7 +112,7 @@ GEM
|
|
111
112
|
ffi (1.17.2-x86_64-linux-gnu)
|
112
113
|
gli (2.22.2)
|
113
114
|
ostruct
|
114
|
-
hashdiff (1.
|
115
|
+
hashdiff (1.2.0)
|
115
116
|
iri (0.10.0)
|
116
117
|
json (2.12.0)
|
117
118
|
language_server-protocol (3.17.0.5)
|
@@ -172,12 +173,13 @@ GEM
|
|
172
173
|
rake (13.2.1)
|
173
174
|
random-port (0.7.5)
|
174
175
|
tago (> 0)
|
175
|
-
rdoc (6.
|
176
|
+
rdoc (6.14.0)
|
177
|
+
erb
|
176
178
|
psych (>= 4.0.0)
|
177
179
|
regexp_parser (2.10.0)
|
178
180
|
retries (0.0.5)
|
179
181
|
rexml (3.4.1)
|
180
|
-
rubocop (1.75.
|
182
|
+
rubocop (1.75.7)
|
181
183
|
json (~> 2.3)
|
182
184
|
language_server-protocol (~> 3.17.0.2)
|
183
185
|
lint_roller (~> 1.1.0)
|
data/assets/index.js
CHANGED
data/bin/judges
CHANGED
@@ -23,7 +23,7 @@ class JudgesGLI extend GLI::App
|
|
23
23
|
start = Time.now
|
24
24
|
@@loog.debug("Running '#{ruby}' command...")
|
25
25
|
Object.const_get("Judges::#{ruby.capitalize}").new(@@loog).run(options, args)
|
26
|
-
@@loog.debug("Command '#{ruby}'
|
26
|
+
@@loog.debug("Command '#{ruby}' completed in #{start.ago}")
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -37,9 +37,9 @@ class JudgesGLI extend GLI::App
|
|
37
37
|
|
38
38
|
subcommand_option_handling(:normal)
|
39
39
|
|
40
|
-
desc '
|
40
|
+
desc 'Enable verbose mode with maximum logging'
|
41
41
|
switch([:v, :verbose])
|
42
|
-
desc '
|
42
|
+
desc 'Specify Factbase version to use'
|
43
43
|
flag([:factbase], type: String)
|
44
44
|
|
45
45
|
pre do |global, command, options, args|
|
@@ -61,36 +61,40 @@ class JudgesGLI extend GLI::App
|
|
61
61
|
true
|
62
62
|
end
|
63
63
|
|
64
|
-
desc 'Update the factbase by
|
64
|
+
desc 'Update the factbase by executing all judges sequentially'
|
65
65
|
command :update do |c|
|
66
|
-
c.desc 'Options to pass to
|
66
|
+
c.desc 'Options to pass to each judge'
|
67
67
|
c.flag([:o, :option], multiple: true, arg_name: '<key=value>')
|
68
|
-
c.desc 'File
|
68
|
+
c.desc 'File containing options, one key=value pair per line'
|
69
69
|
c.flag([:'options-file'])
|
70
70
|
c.desc 'Name of the judge to run (directory name)'
|
71
71
|
c.flag([:judge], multiple: true)
|
72
|
-
c.desc '
|
72
|
+
c.desc 'Location of a Ruby library (directory with .rb files to include)'
|
73
73
|
c.flag([:lib])
|
74
|
-
c.desc 'Shuffle
|
74
|
+
c.desc 'Shuffle judges, except those starting with the specified prefix'
|
75
75
|
c.flag([:shuffle], default_value: '')
|
76
|
-
c.desc '
|
76
|
+
c.desc 'Prioritize a judge to run before all others'
|
77
77
|
c.flag([:boost], multiple: true)
|
78
|
-
c.desc 'Maximum time in seconds
|
78
|
+
c.desc 'Maximum time in seconds for the entire update cycle'
|
79
79
|
c.flag([:lifetime], default_value: 300, type: Integer)
|
80
|
-
c.desc 'Maximum time in seconds
|
80
|
+
c.desc 'Maximum time in seconds for each judge (forcefully terminates if exceeded)'
|
81
81
|
c.flag([:timeout], default_value: 30, type: Integer)
|
82
82
|
c.desc 'Maximum number of update cycles to run'
|
83
83
|
c.flag([:'max-cycles'], default_value: 8, type: Integer)
|
84
|
-
c.desc '
|
84
|
+
c.desc 'Suppress errors even when judges fail'
|
85
85
|
c.switch([:q, :quiet], default_value: false)
|
86
|
-
c.desc '
|
86
|
+
c.desc 'Stop processing immediately after the first error'
|
87
|
+
c.switch([:'fail-fast'], default_value: false)
|
88
|
+
c.desc 'Add a summary fact to the factbase'
|
87
89
|
c.switch([:summary], default_value: false)
|
88
90
|
c.desc 'Use default logging facility'
|
89
91
|
c.switch([:log], default_value: true)
|
92
|
+
c.desc 'Expect at least one judge to be used (fail if none are used)'
|
93
|
+
c.switch([:'expect-judges'], default_value: true)
|
90
94
|
run_it(c, 'update')
|
91
95
|
end
|
92
96
|
|
93
|
-
desc 'Evaluate a single Ruby expression
|
97
|
+
desc 'Evaluate a single Ruby expression against the factbase'
|
94
98
|
command :eval do |c|
|
95
99
|
c.desc 'Use default logging facility'
|
96
100
|
c.switch([:log], default_value: true)
|
@@ -109,40 +113,40 @@ class JudgesGLI extend GLI::App
|
|
109
113
|
run_it(c, 'import')
|
110
114
|
end
|
111
115
|
|
112
|
-
desc 'Remove
|
116
|
+
desc 'Remove outdated facts from the factbase'
|
113
117
|
command :trim do |c|
|
114
|
-
c.desc '
|
118
|
+
c.desc 'Delete only facts matching the specified expression'
|
115
119
|
c.flag([:query], default_value: '(never)')
|
116
120
|
run_it(c, 'trim')
|
117
121
|
end
|
118
122
|
|
119
|
-
desc '
|
123
|
+
desc 'Convert the factbase to a human-readable format (YAML, JSON, etc.)'
|
120
124
|
command :print do |c|
|
121
125
|
c.desc 'Output format (xml, json, or yaml)'
|
122
126
|
c.flag([:format], default_value: 'yaml')
|
123
|
-
c.desc '
|
127
|
+
c.desc 'Automatically generate the output filename'
|
124
128
|
c.switch([:auto], default_value: false)
|
125
|
-
c.desc '
|
129
|
+
c.desc 'Document title to use'
|
126
130
|
c.flag([:title], default_value: 'summary')
|
127
|
-
c.desc '
|
131
|
+
c.desc 'Print only facts matching the specified expression'
|
128
132
|
c.flag([:query], default_value: '(always)')
|
129
|
-
c.desc 'Comma
|
133
|
+
c.desc 'Comma-separated list of columns to display in HTML output (no spaces)'
|
130
134
|
c.flag([:columns], default_value: 'when,what')
|
131
|
-
c.desc 'Comma
|
135
|
+
c.desc 'Comma-separated list of columns to hide from rendering (no spaces)'
|
132
136
|
c.flag([:hidden], default_value: '_id,_time,_version,_job')
|
133
|
-
c.desc '
|
137
|
+
c.desc 'Force printing even if the target file exists and is older than the factbase'
|
134
138
|
c.switch([:force], default_value: false)
|
135
139
|
run_it(c, 'print')
|
136
140
|
end
|
137
141
|
|
138
|
-
desc 'Inspect the factbase and
|
142
|
+
desc 'Inspect the factbase and display all available metadata'
|
139
143
|
command :inspect do |c|
|
140
144
|
run_it(c, 'inspect')
|
141
145
|
end
|
142
146
|
|
143
147
|
desc 'Run automated tests for all judges'
|
144
148
|
command :test do |c|
|
145
|
-
c.desc 'Options to pass to
|
149
|
+
c.desc 'Options to pass to each judge (may be overridden by YAML)'
|
146
150
|
c.flag([:o, :option], multiple: true, arg_name: '<key=value>')
|
147
151
|
c.desc 'Categories of tests to disable'
|
148
152
|
c.flag([:disable], multiple: true)
|
@@ -150,57 +154,57 @@ class JudgesGLI extend GLI::App
|
|
150
154
|
c.flag([:enable], multiple: true)
|
151
155
|
c.desc 'Name of the judge to run (directory name)'
|
152
156
|
c.flag([:judge], multiple: true)
|
153
|
-
c.desc '
|
157
|
+
c.desc 'Number of times to run the tests'
|
154
158
|
c.flag([:runs], type: Integer)
|
155
|
-
c.desc '
|
159
|
+
c.desc 'Location of a Ruby library (directory with .rb files to include)'
|
156
160
|
c.flag([:lib])
|
157
|
-
c.desc '
|
161
|
+
c.desc 'Suppress output even if tests fail or none are executed'
|
158
162
|
c.switch([:quiet], default_value: false)
|
159
163
|
c.desc 'Use default logging facility'
|
160
164
|
c.switch([:log], default_value: true)
|
161
165
|
run_it(c, 'test')
|
162
166
|
end
|
163
167
|
|
164
|
-
desc 'Push the factbase to the server and unlock it
|
168
|
+
desc 'Push the factbase to the server and unlock it remotely'
|
165
169
|
command :push do |c|
|
166
170
|
c.desc 'Authentication token'
|
167
171
|
c.flag([:token])
|
168
|
-
c.desc '
|
172
|
+
c.desc 'Server IP/hostname'
|
169
173
|
c.flag([:host], default_value: 'api.zerocracy.com')
|
170
|
-
c.desc '
|
174
|
+
c.desc 'Server TCP port number'
|
171
175
|
c.flag([:port], default_value: 443, type: Integer)
|
172
|
-
c.desc 'Connection and read
|
176
|
+
c.desc 'Connection and read timeout in seconds'
|
173
177
|
c.flag([:timeout], default_value: 30, type: Integer)
|
174
|
-
c.desc '
|
178
|
+
c.desc 'Enable SSL connection'
|
175
179
|
c.switch([:ssl], default_value: true)
|
176
|
-
c.desc '
|
180
|
+
c.desc 'Unique identifier for lock/unlock operations'
|
177
181
|
c.flag([:owner], default_value: 'default', type: String)
|
178
|
-
c.desc '
|
182
|
+
c.desc 'Additional metadata for the upload (key:value format)'
|
179
183
|
c.flag([:meta], type: String, multiple: true)
|
180
|
-
c.desc '
|
184
|
+
c.desc 'Number of retry attempts'
|
181
185
|
c.flag([:retries], type: Integer, default_value: 3)
|
182
|
-
c.desc '
|
186
|
+
c.desc 'Enable package compression'
|
183
187
|
c.switch([:zip], default_value: true)
|
184
188
|
run_it(c, 'push')
|
185
189
|
end
|
186
190
|
|
187
|
-
desc 'Pull the factbase from the server and lock it
|
191
|
+
desc 'Pull the factbase from the server and lock it remotely'
|
188
192
|
command :pull do |c|
|
189
193
|
c.desc 'Authentication token'
|
190
194
|
c.flag([:token])
|
191
|
-
c.desc '
|
195
|
+
c.desc 'Maximum wait time in seconds'
|
192
196
|
c.flag([:wait], default_value: 10 * 60, arg_name: '<seconds>', type: Integer)
|
193
|
-
c.desc '
|
197
|
+
c.desc 'Server IP/hostname'
|
194
198
|
c.flag([:host], default_value: 'api.zerocracy.com')
|
195
|
-
c.desc '
|
199
|
+
c.desc 'Server TCP port number'
|
196
200
|
c.flag([:port], default_value: 443, type: Integer)
|
197
|
-
c.desc 'Connection and read
|
201
|
+
c.desc 'Connection and read timeout in seconds'
|
198
202
|
c.flag([:timeout], default_value: 30, type: Integer)
|
199
|
-
c.desc '
|
203
|
+
c.desc 'Enable SSL connection'
|
200
204
|
c.switch([:ssl], default_value: true)
|
201
|
-
c.desc '
|
205
|
+
c.desc 'Unique identifier for lock/unlock operations'
|
202
206
|
c.flag([:owner], default_value: 'default', type: String)
|
203
|
-
c.desc '
|
207
|
+
c.desc 'Number of retry attempts'
|
204
208
|
c.flag([:retries], type: Integer, default_value: 3)
|
205
209
|
run_it(c, 'pull')
|
206
210
|
end
|
data/features/import.feature
CHANGED
data/features/update.feature
CHANGED
@@ -15,7 +15,7 @@ Feature: Update
|
|
15
15
|
Then Stdout contains "FOO ā "
|
16
16
|
Then Stdout contains "BAR ā "
|
17
17
|
Then Stdout contains "1 judge(s) processed"
|
18
|
-
Then Stdout contains "Update
|
18
|
+
Then Stdout contains "Update completed in 3 cycle(s), did 3i/0d/3a"
|
19
19
|
And Exit code is zero
|
20
20
|
|
21
21
|
Scenario: Generate a summary fact, with errors
|
@@ -39,7 +39,7 @@ Feature: Update
|
|
39
39
|
"""
|
40
40
|
Then I run bin/judges with "--verbose update --quiet --lifetime 1 --max-cycles 5 . simple.fb"
|
41
41
|
Then Stdout contains "The 'simple' judge skipped, no time left"
|
42
|
-
Then Stdout contains "Update
|
42
|
+
Then Stdout contains "Update completed in 2 cycle(s), did 1i/0d/0a"
|
43
43
|
And Exit code is zero
|
44
44
|
|
45
45
|
Scenario: Use options from a file
|
@@ -57,7 +57,7 @@ Feature: Update
|
|
57
57
|
Then Stdout contains "A1 ā "
|
58
58
|
Then Stdout contains "A2 ā "
|
59
59
|
Then Stdout contains "1 judge(s) processed"
|
60
|
-
Then Stdout contains "Update
|
60
|
+
Then Stdout contains "Update completed"
|
61
61
|
And Exit code is zero
|
62
62
|
|
63
63
|
Scenario: Simple run with a timeout for a judge
|
@@ -71,7 +71,7 @@ Feature: Update
|
|
71
71
|
Then Stdout contains "execution expired"
|
72
72
|
Then Stdout contains "judge timed out after"
|
73
73
|
Then Stdout contains "1 judge(s) processed"
|
74
|
-
Then Stdout contains "Update
|
74
|
+
Then Stdout contains "Update completed in 1 cycle(s), did 0i/0d/0a"
|
75
75
|
And Exit code is zero
|
76
76
|
|
77
77
|
Scenario: Simple run of a few judges, with a lib
|
@@ -87,7 +87,7 @@ Feature: Update
|
|
87
87
|
"""
|
88
88
|
Then I run bin/judges with "update --lib mylib --max-cycles 1 mine simple.fb"
|
89
89
|
Then Stdout contains "1 judge(s) processed"
|
90
|
-
Then Stdout contains "Update
|
90
|
+
Then Stdout contains "Update completed in 1 cycle(s)"
|
91
91
|
And Exit code is zero
|
92
92
|
|
93
93
|
Scenario: The update fails when a bug in a judge
|
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.
|
12
|
+
s.version = '0.44.0'
|
13
13
|
s.license = 'MIT'
|
14
14
|
s.summary = 'Command-Line Tool for a Factbase'
|
15
15
|
s.description =
|
data/lib/judges/commands/eval.rb
CHANGED
@@ -22,7 +22,7 @@ class Judges::Eval
|
|
22
22
|
@loog = loog
|
23
23
|
end
|
24
24
|
|
25
|
-
# Run the eval command.
|
25
|
+
# Run the eval command (called by the +bin/judges+ script).
|
26
26
|
# @param [Hash] opts Command line options (start with '--')
|
27
27
|
# @param [Array] args List of command line arguments
|
28
28
|
# @raise [RuntimeError] If not exactly two arguments provided
|
@@ -40,7 +40,7 @@ class Judges::Eval
|
|
40
40
|
eval(expr)
|
41
41
|
# rubocop:enable Security/Eval
|
42
42
|
impex.export($fb)
|
43
|
-
throw :'Evaluated successfully'
|
43
|
+
throw :'š Evaluated successfully'
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
@@ -24,7 +24,7 @@ class Judges::Import
|
|
24
24
|
@loog = loog
|
25
25
|
end
|
26
26
|
|
27
|
-
# Run the import command.
|
27
|
+
# Run the import command (called by the +bin/judges+ script).
|
28
28
|
# @param [Hash] opts Command line options (start with '--')
|
29
29
|
# @param [Array] args List of command line arguments
|
30
30
|
# @raise [RuntimeError] If not exactly two arguments provided or file not found
|
@@ -47,7 +47,7 @@ class Judges::Import
|
|
47
47
|
end
|
48
48
|
end
|
49
49
|
impex.export(fb)
|
50
|
-
throw :"Import of #{yaml.size} facts
|
50
|
+
throw :"š Import of #{yaml.size} facts completed"
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
@@ -21,12 +21,12 @@ class Judges::Inspect
|
|
21
21
|
@loog = loog
|
22
22
|
end
|
23
23
|
|
24
|
-
# Run the inspect command.
|
24
|
+
# Run the inspect command (called by the +bin/judges+ script).
|
25
25
|
# @param [Hash] _opts Command line options (not used)
|
26
26
|
# @param [Array] args List of command line arguments
|
27
27
|
# @raise [RuntimeError] If no arguments provided
|
28
28
|
def run(_opts, args)
|
29
|
-
raise 'At
|
29
|
+
raise 'At least one argument required' if args.empty?
|
30
30
|
fb = Judges::Impex.new(@loog, args[0]).import
|
31
31
|
@loog.info("Facts: #{fb.size}")
|
32
32
|
end
|
data/lib/judges/commands/join.rb
CHANGED
@@ -22,7 +22,7 @@ class Judges::Join
|
|
22
22
|
@loog = loog
|
23
23
|
end
|
24
24
|
|
25
|
-
# Run the join command.
|
25
|
+
# Run the join command (called by the +bin/judges+ script).
|
26
26
|
# @param [Hash] _opts Command line options (not used)
|
27
27
|
# @param [Array] args List of command line arguments
|
28
28
|
# @raise [RuntimeError] If not exactly two arguments provided
|
@@ -34,7 +34,7 @@ class Judges::Join
|
|
34
34
|
fb = master.import
|
35
35
|
slave.import_to(fb)
|
36
36
|
master.export(fb)
|
37
|
-
throw :'Two factbases joined'
|
37
|
+
throw :'š Two factbases joined successfully'
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
@@ -29,11 +29,12 @@ class Judges::Print
|
|
29
29
|
@loog = loog
|
30
30
|
end
|
31
31
|
|
32
|
-
# Run
|
32
|
+
# Run the print command (called by the +bin/judges+ script).
|
33
33
|
# @param [Hash] opts Command line options (start with '--')
|
34
34
|
# @param [Array] args List of command line arguments
|
35
|
+
# @raise [RuntimeError] If no arguments provided
|
35
36
|
def run(opts, args)
|
36
|
-
raise 'At
|
37
|
+
raise 'At least one argument required' if args.empty?
|
37
38
|
f = args[0]
|
38
39
|
fb = Judges::Impex.new(@loog, f).import
|
39
40
|
fb.query("(not #{opts['query']})").delete! unless opts['query'].nil?
|
@@ -70,7 +71,7 @@ class Judges::Print
|
|
70
71
|
raise "Unknown format '#{fmt}'"
|
71
72
|
end
|
72
73
|
File.binwrite(o, output)
|
73
|
-
throw :"Factbase printed to #{o.to_rel} (#{File.size(o)} bytes)"
|
74
|
+
throw :"š Factbase printed to #{o.to_rel} (#{File.size(o)} bytes)"
|
74
75
|
end
|
75
76
|
end
|
76
77
|
|
data/lib/judges/commands/pull.rb
CHANGED
@@ -25,9 +25,10 @@ class Judges::Pull
|
|
25
25
|
@loog = loog
|
26
26
|
end
|
27
27
|
|
28
|
-
# Run
|
28
|
+
# Run the pull command (called by the +bin/judges+ script).
|
29
29
|
# @param [Hash] opts Command line options (start with '--')
|
30
30
|
# @param [Array] args List of command line arguments
|
31
|
+
# @raise [RuntimeError] If not exactly two arguments provided
|
31
32
|
def run(opts, args)
|
32
33
|
raise 'Exactly two arguments required' unless args.size == 2
|
33
34
|
fb = Factbase.new
|
@@ -54,9 +55,9 @@ class Judges::Pull
|
|
54
55
|
baza.unlock(name, opts['owner'])
|
55
56
|
raise e
|
56
57
|
end
|
57
|
-
throw :"Pulled #{fb.size} facts by
|
58
|
+
throw :"š Pulled #{fb.size} facts by name '#{name}'"
|
58
59
|
else
|
59
|
-
throw :"
|
60
|
+
throw :"ā ļø Nothing to pull - name '#{name}' not found on server"
|
60
61
|
end
|
61
62
|
end
|
62
63
|
end
|
@@ -69,7 +70,7 @@ class Judges::Pull
|
|
69
70
|
loop do
|
70
71
|
break if baza.finished?(id)
|
71
72
|
sleep 1
|
72
|
-
raise "Time is over, the job ##{id} ('#{name}') is still not
|
73
|
+
raise "Time is over, the job ##{id} ('#{name}') is still not completed" if Time.now - start > limit
|
73
74
|
lapsed = Time.now - start
|
74
75
|
@loog.debug("Still waiting for the job ##{id} ('#{name}') to finish... (#{format('%.2f', lapsed)}s already)")
|
75
76
|
end
|
data/lib/judges/commands/push.rb
CHANGED
@@ -25,9 +25,10 @@ class Judges::Push
|
|
25
25
|
@loog = loog
|
26
26
|
end
|
27
27
|
|
28
|
-
# Run
|
28
|
+
# Run the push command (called by the +bin/judges+ script).
|
29
29
|
# @param [Hash] opts Command line options (start with '--')
|
30
30
|
# @param [Array] args List of command line arguments
|
31
|
+
# @raise [RuntimeError] If not exactly two arguments provided
|
31
32
|
def run(opts, args)
|
32
33
|
raise 'Exactly two arguments required' unless args.size == 2
|
33
34
|
name = args[0]
|
@@ -44,7 +45,7 @@ class Judges::Push
|
|
44
45
|
baza.lock(name, opts['owner'])
|
45
46
|
begin
|
46
47
|
id = baza.push(name, fb.export, opts['meta'] || [])
|
47
|
-
throw :"Pushed #{fb.size} facts, job ID is #{id}"
|
48
|
+
throw :"š Pushed #{fb.size} facts, job ID is #{id}"
|
48
49
|
ensure
|
49
50
|
baza.unlock(name, opts['owner'])
|
50
51
|
end
|
data/lib/judges/commands/test.rb
CHANGED
@@ -29,9 +29,10 @@ class Judges::Test
|
|
29
29
|
@loog = loog
|
30
30
|
end
|
31
31
|
|
32
|
-
# Run
|
32
|
+
# Run the test command (called by the +bin/judges+ script).
|
33
33
|
# @param [Hash] opts Command line options (start with '--')
|
34
34
|
# @param [Array] args List of command line arguments
|
35
|
+
# @raise [RuntimeError] If not exactly one argument provided
|
35
36
|
def run(opts, args)
|
36
37
|
raise 'Exactly one argument required' unless args.size == 1
|
37
38
|
dir = args[0]
|
data/lib/judges/commands/trim.rb
CHANGED
@@ -23,18 +23,19 @@ class Judges::Trim
|
|
23
23
|
@loog = loog
|
24
24
|
end
|
25
25
|
|
26
|
-
# Run
|
26
|
+
# Run the trim command (called by the +bin/judges+ script).
|
27
27
|
# @param [Hash] opts Command line options (start with '--')
|
28
28
|
# @param [Array] args List of command line arguments
|
29
|
+
# @raise [RuntimeError] If not exactly one argument provided
|
29
30
|
def run(opts, args)
|
30
31
|
raise 'Exactly one argument required' unless args.size == 1
|
31
32
|
impex = Judges::Impex.new(@loog, args[0])
|
32
33
|
fb = impex.import
|
33
34
|
elapsed(@loog, level: Logger::INFO) do
|
34
35
|
deleted = fb.query(opts['query']).delete!
|
35
|
-
throw :'No facts deleted' if deleted.zero?
|
36
|
+
throw :'ā ļø No facts deleted' if deleted.zero?
|
36
37
|
impex.export(fb)
|
37
|
-
throw :"
|
38
|
+
throw :"š #{deleted} fact(s) deleted"
|
38
39
|
end
|
39
40
|
end
|
40
41
|
end
|
@@ -33,10 +33,10 @@ class Judges::Update
|
|
33
33
|
@start = Time.now
|
34
34
|
end
|
35
35
|
|
36
|
-
# Run
|
37
|
-
#
|
36
|
+
# Run the update command (called by the +bin/judges+ script).
|
38
37
|
# @param [Hash] opts Command line options (start with '--')
|
39
38
|
# @param [Array] args List of command line arguments
|
39
|
+
# @raise [RuntimeError] If not exactly two arguments provided or directory is missing
|
40
40
|
def run(opts, args)
|
41
41
|
raise 'Exactly two arguments required' unless args.size == 2
|
42
42
|
dir = args[0]
|
@@ -81,9 +81,13 @@ class Judges::Update
|
|
81
81
|
@loog.info("Too many cycles already, as set by --max-cycles=#{opts['max-cycles']}, breaking")
|
82
82
|
break
|
83
83
|
end
|
84
|
+
if opts['fail-fast'] && !errors.empty?
|
85
|
+
@loog.info("Due to #{errors.count} errors we must stop at the update cycle ##{c}")
|
86
|
+
break
|
87
|
+
end
|
84
88
|
@loog.info("The cycle #{c} did #{delta}")
|
85
89
|
end
|
86
|
-
throw :"Update
|
90
|
+
throw :"š Update completed in #{c} cycle(s), did #{churn}"
|
87
91
|
end
|
88
92
|
return unless opts['summary']
|
89
93
|
summarize(fb, churn, errors, start, c)
|
@@ -141,11 +145,17 @@ class Judges::Update
|
|
141
145
|
def cycle(opts, judges, fb, options, start, errors)
|
142
146
|
churn = Factbase::Churn.new
|
143
147
|
global = {}
|
148
|
+
used = 0
|
144
149
|
elapsed(@loog, level: Logger::INFO) do
|
145
150
|
done =
|
146
151
|
judges.each_with_index do |judge, i|
|
152
|
+
if opts['fail-fast'] && !errors.empty?
|
153
|
+
@loog.info("Not running #{judge.name.inspect} due to #{errors.count} errors above, in --fail-fast mode")
|
154
|
+
next
|
155
|
+
end
|
147
156
|
next unless include?(opts, judge.name)
|
148
157
|
@loog.info("\nš Running #{judge.name} (##{i}) at #{judge.dir.to_rel} (#{start.ago} already)...")
|
158
|
+
used += 1
|
149
159
|
elapsed(@loog, level: Logger::INFO) do
|
150
160
|
c = one_judge(opts, fb, judge, global, options, errors)
|
151
161
|
churn += c
|
@@ -158,6 +168,10 @@ class Judges::Update
|
|
158
168
|
throw :"š #{done} judge(s) processed" if errors.empty?
|
159
169
|
throw :"ā #{done} judge(s) processed with #{errors.size} errors"
|
160
170
|
end
|
171
|
+
if used.zero?
|
172
|
+
raise 'No judges were used, while at least one expected to run' if opts['expect-judges']
|
173
|
+
@loog.info('No judges were used (looks like an error); not failing because of --no-expect-judges')
|
174
|
+
end
|
161
175
|
unless errors.empty?
|
162
176
|
raise "Failed to update correctly (#{errors.size} errors)" unless opts['quiet']
|
163
177
|
@loog.info('Not failing because of the --quiet flag provided')
|
data/lib/judges/judge.rb
CHANGED
@@ -59,7 +59,7 @@ class Judges::Judge
|
|
59
59
|
end
|
60
60
|
s = File.join(@dir, script)
|
61
61
|
raise "Can't load '#{s}'" unless File.exist?(s)
|
62
|
-
elapsed(@loog, intro: "#{$judge}
|
62
|
+
elapsed(@loog, intro: "#{$judge} completed", level: Logger::INFO) do
|
63
63
|
load(s, true)
|
64
64
|
$fb.churn
|
65
65
|
# rubocop:disable Lint/RescueException
|
data/lib/judges.rb
CHANGED