gitlab-dangerfiles 3.6.1 → 3.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/lib/danger/plugins/internal/helper.rb +9 -1
- data/lib/danger/plugins/roulette.rb +7 -1
- data/lib/gitlab/dangerfiles/base_linter.rb +10 -0
- data/lib/gitlab/dangerfiles/category.rb +97 -0
- data/lib/gitlab/dangerfiles/teammate.rb +7 -36
- data/lib/gitlab/dangerfiles/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 719c4b19692de44772e95901fe7cd45c0bc75c19474babd21a554cf95bb58238
|
4
|
+
data.tar.gz: 768847102d15a2680125ffde73a373bf42bf30ff2d7911b0fdd78e94e7661741
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 48812fba8c3a3507980a276f5322dad66ff499f7630d9a0e46c242e656f0e4e4838eb245a9d8c6386d74c0a1caff02cedbd4a37ceb38ccef75894eef98249cef
|
7
|
+
data.tar.gz: 5220bf93967c1a88b375107b8ec6ce28a87ea0109ecce8e10c56dcd540209ab402c9e74c745cfaf7431edc9a01cc4c36fb0e7dc53ae9874101bbf2980293ea88
|
data/.rubocop.yml
CHANGED
@@ -32,6 +32,9 @@ Style/HashSyntax:
|
|
32
32
|
Style/StringLiterals:
|
33
33
|
EnforcedStyle: double_quotes
|
34
34
|
|
35
|
+
Style/TrailingCommaInHashLiteral:
|
36
|
+
EnforcedStyleForMultiline: consistent_comma
|
37
|
+
|
35
38
|
# Was problematic, and not included in the .rubocop_todo.yml
|
36
39
|
GitlabSecurity/PublicSend:
|
37
40
|
Enabled: false
|
@@ -17,6 +17,7 @@ module Danger
|
|
17
17
|
none: "",
|
18
18
|
qa: "~QA",
|
19
19
|
ux: "~UX",
|
20
|
+
codeowners: '~"Code Owners"',
|
20
21
|
test: "~test for `spec/features/*`",
|
21
22
|
# Deprecated as of 2.3.0 in favor of tooling
|
22
23
|
engineering_productivity: '~"Engineering Productivity" for CI, Danger',
|
@@ -26,6 +27,7 @@ module Danger
|
|
26
27
|
integrations_be: '~"group::integrations" (backend)',
|
27
28
|
integrations_fe: '~"group::integrations" (frontend)',
|
28
29
|
"Authentication and Authorization": '~"group::authentication and authorization"',
|
30
|
+
Compliance: '~"group::compliance"',
|
29
31
|
}.freeze
|
30
32
|
|
31
33
|
# Allows to set specific rule's configuration by passing a block.
|
@@ -234,7 +236,13 @@ module Danger
|
|
234
236
|
# @return [String] the GFM for a category label, making its best guess if it's not
|
235
237
|
# a category we know about.
|
236
238
|
def label_for_category(category)
|
237
|
-
CATEGORY_LABELS
|
239
|
+
CATEGORY_LABELS[category] ||
|
240
|
+
|
241
|
+
if category.start_with?("`")
|
242
|
+
category.to_s
|
243
|
+
else
|
244
|
+
%Q{~"#{category}"}
|
245
|
+
end
|
238
246
|
end
|
239
247
|
|
240
248
|
# @return [String] +""+ when not in the CI context, and the MR Source Project ID as a string otherwise.
|
@@ -20,7 +20,13 @@ module Danger
|
|
20
20
|
|
21
21
|
Approval = Struct.new(:category, :spin) do
|
22
22
|
def self.from_approval_rule(rule, maintainer)
|
23
|
-
category =
|
23
|
+
category =
|
24
|
+
if rule["section"] == "codeowners"
|
25
|
+
"`#{rule["name"]}`"
|
26
|
+
else
|
27
|
+
rule["section"]
|
28
|
+
end.to_sym
|
29
|
+
|
24
30
|
spin = Spin.new(category, nil, maintainer, :reviewer)
|
25
31
|
|
26
32
|
new(category, spin)
|
@@ -14,6 +14,7 @@ module Gitlab
|
|
14
14
|
{
|
15
15
|
subject_too_short: "The %s must contain at least #{MIN_SUBJECT_WORDS_COUNT} words",
|
16
16
|
subject_too_long: "The %s may not be longer than #{MAX_LINE_LENGTH} characters",
|
17
|
+
subject_starts_with_a_space: "The %s must not start with a space",
|
17
18
|
subject_starts_with_lowercase: "The %s must start with a capital letter",
|
18
19
|
subject_ends_with_a_period: "The %s must not end with a period",
|
19
20
|
}
|
@@ -49,6 +50,10 @@ module Gitlab
|
|
49
50
|
add_problem(:subject_too_long, self.class.subject_description)
|
50
51
|
end
|
51
52
|
|
53
|
+
if subject_starts_with_a_space?
|
54
|
+
add_problem(:subject_starts_with_a_space, self.class.subject_description)
|
55
|
+
end
|
56
|
+
|
52
57
|
if subject_starts_with_lowercase?
|
53
58
|
add_problem(:subject_starts_with_lowercase, self.class.subject_description)
|
54
59
|
end
|
@@ -78,8 +83,13 @@ module Gitlab
|
|
78
83
|
line.length > MAX_LINE_LENGTH
|
79
84
|
end
|
80
85
|
|
86
|
+
def subject_starts_with_a_space?
|
87
|
+
subject.start_with?(" ")
|
88
|
+
end
|
89
|
+
|
81
90
|
def subject_starts_with_lowercase?
|
82
91
|
return false if subject.empty?
|
92
|
+
return false if subject_starts_with_a_space?
|
83
93
|
return false if ("A".."Z").cover?(subject[0])
|
84
94
|
|
85
95
|
first_char = subject.sub(/\A(\[[^\]]+\]|[^:\s]+:)\s/, "")[0]
|
@@ -0,0 +1,97 @@
|
|
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
|
+
test: Test,
|
15
|
+
tooling: Tooling,
|
16
|
+
integrations_be: IntegrationsBE,
|
17
|
+
integrations_fe: IntegrationsFE,
|
18
|
+
ux: UX,
|
19
|
+
}.freeze
|
20
|
+
end
|
21
|
+
private_class_method :name_to_class
|
22
|
+
|
23
|
+
def has_capability?(...)
|
24
|
+
has_particular_capability?(...) || has_universal_capability?(...)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def has_particular_capability?(teammate)
|
30
|
+
teammate.capabilities(project).include?(capability)
|
31
|
+
end
|
32
|
+
|
33
|
+
def has_universal_capability?(teammate)
|
34
|
+
false
|
35
|
+
end
|
36
|
+
|
37
|
+
def capability
|
38
|
+
# name can be nil
|
39
|
+
@capability ||= "#{kind} #{name}".strip
|
40
|
+
end
|
41
|
+
|
42
|
+
class Test < Category
|
43
|
+
private
|
44
|
+
|
45
|
+
def has_particular_capability?(teammate)
|
46
|
+
return false if kind != :reviewer
|
47
|
+
|
48
|
+
area = teammate.role[/Software Engineer in Test(?:.*?, (\w+))/, 1]
|
49
|
+
|
50
|
+
area && labels.any?("devops::#{area.downcase}")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
class Tooling < Category
|
55
|
+
private
|
56
|
+
|
57
|
+
def has_particular_capability?(teammate)
|
58
|
+
if super
|
59
|
+
true
|
60
|
+
elsif %i[trainee_maintainer maintainer].include?(kind)
|
61
|
+
false
|
62
|
+
else # fallback to backend reviewer
|
63
|
+
teammate.capabilities(project).include?("#{kind} backend")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
class IntegrationsBE < Category
|
69
|
+
private
|
70
|
+
|
71
|
+
def has_particular_capability?(teammate)
|
72
|
+
kind == :reviewer &&
|
73
|
+
teammate.role.match?(/Backend Engineer.+Manage:Integrations/)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
class IntegrationsFE < Category
|
78
|
+
private
|
79
|
+
|
80
|
+
def has_particular_capability?(teammate)
|
81
|
+
kind == :reviewer &&
|
82
|
+
teammate.role.match?(/Frontend Engineer.+Manage:Integrations/)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
class UX < Category
|
87
|
+
private
|
88
|
+
|
89
|
+
def has_universal_capability?(teammate)
|
90
|
+
teammate.projects.each_value.find do |capabilities|
|
91
|
+
capabilities.include?(capability)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require_relative "category"
|
4
|
+
|
3
5
|
module Gitlab
|
4
6
|
module Dangerfiles
|
5
7
|
class Teammate
|
@@ -74,6 +76,10 @@ module Gitlab
|
|
74
76
|
(Time.now.utc + tz_offset_hours * 3600).hour
|
75
77
|
end
|
76
78
|
|
79
|
+
def capabilities(project)
|
80
|
+
projects.fetch(project, [])
|
81
|
+
end
|
82
|
+
|
77
83
|
protected
|
78
84
|
|
79
85
|
def floored_offset_hours
|
@@ -123,42 +129,7 @@ module Gitlab
|
|
123
129
|
end
|
124
130
|
|
125
131
|
def has_capability?(project, category, kind, labels)
|
126
|
-
|
127
|
-
when :test
|
128
|
-
area = role[/Software Engineer in Test(?:.*?, (\w+))/, 1]
|
129
|
-
|
130
|
-
area && labels.any?("devops::#{area.downcase}") if kind == :reviewer
|
131
|
-
when :tooling, :engineering_productivity # Deprecated as of 2.3.0 in favor of tooling
|
132
|
-
return true if capabilities(project).include?("#{kind} #{category}")
|
133
|
-
return false if %i[trainee_maintainer maintainer].include?(kind)
|
134
|
-
|
135
|
-
capabilities(project).include?("#{kind} backend") # fallback to backend reviewer
|
136
|
-
when :integrations_be
|
137
|
-
kind == :reviewer &&
|
138
|
-
role.match?(/Backend Engineer.+Manage:Integrations/)
|
139
|
-
when :integrations_fe
|
140
|
-
kind == :reviewer &&
|
141
|
-
role.match?(/Frontend Engineer.+Manage:Integrations/)
|
142
|
-
when nil
|
143
|
-
capabilities(project).include?("#{kind}")
|
144
|
-
else
|
145
|
-
capabilities(project).include?("#{kind} #{category}")
|
146
|
-
end || has_universal_capability?(category, kind, labels)
|
147
|
-
end
|
148
|
-
|
149
|
-
def has_universal_capability?(category, kind, labels)
|
150
|
-
case category
|
151
|
-
when :ux
|
152
|
-
capacity = "#{kind} #{category}"
|
153
|
-
|
154
|
-
projects.each_value.find do |capabilities|
|
155
|
-
capabilities.include?(capacity)
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
def capabilities(project)
|
161
|
-
projects.fetch(project, [])
|
132
|
+
Category.for(category, project: project, kind: kind, labels: labels).has_capability?(self)
|
162
133
|
end
|
163
134
|
|
164
135
|
def pluralize(count, singular, plural)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab-dangerfiles
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.6.
|
4
|
+
version: 3.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitLab
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -183,6 +183,7 @@ files:
|
|
183
183
|
- lib/gitlab/Dangerfile
|
184
184
|
- lib/gitlab/dangerfiles.rb
|
185
185
|
- lib/gitlab/dangerfiles/base_linter.rb
|
186
|
+
- lib/gitlab/dangerfiles/category.rb
|
186
187
|
- lib/gitlab/dangerfiles/changes.rb
|
187
188
|
- lib/gitlab/dangerfiles/commit_linter.rb
|
188
189
|
- lib/gitlab/dangerfiles/config.rb
|