fbe 0.40.0 → 0.41.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/reuse.yml +1 -1
- data/lib/fbe/conclude.rb +12 -21
- data/lib/fbe/iterate.rb +26 -30
- data/lib/fbe/over.rb +38 -0
- data/lib/fbe.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e140ff5523bde9171719f3481941dfdf36b381696f313c98b7bb570b172ec49
|
4
|
+
data.tar.gz: a0fa3c06b03e0d0de48ab5e00e9d7985e933b68d174f0625b6a5b9388d2d980a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1fdf1f6e32990d2f34dd33337b4b6f73f0e423092c09834bce6d216746d5c387eb61befa3786c907a84c37e75dd00a0058ff8816b4b7ddc9de09ed166564e55
|
7
|
+
data.tar.gz: 5b7a3331b84db4c7b2b36b700e132987be7dd235b86b97ee7f3d4032a43b30d0bdf0d7a907700726bf7ca8fafcd13fb35e03c895f35b0e32964e57064c2d1a57
|
data/.github/workflows/reuse.yml
CHANGED
data/lib/fbe/conclude.rb
CHANGED
@@ -8,6 +8,7 @@ require_relative '../fbe'
|
|
8
8
|
require_relative 'fb'
|
9
9
|
require_relative 'if_absent'
|
10
10
|
require_relative 'octo'
|
11
|
+
require_relative 'over'
|
11
12
|
|
12
13
|
# Creates an instance of {Fbe::Conclude} and evals it with the block provided.
|
13
14
|
#
|
@@ -195,29 +196,16 @@ class Fbe::Conclude
|
|
195
196
|
# end
|
196
197
|
# end
|
197
198
|
def roll(&)
|
198
|
-
|
199
|
-
@
|
200
|
-
|
201
|
-
|
202
|
-
if @timeout_aware && @options.timeout && Time.now - @kickoff > @options.timeout * 0.9
|
203
|
-
@loog.debug("We've spent more than #{@kickoff.ago}, won't even start")
|
204
|
-
return
|
205
|
-
end
|
199
|
+
return 0 if Fbe.over?(
|
200
|
+
global: @global, options: @options, loog: @loog, epoch: @epoch, kickoff: @kickoff,
|
201
|
+
quota_aware: @quota_aware, lifetime_aware: @lifetime_aware, timeout_aware: @timeout_aware
|
202
|
+
)
|
206
203
|
passed = 0
|
207
|
-
oct = Fbe.octo(loog: @loog, options: @options, global: @global)
|
208
204
|
@fb.query(@query).each do |a|
|
209
|
-
if
|
210
|
-
@
|
211
|
-
|
212
|
-
|
213
|
-
if @lifetime_aware && @options.lifetime && Time.now - @epoch > @options.lifetime * 0.9
|
214
|
-
@loog.debug("We ran out of lifetime (#{@epoch.ago} already), must stop here")
|
215
|
-
break
|
216
|
-
end
|
217
|
-
if @timeout_aware && @options.timeout && Time.now - @kickoff > @options.timeout * 0.9
|
218
|
-
@loog.debug("We've spent more than #{@kickoff.ago}, must stop here")
|
219
|
-
break
|
220
|
-
end
|
205
|
+
break if Fbe.over?(
|
206
|
+
global: @global, options: @options, loog: @loog, epoch: @epoch, kickoff: @kickoff,
|
207
|
+
quota_aware: @quota_aware, lifetime_aware: @lifetime_aware, timeout_aware: @timeout_aware
|
208
|
+
)
|
221
209
|
@fb.txn do |fbt|
|
222
210
|
n = yield fbt, a
|
223
211
|
@loog.info("#{n.what}: #{n.details}") unless n.nil?
|
@@ -226,6 +214,9 @@ class Fbe::Conclude
|
|
226
214
|
end
|
227
215
|
@loog.debug("Found and processed #{passed} facts by: #{@query}")
|
228
216
|
passed
|
217
|
+
rescue Fbe::OffQuota => e
|
218
|
+
@loog.info(e.message)
|
219
|
+
passed
|
229
220
|
end
|
230
221
|
|
231
222
|
# Populates a new fact based on a previous fact and a processing block.
|
data/lib/fbe/iterate.rb
CHANGED
@@ -10,6 +10,7 @@ require_relative '../fbe'
|
|
10
10
|
require_relative 'fb'
|
11
11
|
require_relative 'if_absent'
|
12
12
|
require_relative 'octo'
|
13
|
+
require_relative 'over'
|
13
14
|
require_relative 'overwrite'
|
14
15
|
require_relative 'unmask_repos'
|
15
16
|
|
@@ -267,29 +268,19 @@ class Fbe::Iterate
|
|
267
268
|
starts = before.dup
|
268
269
|
values = {}
|
269
270
|
loop do
|
270
|
-
if
|
271
|
-
@
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
@loog.debug("We ran out of lifetime (#{@epoch.ago} already), must stop here")
|
276
|
-
break
|
277
|
-
end
|
278
|
-
if @timeout_aware && @options.timeout && Time.now - @kickoff > @options.timeout * 0.9
|
279
|
-
@loog.debug("We've spent more than #{@kickoff.ago}, must stop here")
|
271
|
+
if Fbe.over?(
|
272
|
+
global: @global, options: @options, loog: @loog, epoch: @epoch, kickoff: @kickoff,
|
273
|
+
quota_aware: @quota_aware, lifetime_aware: @lifetime_aware, timeout_aware: @timeout_aware
|
274
|
+
)
|
275
|
+
@loog.info("Time to stop after #{started.ago}")
|
280
276
|
break
|
281
277
|
end
|
282
278
|
repos.each do |repo|
|
283
|
-
if
|
284
|
-
@
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
@loog.info("We are working for #{@epoch.ago} already, won't check repository ##{repo}")
|
289
|
-
next
|
290
|
-
end
|
291
|
-
if @timeout_aware && @options.timeout && Time.now - @kickoff > @options.timeout * 0.9
|
292
|
-
@loog.debug("We've spent more than #{@kickoff.ago}, won't check repository ##{repo}")
|
279
|
+
if Fbe.over?(
|
280
|
+
global: @global, options: @options, loog: @loog, epoch: @epoch, kickoff: @kickoff,
|
281
|
+
quota_aware: @quota_aware, lifetime_aware: @lifetime_aware, timeout_aware: @timeout_aware
|
282
|
+
)
|
283
|
+
@loog.info("Won't check repository ##{repo}")
|
293
284
|
break
|
294
285
|
end
|
295
286
|
next if restarted.include?(repo)
|
@@ -335,16 +326,21 @@ class Fbe::Iterate
|
|
335
326
|
break
|
336
327
|
end
|
337
328
|
end
|
338
|
-
repos.each do |repo|
|
339
|
-
next if before[repo] == starts[repo]
|
340
|
-
f =
|
341
|
-
Fbe.if_absent(fb: @fb, always: true) do |n|
|
342
|
-
n.what = 'iterate'
|
343
|
-
n.where = 'github'
|
344
|
-
n.repository = repo
|
345
|
-
end
|
346
|
-
Fbe.overwrite(f, @label, before[repo], fb: @fb)
|
347
|
-
end
|
348
329
|
@loog.debug("Finished scanning #{repos.size} repos in #{@kickoff.ago}: #{seen.map { |k, v| "#{k}:#{v}" }.joined}")
|
330
|
+
rescue Fbe::OffQuota => e
|
331
|
+
@loog.info(e.message)
|
332
|
+
ensure
|
333
|
+
if defined?(repos) && defined?(before) && defined?(starts)
|
334
|
+
repos.each do |repo|
|
335
|
+
next if before[repo] == starts[repo]
|
336
|
+
f =
|
337
|
+
Fbe.if_absent(fb: @fb, always: true) do |n|
|
338
|
+
n.what = 'iterate'
|
339
|
+
n.where = 'github'
|
340
|
+
n.repository = repo
|
341
|
+
end
|
342
|
+
Fbe.overwrite(f, @label, before[repo], fb: @fb)
|
343
|
+
end
|
344
|
+
end
|
349
345
|
end
|
350
346
|
end
|
data/lib/fbe/over.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2024-2025 Zerocracy
|
4
|
+
# SPDX-License-Identifier: MIT
|
5
|
+
|
6
|
+
require_relative '../fbe'
|
7
|
+
require_relative 'octo'
|
8
|
+
|
9
|
+
# Check GitHub API quota, lifetime, and timeout.
|
10
|
+
#
|
11
|
+
# @param [Hash] global Hash of global options
|
12
|
+
# @param [Judges::Options] options The options available globally
|
13
|
+
# @param [Loog] loog Logging facility
|
14
|
+
# @param [Time] epoch When the entire update started
|
15
|
+
# @param [Time] kickoff When the particular judge started
|
16
|
+
# @param [Boolean] quota_aware Enable or disable check of GitHub API quota
|
17
|
+
# @param [Boolean] lifetime_aware Enable or disable check of lifetime limitations
|
18
|
+
# @param [Boolean] timeout_aware Enable or disable check of timeout limitations
|
19
|
+
# @return [Boolean] check result
|
20
|
+
def Fbe.over?(
|
21
|
+
global: $global, options: $options, loog: $loog,
|
22
|
+
epoch: $epoch || Time.now, kickoff: $kickoff || Time.now,
|
23
|
+
quota_aware: true, lifetime_aware: true, timeout_aware: true
|
24
|
+
)
|
25
|
+
if quota_aware && Fbe.octo(loog:, options:, global:).off_quota?(threshold: 100)
|
26
|
+
loog.info('We are off GitHub quota, time to stop')
|
27
|
+
return true
|
28
|
+
end
|
29
|
+
if lifetime_aware && options.lifetime && Time.now - epoch > options.lifetime * 0.9
|
30
|
+
loog.info("We ran out of lifetime (#{epoch.ago} already), must stop here")
|
31
|
+
return true
|
32
|
+
end
|
33
|
+
if timeout_aware && options.timeout && Time.now - kickoff > options.timeout * 0.9
|
34
|
+
loog.info("We've spent more than #{kickoff.ago}, must stop here")
|
35
|
+
return true
|
36
|
+
end
|
37
|
+
false
|
38
|
+
end
|
data/lib/fbe.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fbe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.41.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
@@ -384,6 +384,7 @@ files:
|
|
384
384
|
- lib/fbe/middleware/sqlite_store.rb
|
385
385
|
- lib/fbe/middleware/trace.rb
|
386
386
|
- lib/fbe/octo.rb
|
387
|
+
- lib/fbe/over.rb
|
387
388
|
- lib/fbe/overwrite.rb
|
388
389
|
- lib/fbe/pmp.rb
|
389
390
|
- lib/fbe/regularly.rb
|