fbe 0.0.60 → 0.0.62

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4933facacd974e44985f3931125665ab4456062b0f4a45faf3bdc6a970e42c21
4
- data.tar.gz: 53f0dde5e526aa66a703f8ee088ecd08e7aedb49d847b46c3b6a0080930509d6
3
+ metadata.gz: 9db76ff808a838d58140d80ab38a5abcaa73cac5e2db61a1fdf0f5eba7893ebc
4
+ data.tar.gz: 7adbb08362be5719e5213b86fae16d958b7b8472037d3a3d5472188fbdd9f044
5
5
  SHA512:
6
- metadata.gz: 17c95861794f3865ecd9e5e5f1afe3863a7194393dce7fa7d1bd479455595ca563868819f2e7e445590ddc819f09907411923a4c21c65a26e7201165809270c4
7
- data.tar.gz: 2404df0f1d5514a696f8e6604fada7792f5ce8e605dec85f48938b831dc5cd833221137e5c907e233723b67d080d78d77a1bdbf38db37f4cbe06a54cb84e72f2
6
+ metadata.gz: 666d18d08f85c279c8eeb556b77faf69dcbe1836e9bc222ddc3be7320f13e52a80ecc1d00b5cff60540e04a649e39fcda697934b5be02385dfb0e313ddb8f128
7
+ data.tar.gz: d33b53016e62a49726639efe3058a92bf875b71a21fa07c6466b60ebd8f85ed48fff3a08ca08d20f1a3df25b7d31c4f913d591f354a99961d7959983a0beb9a7
@@ -1,7 +1,7 @@
1
1
  (award
2
2
  (explain "When a bug is reported and accepted by the team, the reporter gets a bonus")
3
3
  (aka
4
- (let bonus {{ 8 | times: love }})
4
+ (let bonus {{ 4 | times: love }})
5
5
  (give bonus "as a basis")
6
6
  "award ${bonus} points")
7
7
  )
@@ -5,12 +5,12 @@
5
5
  (in reviews "the number of reviews provided")
6
6
 
7
7
  (aka
8
- (let basis {{ 8 | times: love }})
8
+ (let basis {{ 2 | times: love }})
9
9
  (give basis "as a basis")
10
10
  "award ${basis} points")
11
11
 
12
12
  (aka
13
- (let hoc_k {{ 0.05 | times: love }})
13
+ (let hoc_k {{ 0.025 | times: love }})
14
14
  (let hoc_threshold {{ 400 | divided_by: paranoia }})
15
15
  (let hoc_max 16)
16
16
  (let hoc_min 5)
@@ -72,7 +72,7 @@
72
72
  "deduct ${few_hoc_fee} points if you contribute less than ${hoc_needed} hits-of-code")
73
73
 
74
74
  (aka
75
- (let max 32)
75
+ (let max 24)
76
76
  (set over (if (gt (total) max) (minus max (total)) 0))
77
77
  (give over "to not go over the cap")
78
78
  (let min 4)
@@ -5,7 +5,7 @@
5
5
  (in self "1 if the review was made for their own code contribution, otherwise zero")
6
6
 
7
7
  (aka
8
- (let basis {{ 4 | times: love }})
8
+ (let basis {{ 2 | times: love }})
9
9
  (give basis "as a basis")
10
10
  "award ${basis} points")
11
11
 
@@ -16,7 +16,7 @@
16
16
  "deduct ${self_fee} points if they reviewed their own contribution")
17
17
 
18
18
  (aka
19
- (let hoc_k {{ 0.01 | times: love }})
19
+ (let hoc_k {{ 0.005 | times: love }})
20
20
  (let hoc_max 16)
21
21
  (let hoc_min 5)
22
22
  (set bonus_for_hoc (times hoc hoc_k))
@@ -41,7 +41,7 @@
41
41
  "deduct ${silence_fee} points if there were absolutely no comments made during review")
42
42
 
43
43
  (aka
44
- (let comments_k {{ 0.25 | times: love }})
44
+ (let comments_k {{ 0.125 | times: love }})
45
45
  (let comments_max 8)
46
46
  (let comments_min 5)
47
47
  (set bonus_for_comments (times comments comments_k))
@@ -58,7 +58,7 @@
58
58
  "deduct ${hoc_fee} points if there were less than ${hoc_needed} hits-of-code")
59
59
 
60
60
  (aka
61
- (let max 32)
61
+ (let max 24)
62
62
  (set over (if (gt (total) max) (minus max (total)) 0))
63
63
  (give over "to not go over the cap")
64
64
  (let min 4)
@@ -1,7 +1,7 @@
1
1
  (award
2
2
  (explain "When an enhancement is suggested and accepted by the team, the reporter gets a bonus")
3
3
  (aka
4
- (let bonus {{ 8 | times: love }})
4
+ (let bonus {{ 4 | times: love }})
5
5
  (give bonus "as a basis")
6
6
  "award ${bonus} points")
7
7
  )
@@ -4,12 +4,12 @@
4
4
  (in self "1 if the bug was reported and resolved by the same person, otherwise zero")
5
5
  (set days (div hours 24))
6
6
  (aka
7
- (let basis {{ 8 | times: love }})
7
+ (let basis {{ 2 | times: love }})
8
8
  (give basis "as a basis")
9
9
  "award ${basis} points")
10
10
 
11
11
  (aka
12
- (let b1 {{ 4 | times: love }})
12
+ (let b1 {{ 2 | times: love }})
13
13
  (let hours_threshold {{ 48 | divided_by: paranoia }})
14
14
  (set b1 (if (lt hours hours_threshold) b1 0))
15
15
  (give b1 "for resolving it in less than ${hours_threshold} hours")
@@ -30,7 +30,7 @@
30
30
  "deduct ${day_fee} points for each day of delay, but no more than ${days_fee_max} points")
31
31
 
32
32
  (aka
33
- (let max 24)
33
+ (let max 16)
34
34
  (set over (if (gt (total) max) (minus max (total)) 0))
35
35
  (give over "to not go over the cap")
36
36
  (let min 4)
data/lib/fbe/octo.rb CHANGED
@@ -541,6 +541,64 @@ class Fbe::FakeOctokit
541
541
  changed_files: 2
542
542
  }
543
543
  }
544
+ },
545
+ {
546
+ id: 43,
547
+ created_at: Time.now,
548
+ actor: { id: 42 },
549
+ type: 'PullRequestEvent',
550
+ repo: { id: repo },
551
+ payload: {
552
+ action: 'closed',
553
+ number: 172,
554
+ ref_type: 'tag',
555
+ ref: 'foo',
556
+ pull_request: {
557
+ url: 'https://api.github.com/repos/yegor256/judges/pulls/93',
558
+ id: 1_990_323_142,
559
+ node_id: 'PR_kwDOL6GCO852oevG',
560
+ number: 172,
561
+ state: 'closed',
562
+ locked: false,
563
+ title: '#999 new feature',
564
+ user: {
565
+ login: 'test',
566
+ id: 88_084_038,
567
+ node_id: 'MDQ6VXNlcjE2NDYwMjA=',
568
+ type: 'User',
569
+ site_admin: false
570
+ },
571
+ base: {
572
+ label: 'zerocracy:master',
573
+ ref: 'master',
574
+ user: {
575
+ login: 'zerocracy',
576
+ id: 24_234_201
577
+ },
578
+ repo: {
579
+ id: repo,
580
+ node_id: 'R_kgDOK2_4Aw',
581
+ name: 'judges-action',
582
+ full_name: 'zerocracy/judges-action',
583
+ private: false,
584
+ owner: {
585
+ login: 'zerocracy'
586
+ }
587
+ }
588
+ },
589
+ head: {
590
+ ref: 'zerocracy/judges-action',
591
+ sha: '74d0c234967de0f690805c6943e78db42a294c1a'
592
+ },
593
+ merged_at: Time.now,
594
+ comments: 2,
595
+ review_comments: 2,
596
+ commits: 1,
597
+ additions: 3,
598
+ deletions: 3,
599
+ changed_files: 2
600
+ }
601
+ }
544
602
  }
545
603
  ]
546
604
  end
@@ -691,65 +749,166 @@ class Fbe::FakeOctokit
691
749
  ]
692
750
  end
693
751
 
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
- ]
752
+ def check_runs_for_ref(repo, sha)
753
+ data = {
754
+ 'zerocracy/baza' => {
755
+ total_count: 7,
756
+ check_runs: [
757
+ {
758
+ id: 28_907_016_501,
759
+ name: 'make',
760
+ head_sha: sha,
761
+ started_at: '2024-08-18T08:04:44Z',
762
+ completed_at: '2024-08-18T08:20:17Z',
763
+ app: {
764
+ slug: 'github-actions'
765
+ }
766
+ },
767
+ {
768
+ id: 28_906_596_603,
769
+ name: 'copyrights',
770
+ head_sha: sha,
771
+ started_at: '2024-08-18T08:04:44Z',
772
+ completed_at: '2024-08-18T08:20:17Z',
773
+ app: {
774
+ slug: 'github-actions'
775
+ }
776
+ },
777
+ {
778
+ id: 28_906_596_550,
779
+ name: 'markdown-lint',
780
+ head_sha: sha,
781
+ started_at: '2024-08-18T08:04:44Z',
782
+ completed_at: '2024-08-18T08:20:17Z',
783
+ app: {
784
+ slug: 'github-actions'
785
+ }
786
+ },
787
+ {
788
+ id: 28_906_596_483,
789
+ name: 'pdd',
790
+ head_sha: sha,
791
+ started_at: '2024-08-18T08:04:44Z',
792
+ completed_at: '2024-08-18T08:20:17Z',
793
+ app: {
794
+ slug: 'github-actions'
795
+ }
796
+ },
797
+ {
798
+ id: 28_906_596_433,
799
+ name: 'rake',
800
+ head_sha: sha,
801
+ started_at: '2024-08-18T08:04:44Z',
802
+ completed_at: '2024-08-18T08:20:17Z',
803
+ app: {
804
+ slug: 'github-actions'
805
+ }
806
+ },
807
+ {
808
+ id: 28_906_596_405,
809
+ name: 'shellcheck',
810
+ head_sha: sha,
811
+ started_at: '2024-08-18T08:04:44Z',
812
+ completed_at: '2024-08-18T08:20:17Z',
813
+ app: {
814
+ slug: 'github-actions'
815
+ }
816
+ },
817
+ {
818
+ id: 28_906_596_379,
819
+ name: 'yamllint',
820
+ head_sha: sha,
821
+ started_at: '2024-08-18T08:04:44Z',
822
+ completed_at: '2024-08-18T08:20:17Z',
823
+ app: {
824
+ slug: 'github-actions'
825
+ }
826
+ }
827
+ ]
828
+ },
829
+ 'zerocracy/judges-action' => {
830
+ total_count: 7,
831
+ check_runs: [
832
+ {
833
+ id: 28_907_016_501,
834
+ name: 'Codacy Static Code Analysis',
835
+ head_sha: sha,
836
+ started_at: '2024-08-18T08:04:44Z',
837
+ completed_at: '2024-08-18T08:20:17Z',
838
+ app: {
839
+ slug: 'codacy-production'
840
+ }
841
+ },
842
+ {
843
+ id: 28_906_596_603,
844
+ name: 'copyrights',
845
+ head_sha: sha,
846
+ started_at: '2024-08-18T08:04:44Z',
847
+ completed_at: '2024-08-18T08:20:17Z',
848
+ app: {
849
+ slug: 'github-actions'
850
+ }
851
+ },
852
+ {
853
+ id: 28_906_596_550,
854
+ name: 'markdown-lint',
855
+ head_sha: sha,
856
+ started_at: '2024-08-18T08:04:44Z',
857
+ completed_at: '2024-08-18T08:20:17Z',
858
+ app: {
859
+ slug: 'github-actions'
860
+ }
861
+ },
862
+ {
863
+ id: 28_906_596_483,
864
+ name: 'pdd',
865
+ head_sha: sha,
866
+ started_at: '2024-08-18T08:04:44Z',
867
+ completed_at: '2024-08-18T08:20:17Z',
868
+ app: {
869
+ slug: 'github-actions'
870
+ }
871
+ },
872
+ {
873
+ id: 28_906_596_433,
874
+ name: 'rake',
875
+ head_sha: sha,
876
+ started_at: '2024-08-18T08:04:44Z',
877
+ completed_at: '2024-08-18T08:20:17Z',
878
+ app: {
879
+ slug: 'github-actions'
880
+ }
881
+ },
882
+ {
883
+ id: 28_906_596_405,
884
+ name: 'shellcheck',
885
+ head_sha: sha,
886
+ started_at: '2024-08-18T08:04:44Z',
887
+ completed_at: '2024-08-18T08:20:17Z',
888
+ app: {
889
+ slug: 'github-actions'
890
+ }
891
+ },
892
+ {
893
+ id: 28_906_596_379,
894
+ name: 'yamllint',
895
+ head_sha: sha,
896
+ started_at: '2024-08-18T08:04:44Z',
897
+ completed_at: '2024-08-18T08:20:17Z',
898
+ app: {
899
+ slug: 'github-actions'
900
+ }
901
+ }
902
+ ]
903
+ }
748
904
  }
905
+ data.fetch(repo) do
906
+ { total_count: 0, check_runs: [] }
907
+ end
749
908
  end
750
909
 
751
910
  def workflow_run_job(_repo, job)
752
- result = [
911
+ [
753
912
  {
754
913
  id: 28_907_016_501,
755
914
  run_id: 10_438_531_072,
@@ -799,12 +958,17 @@ class Fbe::FakeOctokit
799
958
  started_at: '2024-08-18T08:04:44Z',
800
959
  completed_at: '2024-08-18T08:20:17Z'
801
960
  }
802
- ].select { |json| json[:id] == job }
803
- result.first
961
+ ].select { |json| json[:id] == job }.first || {
962
+ id: job,
963
+ run_id: 1234,
964
+ name: 'run job',
965
+ started_at: '2024-08-18T08:04:44Z',
966
+ completed_at: '2024-08-18T08:20:17Z'
967
+ }
804
968
  end
805
969
 
806
970
  def workflow_run(repo, id)
807
- runs = [
971
+ [
808
972
  {
809
973
  id: 10_438_531_072,
810
974
  event: 'pull_request',
@@ -861,22 +1025,17 @@ class Fbe::FakeOctokit
861
1025
  started_at: '2024-08-18T08:04:44Z',
862
1026
  completed_at: '2024-08-18T08:20:17Z'
863
1027
  }
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
1028
+ ].select { |json| json[:id] == id }.first || {
1029
+ id:,
1030
+ name: 'copyrights',
1031
+ head_branch: 'master',
1032
+ head_sha: '7d34c53e6743944dbf6fc729b1066bcbb3b18443',
1033
+ event: 'push',
1034
+ status: 'completed',
1035
+ conclusion: 'success',
1036
+ workflow_id: id,
1037
+ created_at: random_time,
1038
+ repository: repository(repo)
1039
+ }
881
1040
  end
882
1041
  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.60'
30
+ VERSION = '0.0.62'
31
31
  end
@@ -51,13 +51,13 @@ class TestBylaws < Minitest::Test
51
51
  { hoc: 30_000, contributors: 1 } => 32
52
52
  },
53
53
  'resolved-bug-was-rewarded' => {
54
- { hours: 1, self: 0 } => 24,
55
- { hours: 48, self: 0 } => 14,
56
- { hours: 80, self: 0 } => 13,
54
+ { hours: 1, self: 0 } => 8,
55
+ { hours: 48, self: 0 } => 4,
56
+ { hours: 80, self: 0 } => 4,
57
57
  { hours: 300, self: 0 } => 4,
58
58
  { hours: 3_000, self: 0 } => 4,
59
59
  { hours: 30_000, self: 0 } => 4,
60
- { hours: 1, self: 1 } => 8
60
+ { hours: 1, self: 1 } => 4
61
61
  },
62
62
  'push-to-master-was-punished' => {
63
63
  {} => -16
@@ -65,10 +65,10 @@ class TestBylaws < Minitest::Test
65
65
  'code-review-was-rewarded' => {
66
66
  { hoc: 0, comments: 0, self: 0 } => 4,
67
67
  { hoc: 3, comments: 0, self: 0 } => 4,
68
- { hoc: 78, comments: 7, self: 0 } => 8,
69
- { hoc: 600, comments: 1, self: 0 } => 10,
70
- { hoc: 500, comments: 40, self: 0 } => 26,
71
- { hoc: 5_000, comments: 100, self: 0 } => 32,
68
+ { hoc: 78, comments: 7, self: 0 } => 4,
69
+ { hoc: 600, comments: 1, self: 0 } => 4,
70
+ { hoc: 500, comments: 40, self: 0 } => 17,
71
+ { hoc: 5_000, comments: 100, self: 0 } => 24,
72
72
  { hoc: 100, comments: 50, self: 1 } => 4,
73
73
  { hoc: 10_000, comments: 200, self: 1 } => 4
74
74
  },
@@ -77,20 +77,21 @@ class TestBylaws < Minitest::Test
77
77
  { hoc: 3, comments: 0, reviews: 0 } => 4,
78
78
  { hoc: 78, comments: 0, reviews: 0 } => 4,
79
79
  { hoc: 78, comments: 1, reviews: 0 } => 4,
80
- { hoc: 50, comments: 15, reviews: 0 } => 5,
80
+ { hoc: 50, comments: 15, reviews: 0 } => 4,
81
81
  { hoc: 50, comments: 25, reviews: 0 } => 4,
82
- { hoc: 180, comments: 7, reviews: 2 } => 32,
83
- { hoc: 150, comments: 5, reviews: 1 } => 27,
82
+ { hoc: 180, comments: 7, reviews: 2 } => 13,
83
+ { hoc: 199, comments: 8, reviews: 3 } => 14,
84
+ { hoc: 150, comments: 5, reviews: 1 } => 8,
84
85
  { hoc: 500, comments: 25, reviews: 2 } => 4,
85
- { hoc: 99, comments: 6, reviews: 1 } => 26,
86
+ { hoc: 99, comments: 6, reviews: 1 } => 4,
86
87
  { hoc: 1_500, comments: 3, reviews: 0 } => 4,
87
88
  { hoc: 15_000, comments: 40, reviews: 0 } => 4
88
89
  },
89
90
  'bug-report-was-rewarded' => {
90
- {} => 16
91
+ {} => 8
91
92
  },
92
93
  'enhancement-suggestion-was-rewarded' => {
93
- {} => 16
94
+ {} => 8
94
95
  },
95
96
  'dud-was-punished' => {
96
97
  {} => -16
@@ -104,7 +105,7 @@ class TestBylaws < Minitest::Test
104
105
  assert(!formula.nil?, title)
105
106
  a = Fbe::Award.new(formula)
106
107
  help = [
107
- " '#{title.gsub('-', '_')}' => {\n ",
108
+ " '#{title.gsub('_', '-')}' => {\n ",
108
109
  pairs.map do |args, _|
109
110
  [
110
111
  '{',
@@ -160,6 +160,42 @@ class TestOcto < Minitest::Test
160
160
  assert(!o.off_quota) if n > 100
161
161
  limit -= 1
162
162
  end
163
- assert_in_delta(pause, Time.now - start_time, 1)
163
+ assert_in_delta(pause, Time.now - start_time, 5)
164
+ end
165
+
166
+ def test_fetches_fake_check_runs_for_ref
167
+ WebMock.disable_net_connect!
168
+ o = Fbe.octo(loog: Loog::NULL, global: {}, options: Judges::Options.new({ 'testing' => true }))
169
+ sha = 'f2ca1bb6c7e907d06'
170
+ result = o.check_runs_for_ref('zerocracy/baza', sha)
171
+ assert_equal(7, result[:total_count])
172
+ assert_equal(7, result[:check_runs].count)
173
+ result = o.check_runs_for_ref('zerocracy/judges-action', sha)
174
+ assert_equal(7, result[:total_count])
175
+ assert_equal(7, result[:check_runs].count)
176
+ result = o.check_runs_for_ref('zerocracy/something', sha)
177
+ assert_equal(0, result[:total_count])
178
+ assert_instance_of(Array, result[:check_runs])
179
+ assert_equal(0, result[:check_runs].count)
180
+ end
181
+
182
+ def test_fetches_fake_workflow_run
183
+ WebMock.disable_net_connect!
184
+ o = Fbe.octo(loog: Loog::NULL, global: {}, options: Judges::Options.new({ 'testing' => true }))
185
+ id = 10_438_531_072
186
+ result = o.workflow_run('zerocracy/baza', id)
187
+ assert_equal(id, result[:id])
188
+ result = o.workflow_run('zerocracy/baza', 0)
189
+ assert_equal(0, result[:id])
190
+ end
191
+
192
+ def test_fetches_fake_workflow_run_job
193
+ WebMock.disable_net_connect!
194
+ o = Fbe.octo(loog: Loog::NULL, global: {}, options: Judges::Options.new({ 'testing' => true }))
195
+ id = 28_906_596_433
196
+ result = o.workflow_run_job('zerocracy/baza', id)
197
+ assert_equal(id, result[:id])
198
+ result = o.workflow_run_job('zerocracy/baza', 0)
199
+ assert_equal(0, result[:id])
164
200
  end
165
201
  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.60
4
+ version: 0.0.62
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-22 00:00:00.000000000 Z
11
+ date: 2024-08-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backtrace