fbe 0.0.56 → 0.0.58

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: 50405a3f7472db8c909709be30db7a6eed4f5923fca49fac7ac58da9e936c324
4
- data.tar.gz: 60d9ca2097226f9763e532e0f27f020087994953d772029fb7bfb9570e6c8396
3
+ metadata.gz: 037e6b31b619e5a79f4f986f6be016c8cafed2fe3b7b000f0f02de5780052df1
4
+ data.tar.gz: 85134954a6f355895224da28d587adfad1bca6f0f41b2b3da3b7ae6757d8038f
5
5
  SHA512:
6
- metadata.gz: 7a4f743d351eb119586a77f6d675f4c311b511bd72823da1b4be71eb4ba5abcd70a22be42c91973835cc3b5451ae8c8bb68015945f1104ef504a23be073c2913
7
- data.tar.gz: e3dc8bfefcfc1fbcc5519af0961b8aea92c0ea2702e9d348710557e95ccfb8df725e4d350ecb7e11a3cac839893d27c77a709458cc0dab9c29a9a85eb77da5b6
6
+ metadata.gz: efcd99caa7002a17af0330cc0b9ab64bf049fee54d11c72454e90f4a99fca8b739b2f5ad351caa525023eb0bea0f15a7e964949821c953e77e4a76ff247d929b
7
+ data.tar.gz: b5d1c69ca30a4973400ceb74c447aa90e909103ab6c73d7e4aefd8e254bbfd868daa1e215a8080bf7da6135f312077de6525437a7fb12da1bad3570d2cfc2fdd
@@ -82,7 +82,7 @@ class Fbe::Graph
82
82
  }
83
83
  GRAPHQL
84
84
  )
85
- result.repository.pull_request.review_threads.to_h['nodes']
85
+ result&.to_h&.dig('repository', 'pullRequest', 'reviewThreads', 'nodes') || []
86
86
  end
87
87
 
88
88
  def total_commits(owner, name, branch)
@@ -124,29 +124,38 @@ class Fbe::Graph
124
124
  {}
125
125
  end
126
126
 
127
- def resolved_conversations(_owner, _name, _number)
128
- [
129
- {
130
- 'id' => 'PRRT_kwDOK2_4A85BHZAR',
131
- 'isResolved' => true,
132
- 'comments' => {
133
- 'nodes' => [
134
- {
135
- 'id' => 'PRRC_kwDOK2_4A85l3obO',
136
- 'body' => 'first message',
137
- 'author' => { '__typename' => 'User', 'login' => 'reviewer' },
138
- 'createdAt' => '2024-08-08T09:41:46Z'
139
- },
140
- {
141
- 'id' => 'PRRC_kwDOK2_4A85l3yTp',
142
- 'body' => 'second message',
143
- 'author' => { '__typename' => 'User', 'login' => 'programmer' },
144
- 'createdAt' => '2024-08-08T10:01:55Z'
145
- }
146
- ]
147
- }
127
+ def resolved_conversations(owner, name, _number)
128
+ data = {
129
+ zerocracy_baza: [
130
+ conversation('PRRT_kwDOK2_4A85BHZAR')
131
+ ]
132
+ }
133
+ data[:"#{owner}_#{name}"] || []
134
+ end
135
+
136
+ private
137
+
138
+ def conversation(id)
139
+ {
140
+ 'id' => id,
141
+ 'isResolved' => true,
142
+ 'comments' => {
143
+ 'nodes' => [
144
+ {
145
+ 'id' => 'PRRC_kwDOK2_4A85l3obO',
146
+ 'body' => 'first message',
147
+ 'author' => { '__typename' => 'User', 'login' => 'reviewer' },
148
+ 'createdAt' => '2024-08-08T09:41:46Z'
149
+ },
150
+ {
151
+ 'id' => 'PRRC_kwDOK2_4A85l3yTp',
152
+ 'body' => 'second message',
153
+ 'author' => { '__typename' => 'User', 'login' => 'programmer' },
154
+ 'createdAt' => '2024-08-08T10:01:55Z'
155
+ }
156
+ ]
148
157
  }
149
- ]
158
+ }
150
159
  end
151
160
  end
152
161
  end
data/lib/fbe/octo.rb CHANGED
@@ -181,21 +181,6 @@ class Fbe::FakeOctokit
181
181
  }
182
182
  end
183
183
 
184
- def workflow_run(repo, id)
185
- {
186
- id:,
187
- name: 'copyrights',
188
- head_branch: 'master',
189
- head_sha: '7d34c53e6743944dbf6fc729b1066bcbb3b18443',
190
- event: 'push',
191
- status: 'completed',
192
- conclusion: 'success',
193
- workflow_id: id,
194
- created_at: random_time,
195
- repository: repository(repo)
196
- }
197
- end
198
-
199
184
  def workflow_run_usage(_repo, _id)
200
185
  {
201
186
  billable: {
@@ -537,11 +522,15 @@ class Fbe::FakeOctokit
537
522
  node_id: 'R_kgDOK2_4Aw',
538
523
  name: 'baza',
539
524
  full_name: 'zerocracy/baza',
540
- private: false
525
+ private: false,
526
+ owner: {
527
+ login: 'zerocracy'
528
+ }
541
529
  }
542
530
  },
543
531
  head: {
544
- ref: 'zerocracy/baza'
532
+ ref: 'zerocracy/baza',
533
+ sha: '74d0c234967de0f690805c6943e78db42a294c1a'
545
534
  },
546
535
  merged_at: Time.now,
547
536
  comments: 2,
@@ -701,4 +690,193 @@ class Fbe::FakeOctokit
701
690
  }
702
691
  ]
703
692
  end
693
+
694
+ def check_runs_for_ref(_repo, sha)
695
+ {
696
+ total_count: 7,
697
+ check_runs: [
698
+ {
699
+ id: 28_907_016_501,
700
+ name: 'make',
701
+ head_sha: sha,
702
+ started_at: '2024-08-18T08:04:44Z',
703
+ completed_at: '2024-08-18T08:20:17Z'
704
+ },
705
+ {
706
+ id: 28_906_596_603,
707
+ name: 'copyrights',
708
+ head_sha: sha,
709
+ started_at: '2024-08-18T08:04:44Z',
710
+ completed_at: '2024-08-18T08:20:17Z'
711
+ },
712
+ {
713
+ id: 28_906_596_550,
714
+ name: 'markdown-lint',
715
+ head_sha: sha,
716
+ started_at: '2024-08-18T08:04:44Z',
717
+ completed_at: '2024-08-18T08:20:17Z'
718
+ },
719
+ {
720
+ id: 28_906_596_483,
721
+ name: 'pdd',
722
+ head_sha: sha,
723
+ started_at: '2024-08-18T08:04:44Z',
724
+ completed_at: '2024-08-18T08:20:17Z'
725
+ },
726
+ {
727
+ id: 28_906_596_433,
728
+ name: 'rake',
729
+ head_sha: sha,
730
+ started_at: '2024-08-18T08:04:44Z',
731
+ completed_at: '2024-08-18T08:20:17Z'
732
+ },
733
+ {
734
+ id: 28_906_596_405,
735
+ name: 'shellcheck',
736
+ head_sha: sha,
737
+ started_at: '2024-08-18T08:04:44Z',
738
+ completed_at: '2024-08-18T08:20:17Z'
739
+ },
740
+ {
741
+ id: 28_906_596_379,
742
+ name: 'yamllint',
743
+ head_sha: sha,
744
+ started_at: '2024-08-18T08:04:44Z',
745
+ completed_at: '2024-08-18T08:20:17Z'
746
+ }
747
+ ]
748
+ }
749
+ end
750
+
751
+ def workflow_run_job(_repo, job)
752
+ result = [
753
+ {
754
+ id: 28_907_016_501,
755
+ run_id: 10_438_531_072,
756
+ name: 'make',
757
+ started_at: '2024-08-18T08:04:44Z',
758
+ completed_at: '2024-08-18T08:20:17Z'
759
+ },
760
+ {
761
+ id: 28_906_596_603,
762
+ run_id: 10_438_531_073,
763
+ name: 'copyrights',
764
+ started_at: '2024-08-18T08:04:44Z',
765
+ completed_at: '2024-08-18T08:20:17Z'
766
+ },
767
+ {
768
+ id: 28_906_596_550,
769
+ run_id: 10_438_531_074,
770
+ name: 'markdown-lint',
771
+ started_at: '2024-08-18T08:04:44Z',
772
+ completed_at: '2024-08-18T08:20:17Z'
773
+ },
774
+ {
775
+ id: 28_906_596_483,
776
+ run_id: 10_438_531_075,
777
+ name: 'pdd',
778
+ started_at: '2024-08-18T08:04:44Z',
779
+ completed_at: '2024-08-18T08:20:17Z'
780
+ },
781
+ {
782
+ id: 28_906_596_433,
783
+ run_id: 10_438_531_076,
784
+ name: 'rake',
785
+ started_at: '2024-08-18T08:04:44Z',
786
+ completed_at: '2024-08-18T08:20:17Z'
787
+ },
788
+ {
789
+ id: 28_906_596_405,
790
+ run_id: 10_438_531_077,
791
+ name: 'shellcheck',
792
+ started_at: '2024-08-18T08:04:44Z',
793
+ completed_at: '2024-08-18T08:20:17Z'
794
+ },
795
+ {
796
+ id: 28_906_596_379,
797
+ run_id: 10_438_531_078,
798
+ name: 'yamllint',
799
+ started_at: '2024-08-18T08:04:44Z',
800
+ completed_at: '2024-08-18T08:20:17Z'
801
+ }
802
+ ].select { |json| json[:id] == job }
803
+ result.first
804
+ end
805
+
806
+ def workflow_run(repo, id)
807
+ runs = [
808
+ {
809
+ id: 10_438_531_072,
810
+ event: 'pull_request',
811
+ conclusion: 'success',
812
+ name: 'make',
813
+ started_at: '2024-08-18T08:04:44Z',
814
+ completed_at: '2024-08-18T08:20:17Z'
815
+ },
816
+ {
817
+ id: 10_438_531_073,
818
+ event: 'pull_request',
819
+ conclusion: 'success',
820
+ name: 'copyrights',
821
+ started_at: '2024-08-18T08:04:44Z',
822
+ completed_at: '2024-08-18T08:20:17Z'
823
+ },
824
+ {
825
+ id: 10_438_531_074,
826
+ event: 'pull_request',
827
+ conclusion: 'success',
828
+ name: 'markdown-lint',
829
+ started_at: '2024-08-18T08:04:44Z',
830
+ completed_at: '2024-08-18T08:20:17Z'
831
+ },
832
+ {
833
+ id: 10_438_531_075,
834
+ event: 'pull_request',
835
+ conclusion: 'failure',
836
+ name: 'pdd',
837
+ started_at: '2024-08-18T08:04:44Z',
838
+ completed_at: '2024-08-18T08:20:17Z'
839
+ },
840
+ {
841
+ id: 10_438_531_076,
842
+ event: 'pull_request',
843
+ conclusion: 'success',
844
+ name: 'rake',
845
+ started_at: '2024-08-18T08:04:44Z',
846
+ completed_at: '2024-08-18T08:20:17Z'
847
+ },
848
+ {
849
+ id: 10_438_531_077,
850
+ event: 'commit',
851
+ conclusion: 'success',
852
+ name: 'shellcheck',
853
+ started_at: '2024-08-18T08:04:44Z',
854
+ completed_at: '2024-08-18T08:20:17Z'
855
+ },
856
+ {
857
+ id: 10_438_531_078,
858
+ event: 'pull_request',
859
+ conclusion: 'failure',
860
+ name: 'yamllint',
861
+ started_at: '2024-08-18T08:04:44Z',
862
+ completed_at: '2024-08-18T08:20:17Z'
863
+ }
864
+ ].select { |json| json[:id] == id }
865
+ if runs.first.nil?
866
+ {
867
+ id:,
868
+ name: 'copyrights',
869
+ head_branch: 'master',
870
+ head_sha: '7d34c53e6743944dbf6fc729b1066bcbb3b18443',
871
+ event: 'push',
872
+ status: 'completed',
873
+ conclusion: 'success',
874
+ workflow_id: id,
875
+ created_at: random_time,
876
+ repository: repository(repo)
877
+ }
878
+ else
879
+ runs.first
880
+ end
881
+ end
704
882
  end
data/lib/fbe.rb CHANGED
@@ -27,5 +27,5 @@
27
27
  # License:: MIT
28
28
  module Fbe
29
29
  # Current version of the gem (changed by .rultor.yml on every release)
30
- VERSION = '0.0.56'
30
+ VERSION = '0.0.58'
31
31
  end
@@ -80,6 +80,15 @@ class TestGitHubGraph < Minitest::Test
80
80
  g = Fbe.github_graph(options:, loog: Loog::NULL, global:)
81
81
  result = g.resolved_conversations('zerocracy', 'baza', 172)
82
82
  assert_equal(1, result.count)
83
+ result = g.resolved_conversations('zerocracy', 'baza', 0)
84
+ assert(Array, result.class)
85
+ assert(0, result.count)
86
+ result = g.resolved_conversations('zerocracy1', 'baza', 0)
87
+ assert(Array, result.class)
88
+ assert(0, result.count)
89
+ result = g.resolved_conversations('zerocracy', 'baza1', 0)
90
+ assert(Array, result.class)
91
+ assert(0, result.count)
83
92
  end
84
93
 
85
94
  def test_gets_total_commits_of_repo
@@ -91,4 +100,18 @@ class TestGitHubGraph < Minitest::Test
91
100
  result = g.total_commits('zerocracy', 'baza', 'master')
92
101
  assert(result.positive?)
93
102
  end
103
+
104
+ def test_get_fake_empty_conversations
105
+ WebMock.disable_net_connect!
106
+ graph = Fbe.github_graph(options: Judges::Options.new('testing' => true), loog: Loog::NULL, global: {})
107
+ result = graph.resolved_conversations(nil, 'baza', 172)
108
+ assert(result.empty?)
109
+ end
110
+
111
+ def test_get_fake_conversations
112
+ WebMock.disable_net_connect!
113
+ graph = Fbe.github_graph(options: Judges::Options.new('testing' => true), loog: Loog::NULL, global: {})
114
+ result = graph.resolved_conversations('zerocracy', 'baza', 172)
115
+ assert_equal(1, result.count)
116
+ end
94
117
  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.56
4
+ version: 0.0.58
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-08-19 00:00:00.000000000 Z
11
+ date: 2024-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace