fbe 0.0.11 → 0.0.13
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/Gemfile.lock +1 -1
- data/README.md +2 -1
- data/fbe.gemspec +1 -0
- data/lib/fbe/conclude.rb +3 -2
- data/lib/fbe/fb.rb +1 -0
- data/lib/fbe/iterate.rb +16 -11
- data/lib/fbe/unmask_repos.rb +1 -0
- data/lib/fbe.rb +1 -1
- data/test/fbe/test_conclude.rb +12 -16
- data/test/fbe/test_iterate.rb +41 -7
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ddb68efaa2108636f7d036c7ce41054cb2df54b5dbb080c44fca22dc7afb0b56
|
|
4
|
+
data.tar.gz: 6f6e8fd827d6d9728a9149ccab9e2c70bc5cbefba0ec96845f5d1bf5f6dc7381
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 917d79f1b09563a98a7ef0dbfa86155de181c79dec11768854eef48b0f03d8ae7e23432ab01b69266ea498abf987d5723f3e0d54d694be2ce21e2686af9e47c9
|
|
7
|
+
data.tar.gz: ebe3be674f88f238e9d7d6506c2a0c03f27589ced7ee7eb899d1a869bca1964c752a7544299e0aebf6d080052b3bcf6b31bcd8c2224212b00bd3c202a8acf5ca
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
[](https://hitsofcode.com/view/github/zerocracy/fbe)
|
|
12
12
|
[](https://github.com/zerocracy/fbe/blob/master/LICENSE.txt)
|
|
13
13
|
|
|
14
|
-
It's a collection of tools
|
|
14
|
+
It's a collection of tools for
|
|
15
|
+
[zerocracy/judges-action](https://github.com/zerocracy/judges-action).
|
|
15
16
|
|
|
16
17
|
## How to contribute
|
|
17
18
|
|
data/fbe.gemspec
CHANGED
data/lib/fbe/conclude.rb
CHANGED
|
@@ -38,7 +38,7 @@ end
|
|
|
38
38
|
# Copyright:: Copyright (c) 2024 Zerocracy
|
|
39
39
|
# License:: MIT
|
|
40
40
|
class Fbe::Conclude
|
|
41
|
-
def initialize(fb
|
|
41
|
+
def initialize(fb:, judge:, loog:, options:, global:)
|
|
42
42
|
@fb = fb
|
|
43
43
|
@judge = judge
|
|
44
44
|
@loog = loog
|
|
@@ -88,8 +88,8 @@ class Fbe::Conclude
|
|
|
88
88
|
private
|
|
89
89
|
|
|
90
90
|
def roll(&)
|
|
91
|
+
passed = 0
|
|
91
92
|
catch :stop do
|
|
92
|
-
passed = 0
|
|
93
93
|
@fb.txn do |fbt|
|
|
94
94
|
fbt.query(@query).each do |a|
|
|
95
95
|
throw :stop if @quota_aware && Fbe.octo(loog: @loog, options: @options, global: @global).off_quota
|
|
@@ -99,6 +99,7 @@ class Fbe::Conclude
|
|
|
99
99
|
end
|
|
100
100
|
end
|
|
101
101
|
end
|
|
102
|
+
@loog.debug("Found and processed #{passed} facts by: #{@query}")
|
|
102
103
|
end
|
|
103
104
|
|
|
104
105
|
def fill(fact, prev)
|
data/lib/fbe/fb.rb
CHANGED
data/lib/fbe/iterate.rb
CHANGED
|
@@ -38,7 +38,7 @@ end
|
|
|
38
38
|
# Copyright:: Copyright (c) 2024 Zerocracy
|
|
39
39
|
# License:: MIT
|
|
40
40
|
class Fbe::Iterate
|
|
41
|
-
def initialize(fb
|
|
41
|
+
def initialize(fb:, loog:, options:, global:)
|
|
42
42
|
@fb = fb
|
|
43
43
|
@loog = loog
|
|
44
44
|
@options = options
|
|
@@ -84,24 +84,25 @@ class Fbe::Iterate
|
|
|
84
84
|
oct = Fbe.octo(loog: @loog, options: @options, global: @global)
|
|
85
85
|
repos = Fbe.unmask_repos(loog: @loog, options: @options, global: @global)
|
|
86
86
|
restarted = []
|
|
87
|
+
fb = Fbe.fb(fb: @fb, global: @global, options: @options)
|
|
87
88
|
loop do
|
|
88
89
|
repos.each do |repo|
|
|
89
90
|
next if restarted.include?(repo)
|
|
90
91
|
seen[repo] = 0 if seen[repo].nil?
|
|
91
92
|
if seen[repo] >= @repeats
|
|
92
|
-
@loog.debug("We've seen too many in
|
|
93
|
+
@loog.debug("We've seen too many (#{seen[repo]}) in #{repo}, let's see next one")
|
|
93
94
|
next
|
|
94
95
|
end
|
|
95
96
|
rid = oct.repo_id_by_name(repo)
|
|
96
|
-
before =
|
|
97
|
+
before = fb.query(
|
|
97
98
|
"(agg (and (eq what '#{@label}') (eq where 'github') (eq repository #{rid})) (first latest))"
|
|
98
99
|
).one
|
|
99
|
-
|
|
100
|
+
fb.query("(and (eq what '#{@label}') (eq where 'github') (eq repository #{rid}))").delete!
|
|
100
101
|
before = before.nil? ? @since : before.first
|
|
101
|
-
nxt =
|
|
102
|
+
nxt = fb.query(@query).one(before:, repository: rid)
|
|
102
103
|
after =
|
|
103
104
|
if nxt.nil?
|
|
104
|
-
@loog.debug("Next
|
|
105
|
+
@loog.debug("Next element after ##{before} not suggested, re-starting from ##{@since}: #{@query}")
|
|
105
106
|
restarted << repo
|
|
106
107
|
@since
|
|
107
108
|
else
|
|
@@ -109,15 +110,15 @@ class Fbe::Iterate
|
|
|
109
110
|
yield(rid, nxt)
|
|
110
111
|
end
|
|
111
112
|
raise "Iterator must return an Integer, while #{after.class} returned" unless after.is_a?(Integer)
|
|
112
|
-
f =
|
|
113
|
+
f = fb.insert
|
|
113
114
|
f.where = 'github'
|
|
114
115
|
f.repository = rid
|
|
115
116
|
f.latest =
|
|
116
117
|
if after.nil?
|
|
117
|
-
@loog.debug("After is nil at #{repo}, setting the
|
|
118
|
+
@loog.debug("After is nil at #{repo}, setting the 'latest' to ##{nxt}")
|
|
118
119
|
nxt
|
|
119
120
|
else
|
|
120
|
-
@loog.debug("After is ##{after} at #{repo}, setting the
|
|
121
|
+
@loog.debug("After is ##{after} at #{repo}, setting the 'latest' to it")
|
|
121
122
|
after
|
|
122
123
|
end
|
|
123
124
|
f.what = @label
|
|
@@ -131,8 +132,12 @@ class Fbe::Iterate
|
|
|
131
132
|
@loog.debug('We are off GitHub quota, time to stop')
|
|
132
133
|
break
|
|
133
134
|
end
|
|
134
|
-
unless seen.
|
|
135
|
-
@loog.debug(
|
|
135
|
+
unless seen.any? { |r, v| v < @repeats && !restarted.include?(r) }
|
|
136
|
+
@loog.debug("No more repos to scan (out of #{repos.size}), quitting")
|
|
137
|
+
break
|
|
138
|
+
end
|
|
139
|
+
if restarted.size == repos.size
|
|
140
|
+
@loog.debug("All #{repos.size} repos restarted, quitting")
|
|
136
141
|
break
|
|
137
142
|
end
|
|
138
143
|
end
|
data/lib/fbe/unmask_repos.rb
CHANGED
data/lib/fbe.rb
CHANGED
data/test/fbe/test_conclude.rb
CHANGED
|
@@ -50,7 +50,7 @@ class TestConclude < Minitest::Test
|
|
|
50
50
|
fb = Factbase.new
|
|
51
51
|
fb.insert.foo = 1
|
|
52
52
|
fb.insert.bar = 2
|
|
53
|
-
Fbe.conclude(fb:, judge: 'judge-one', loog: Loog::NULL) do
|
|
53
|
+
Fbe.conclude(fb:, judge: 'judge-one', loog: Loog::NULL, global: {}, options: Judges::Options.new) do
|
|
54
54
|
on '(exists foo)'
|
|
55
55
|
draw do |n, prev|
|
|
56
56
|
n.sum = prev.foo + 1
|
|
@@ -64,12 +64,10 @@ class TestConclude < Minitest::Test
|
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
def test_maybe
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
Fbe.fb.insert.foo = 1
|
|
72
|
-
Fbe.conclude(judge: 'issue-was-opened', loog: Loog::NULL) do
|
|
67
|
+
options = Judges::Options.new
|
|
68
|
+
fb = Fbe.fb(global: {}, options:)
|
|
69
|
+
fb.insert.foo = 1
|
|
70
|
+
Fbe.conclude(fb:, judge: 'issue-was-opened', loog: Loog::NULL, options:, global: {}) do
|
|
73
71
|
on '(exists foo)'
|
|
74
72
|
maybe do |n, prev|
|
|
75
73
|
n.repository = 111
|
|
@@ -80,24 +78,22 @@ class TestConclude < Minitest::Test
|
|
|
80
78
|
"it's a test." * 20
|
|
81
79
|
end
|
|
82
80
|
end
|
|
83
|
-
f =
|
|
81
|
+
f = fb.query('(exists issue)').each.to_a[0]
|
|
84
82
|
assert_equal(1, f.issue)
|
|
85
83
|
assert(f._id.positive?)
|
|
86
84
|
end
|
|
87
85
|
|
|
88
86
|
def test_consider
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
Fbe.fb.insert.foo = 1
|
|
94
|
-
Fbe.conclude(judge: 'issue-was-closed', loog: Loog::NULL) do
|
|
87
|
+
fb = Factbase.new
|
|
88
|
+
fb.insert.foo = 1
|
|
89
|
+
options = Judges::Options.new
|
|
90
|
+
Fbe.conclude(fb:, judge: 'issue-was-closed', loog: Loog::NULL, options:, global: {}) do
|
|
95
91
|
on '(exists foo)'
|
|
96
92
|
consider do |_prev|
|
|
97
|
-
|
|
93
|
+
fb.insert.bar = 42
|
|
98
94
|
end
|
|
99
95
|
end
|
|
100
|
-
f =
|
|
96
|
+
f = fb.query('(exists bar)').each.to_a[0]
|
|
101
97
|
assert_equal(42, f.bar)
|
|
102
98
|
end
|
|
103
99
|
end
|
data/test/fbe/test_iterate.rb
CHANGED
|
@@ -34,20 +34,54 @@ require_relative '../../lib/fbe/iterate'
|
|
|
34
34
|
# License:: MIT
|
|
35
35
|
class TestIterate < Minitest::Test
|
|
36
36
|
def test_simple
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
Fbe.iterate(loog: Loog::NULL) do
|
|
37
|
+
opts = Judges::Options.new(['repositories=foo/bar', 'testing=true'])
|
|
38
|
+
fb = Factbase.new
|
|
39
|
+
fb.insert.foo = 42
|
|
40
|
+
Fbe.iterate(fb:, loog: Loog::NULL, options: opts, global: {}) do
|
|
42
41
|
as 'labels-were-scanned'
|
|
43
42
|
by '(agg (always) (max foo))'
|
|
44
43
|
repeats 2
|
|
45
44
|
over do |_repository, foo|
|
|
46
|
-
f =
|
|
45
|
+
f = fb.insert
|
|
47
46
|
f.foo = foo + 1
|
|
48
47
|
f.foo
|
|
49
48
|
end
|
|
50
49
|
end
|
|
51
|
-
assert_equal(4,
|
|
50
|
+
assert_equal(4, fb.size)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def test_many_repeats
|
|
54
|
+
opts = Judges::Options.new(['repositories=foo/bar,foo/second', 'testing=true'])
|
|
55
|
+
cycles = 0
|
|
56
|
+
reps = 5
|
|
57
|
+
Fbe.iterate(fb: Factbase.new, loog: Loog::NULL, global: {}, options: opts) do
|
|
58
|
+
as 'labels-were-scanned'
|
|
59
|
+
by '(plus 1 1)'
|
|
60
|
+
repeats reps
|
|
61
|
+
over do |_, nxt|
|
|
62
|
+
cycles += 1
|
|
63
|
+
nxt
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
assert_equal(reps * 2, cycles)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def test_with_restart
|
|
70
|
+
opts = Judges::Options.new(['repositories=foo/bar', 'testing=true'])
|
|
71
|
+
cycles = 0
|
|
72
|
+
fb = Factbase.new
|
|
73
|
+
f = fb.insert
|
|
74
|
+
f.foo = 42
|
|
75
|
+
Fbe.iterate(fb:, loog: Loog::NULL, global: {}, options: opts) do
|
|
76
|
+
as 'labels-were-scanned'
|
|
77
|
+
by '(agg (and (eq foo 42) (not (exists bar))) (max foo))'
|
|
78
|
+
repeats 10
|
|
79
|
+
over do |_, nxt|
|
|
80
|
+
cycles += 1
|
|
81
|
+
f.bar = 1
|
|
82
|
+
nxt
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
assert_equal(1, cycles)
|
|
52
86
|
end
|
|
53
87
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fbe
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.13
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Yegor Bugayenko
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2024-07-
|
|
11
|
+
date: 2024-07-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: backtrace
|