gitlab-dangerfiles 4.6.0 → 4.8.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/.gitignore +0 -1
- data/.gitlab-ci.yml +11 -21
- data/.rubocop.yml +3 -16
- data/Gemfile.lock +231 -0
- data/lefthook.yml +0 -5
- data/lib/danger/plugins/changelog.rb +8 -4
- data/lib/danger/plugins/internal/helper.rb +17 -6
- data/lib/danger/plugins/roulette.rb +34 -267
- data/lib/danger/rules/commit_messages/Dangerfile +1 -6
- data/lib/danger/rules/simple_roulette/Dangerfile +4 -2
- data/lib/gitlab/dangerfiles/approval.rb +22 -0
- data/lib/gitlab/dangerfiles/base_linter.rb +1 -1
- data/lib/gitlab/dangerfiles/capability.rb +84 -0
- data/lib/gitlab/dangerfiles/commit_linter.rb +2 -2
- data/lib/gitlab/dangerfiles/emoji_checker.rb +1 -1
- data/lib/gitlab/dangerfiles/spec_helper.rb +231 -1
- data/lib/gitlab/dangerfiles/spin.rb +15 -0
- data/lib/gitlab/dangerfiles/spinner.rb +190 -0
- data/lib/gitlab/dangerfiles/teammate.rb +89 -3
- data/lib/gitlab/dangerfiles/type_label_guesser.rb +1 -1
- data/lib/gitlab/dangerfiles/version.rb +1 -1
- metadata +8 -4
- data/lib/gitlab/dangerfiles/category.rb +0 -111
@@ -1,111 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Gitlab
|
4
|
-
module Dangerfiles
|
5
|
-
CategoryStruct = Struct.new(:name, :project, :kind, :labels, keyword_init: true)
|
6
|
-
|
7
|
-
class Category < CategoryStruct
|
8
|
-
def self.for(name, **arguments)
|
9
|
-
(name_to_class[name] || self).new(name: name, **arguments)
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.name_to_class
|
13
|
-
@name_to_class ||= {
|
14
|
-
none: None,
|
15
|
-
test: Test,
|
16
|
-
tooling: Tooling,
|
17
|
-
import_integrate_be: ImportIntegrateBE,
|
18
|
-
import_integrate_fe: ImportIntegrateFE,
|
19
|
-
ux: UX,
|
20
|
-
}.freeze
|
21
|
-
end
|
22
|
-
private_class_method :name_to_class
|
23
|
-
|
24
|
-
def has_capability?(teammate)
|
25
|
-
teammate.capabilities(project).include?(capability)
|
26
|
-
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def capability
|
31
|
-
@capability ||= "#{kind} #{name}"
|
32
|
-
end
|
33
|
-
|
34
|
-
class None < Category
|
35
|
-
def capability
|
36
|
-
@capability ||= kind.to_s
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
class Test < Category
|
41
|
-
def has_capability?(teammate)
|
42
|
-
return false if kind != :reviewer
|
43
|
-
|
44
|
-
area = teammate.role[/Software Engineer in Test(?:.*?, (\w+))/, 1]
|
45
|
-
|
46
|
-
!!area && labels.any?("devops::#{area.downcase}")
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
class Tooling < Category
|
51
|
-
def has_capability?(teammate)
|
52
|
-
if super
|
53
|
-
true
|
54
|
-
elsif %i[trainee_maintainer maintainer].include?(kind)
|
55
|
-
false
|
56
|
-
else # fallback to backend reviewer
|
57
|
-
teammate.capabilities(project).include?("#{kind} backend")
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
class ImportIntegrateBE < Category
|
63
|
-
def has_capability?(teammate)
|
64
|
-
kind == :reviewer &&
|
65
|
-
teammate.role.match?(/Backend Engineer.+Manage:Import and Integrate/)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
class ImportIntegrateFE < Category
|
70
|
-
def has_capability?(teammate)
|
71
|
-
kind == :reviewer &&
|
72
|
-
teammate.role.match?(/Frontend Engineer.+Manage:Import and Integrate/)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
class UX < Category
|
77
|
-
def has_capability?(teammate)
|
78
|
-
super &&
|
79
|
-
|
80
|
-
if labels.any?("Community contribution")
|
81
|
-
# We want the designer for the team to review the wider community
|
82
|
-
# contribution because they're more familiar with that area.
|
83
|
-
the_designer_for_the_team?(teammate)
|
84
|
-
else
|
85
|
-
# We don't want the designer for the team to review merge
|
86
|
-
# requests for the same team which is designed by themselves.
|
87
|
-
# So they can only review if they're not the designer for the team.
|
88
|
-
!the_designer_for_the_team?(teammate)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
private
|
93
|
-
|
94
|
-
def the_designer_for_the_team?(teammate)
|
95
|
-
# Pick corresponding group for community contribution
|
96
|
-
# Specialty can be:
|
97
|
-
# Source Code
|
98
|
-
# [Growth: Activation, Growth: Expansion]
|
99
|
-
# Runner
|
100
|
-
group_labels = Array(teammate.specialty).map do |field|
|
101
|
-
group = field.strip.sub(/^.+: ?/, "").downcase
|
102
|
-
|
103
|
-
"group::#{group}"
|
104
|
-
end
|
105
|
-
|
106
|
-
(group_labels & labels).any?
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|