fbe 0.0.11 → 0.0.12
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 +2 -1
- data/lib/fbe/fb.rb +1 -0
- data/lib/fbe/iterate.rb +16 -8
- 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 +40 -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: 82aa4fc845f2c9cae3e6eab0134f2a3c222f69d5a9a758f9d7781ba55f4fd454
|
4
|
+
data.tar.gz: cfb626ee801720ea0085645eb10a8b46b57e9a9e863177071e649631559a7f9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a62d4ad1d1af3230b90b18af6dec389f0fee81e3a2850a59794c0981f0ba31428c2ff7474450085d4060a4f584d86ebc9f0301f92442d9179429f008eeb18d2
|
7
|
+
data.tar.gz: d443ad05ef6b5d75f920d597c232b50a8bce3fdb05eefd154a0d2dd2e636af9bc37d35ece6dc0a5165a2872965f7643f02424c336c6f112b6c63f89ab73219c1
|
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
@@ -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
@@ -84,24 +84,28 @@ 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
|
+
if restarted.include?(repo)
|
91
|
+
@loog.debug("Already restared #{repo}, won't iterate it anymore")
|
92
|
+
next
|
93
|
+
end
|
90
94
|
seen[repo] = 0 if seen[repo].nil?
|
91
95
|
if seen[repo] >= @repeats
|
92
96
|
@loog.debug("We've seen too many in the #{repo} repo, time to move to the next one")
|
93
97
|
next
|
94
98
|
end
|
95
99
|
rid = oct.repo_id_by_name(repo)
|
96
|
-
before =
|
100
|
+
before = fb.query(
|
97
101
|
"(agg (and (eq what '#{@label}') (eq where 'github') (eq repository #{rid})) (first latest))"
|
98
102
|
).one
|
99
|
-
|
103
|
+
fb.query("(and (eq what '#{@label}') (eq where 'github') (eq repository #{rid}))").delete!
|
100
104
|
before = before.nil? ? @since : before.first
|
101
|
-
nxt =
|
105
|
+
nxt = fb.query(@query).one(before:, repository: rid)
|
102
106
|
after =
|
103
107
|
if nxt.nil?
|
104
|
-
@loog.debug("Next
|
108
|
+
@loog.debug("Next element after ##{before} not suggested, re-starting from ##{@since}: #{@query}")
|
105
109
|
restarted << repo
|
106
110
|
@since
|
107
111
|
else
|
@@ -109,15 +113,15 @@ class Fbe::Iterate
|
|
109
113
|
yield(rid, nxt)
|
110
114
|
end
|
111
115
|
raise "Iterator must return an Integer, while #{after.class} returned" unless after.is_a?(Integer)
|
112
|
-
f =
|
116
|
+
f = fb.insert
|
113
117
|
f.where = 'github'
|
114
118
|
f.repository = rid
|
115
119
|
f.latest =
|
116
120
|
if after.nil?
|
117
|
-
@loog.debug("After is nil at #{repo}, setting the
|
121
|
+
@loog.debug("After is nil at #{repo}, setting the 'latest' to ##{nxt}")
|
118
122
|
nxt
|
119
123
|
else
|
120
|
-
@loog.debug("After is ##{after} at #{repo}, setting the
|
124
|
+
@loog.debug("After is ##{after} at #{repo}, setting the 'latest' to it")
|
121
125
|
after
|
122
126
|
end
|
123
127
|
f.what = @label
|
@@ -135,6 +139,10 @@ class Fbe::Iterate
|
|
135
139
|
@loog.debug('No more repos to scan, quitting')
|
136
140
|
break
|
137
141
|
end
|
142
|
+
if restarted.size == repos.size
|
143
|
+
@loog.debug("All #{repos.size} repos restarted, quitting")
|
144
|
+
break
|
145
|
+
end
|
138
146
|
end
|
139
147
|
@loog.debug("Finished scanning #{repos.size} repos: #{seen.map { |k, v| "#{k}:#{v}" }.join(', ')}")
|
140
148
|
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
|
+
fb = Fbe.fb
|
68
|
+
fb.insert.foo = 1
|
69
|
+
options = Judges::Options.new
|
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,53 @@ 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', 'testing=true'])
|
55
|
+
cycles = 0
|
56
|
+
Fbe.iterate(fb: Factbase.new, loog: Loog::NULL, global: {}, options: opts) do
|
57
|
+
as 'labels-were-scanned'
|
58
|
+
by '(plus 1 1)'
|
59
|
+
repeats 5
|
60
|
+
over do |_, nxt|
|
61
|
+
cycles += 1
|
62
|
+
nxt
|
63
|
+
end
|
64
|
+
end
|
65
|
+
assert_equal(5, cycles)
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_with_restart
|
69
|
+
opts = Judges::Options.new(['repositories=foo/bar', 'testing=true'])
|
70
|
+
cycles = 0
|
71
|
+
fb = Factbase.new
|
72
|
+
f = fb.insert
|
73
|
+
f.foo = 42
|
74
|
+
Fbe.iterate(fb:, loog: Loog::NULL, global: {}, options: opts) do
|
75
|
+
as 'labels-were-scanned'
|
76
|
+
by '(agg (and (eq foo 42) (not (exists bar))) (max foo))'
|
77
|
+
repeats 10
|
78
|
+
over do |_, nxt|
|
79
|
+
cycles += 1
|
80
|
+
f.bar = 1
|
81
|
+
nxt
|
82
|
+
end
|
83
|
+
end
|
84
|
+
assert_equal(1, cycles)
|
52
85
|
end
|
53
86
|
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.12
|
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
|