gitlab-dangerfiles 3.13.0 → 4.10.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.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +0 -1
  3. data/.gitlab/CODEOWNERS +1 -1
  4. data/.gitlab/merge_request_templates/Release.md +1 -1
  5. data/.gitlab-ci.yml +21 -42
  6. data/.rubocop.yml +6 -16
  7. data/.rubocop_todo.yml +5 -8
  8. data/Gemfile +0 -16
  9. data/Gemfile.lock +234 -0
  10. data/README.md +96 -9
  11. data/gitlab-dangerfiles.gemspec +13 -5
  12. data/lefthook.yml +0 -5
  13. data/lib/danger/plugins/changelog.rb +9 -7
  14. data/lib/danger/plugins/duo_code.rb +12 -0
  15. data/lib/danger/plugins/internal/helper.rb +34 -10
  16. data/lib/danger/plugins/roulette.rb +95 -256
  17. data/lib/danger/rules/commit_messages/Dangerfile +2 -7
  18. data/lib/danger/rules/duo_code_review/Dangerfile +10 -0
  19. data/lib/danger/rules/simple_roulette/Dangerfile +17 -10
  20. data/lib/danger/rules/type_label/Dangerfile +0 -8
  21. data/lib/danger/rules/z_add_labels/Dangerfile +3 -3
  22. data/lib/gitlab/dangerfiles/approval.rb +22 -0
  23. data/lib/gitlab/dangerfiles/base_linter.rb +1 -1
  24. data/lib/gitlab/dangerfiles/capability.rb +82 -0
  25. data/lib/gitlab/dangerfiles/commit_linter.rb +2 -2
  26. data/lib/gitlab/dangerfiles/config.rb +29 -3
  27. data/lib/gitlab/dangerfiles/emoji_checker.rb +1 -1
  28. data/lib/gitlab/dangerfiles/spec_helper.rb +231 -1
  29. data/lib/gitlab/dangerfiles/spin.rb +15 -0
  30. data/lib/gitlab/dangerfiles/spinner.rb +191 -0
  31. data/lib/gitlab/dangerfiles/teammate.rb +94 -20
  32. data/lib/gitlab/dangerfiles/type_label_guesser.rb +2 -2
  33. data/lib/gitlab/dangerfiles/version.rb +1 -1
  34. data/lib/gitlab/dangerfiles.rb +0 -1
  35. metadata +100 -25
  36. data/lib/danger/rules/subtype_label/Dangerfile +0 -14
  37. data/lib/gitlab/dangerfiles/category.rb +0 -111
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fae45cdf2a0c840f86b2d1864e521587210e4f365d2d03727be0d73866e4379c
4
- data.tar.gz: a8380520fe8d4d12be578493244570265023db9f850ff374cd879591fb533b02
3
+ metadata.gz: dc6047699d31bc320127f651d567ddf984b6189eeeb7646eb4f0d46b4185e9fd
4
+ data.tar.gz: 655da17704203a02f6f138b8493bb8cf2002c2121d1015a63da0677ebf23b48d
5
5
  SHA512:
6
- metadata.gz: 178104293164685aa9b265505785872372ad621b92b15fca37a590be070e7abbfd4090c339f3869c1c9e4da56281800b479c96c6992fb141e358320944e508ab
7
- data.tar.gz: bb6f9c2b409a904517d7f8e91918ddc7df959de37b41a25cd898398749d227e5b40755669a406e3bd8063df255f8639d5fccdef37c2cd150cad31e6c3d036f11
6
+ metadata.gz: 02613c71246a09f46d15e0117e3f304ae626618c5736ff9b02f5e15bfbeccaa4921cefa694c97548dc5af2f4611866b58eb29f9eb5e0305d7412461097980a2c
7
+ data.tar.gz: 6703f6fe3502ad2336c33a4296a67d3e7d77d0dd9e46db97f510f0bd4c17a729f1bb20afcbb4ab6a0d5b24da477e4e50378e76cb943b9fc474fbed29320e619b
data/.gitignore CHANGED
@@ -3,7 +3,6 @@
3
3
  /.rspec
4
4
  /.bundle/
5
5
  /.yardoc
6
- /Gemfile.lock
7
6
  /_yardoc/
8
7
  /coverage/
9
8
  /pkg/
data/.gitlab/CODEOWNERS CHANGED
@@ -1 +1 @@
1
- * @gl-quality/eng-prod
1
+ * @gl-dx/eng-prod
@@ -2,7 +2,7 @@
2
2
  commit from this merge request, and `<NEW_VERSION>` with the upcoming version number. -->
3
3
  ## Diff
4
4
 
5
- https://gitlab.com/gitlab-org/ruby/gems/gitlab-dangerfiles/-/compare/v<PREVIOUS_VERSION>...<COMMIT_UPDATING_VERSION>
5
+ https://gitlab.com/gitlab-org/ruby/gems/gitlab-dangerfiles/-/compare/<PREVIOUS_VERSION>...<COMMIT_UPDATING_VERSION>
6
6
 
7
7
  ## Checklist
8
8
 
data/.gitlab-ci.yml CHANGED
@@ -11,13 +11,9 @@ workflow:
11
11
  # For tags, create a pipeline.
12
12
  - if: '$CI_COMMIT_TAG'
13
13
 
14
- .default:
15
- image: "ruby:${RUBY_VERSION}"
14
+ default:
16
15
  tags:
17
16
  - gitlab-org
18
- before_script:
19
- - gem install bundler
20
- - bundle install -j $(nproc) --path vendor
21
17
  cache:
22
18
  key:
23
19
  files:
@@ -25,64 +21,47 @@ workflow:
25
21
  - gitlab-dangerfiles.gemspec
26
22
  paths:
27
23
  - vendor/ruby
28
- - Gemfile.lock
29
- policy: pull
30
24
 
31
- test:rspec:
32
- extends: .default
25
+ .default-test-job:
26
+ image: "${GITLAB_DEPENDENCY_PROXY}ruby:${RUBY_VERSION}"
33
27
  stage: test
34
- script:
35
- - bundle exec rspec
28
+ needs: []
29
+ before_script:
30
+ - gem install bundler
31
+ - bundle install -j $(nproc) --path vendor
36
32
  parallel:
37
33
  matrix:
38
34
  - RUBY_VERSION: ['3.0', '3.1', '3.2']
39
35
 
40
- test:rubocop:
41
- extends: .default
42
- stage: test
36
+ test:rspec:
37
+ extends: .default-test-job
43
38
  script:
44
- - bundle exec rubocop -P -E .
45
- parallel:
46
- matrix:
47
- - RUBY_VERSION: ['3.0', '3.1', '3.2']
39
+ - bundle exec rspec
48
40
 
49
- test:rufo:
50
- extends: .default
51
- stage: test
41
+ test:rubocop:
42
+ extends: .default-test-job
52
43
  script:
53
- - bundle exec rufo --check .
54
- parallel:
55
- matrix:
56
- - RUBY_VERSION: ['3.0', '3.1', '3.2']
44
+ - bundle exec rubocop -P -E .
57
45
 
58
46
  include:
47
+ - component: gitlab.com/components/sast/sast@~latest
48
+ - component: gitlab.com/components/secret-detection/secret-detection@~latest
49
+ - component: gitlab.com/gitlab-org/components/gem-release/gem-release@~latest
50
+ inputs:
51
+ smoke_test_script: "ruby -r 'gitlab-dangerfiles' -e \"puts Gitlab::Dangerfiles::VERSION\""
52
+ - component: gitlab.com/gitlab-org/components/danger-review/danger-review@~latest
53
+ inputs:
54
+ dry_run: true
59
55
  - template: Security/Dependency-Scanning.gitlab-ci.yml
60
- - template: Security/License-Scanning.gitlab-ci.yml
61
- - template: Security/SAST.gitlab-ci.yml
62
- - template: Security/Secret-Detection.gitlab-ci.yml
63
- - project: 'gitlab-org/quality/pipeline-common'
64
- file:
65
- - '/ci/danger-review.yml'
66
- - '/ci/gem-release.yml'
67
56
 
68
57
  # run security jobs on MRs
69
58
  # see: https://gitlab.com/gitlab-org/gitlab/-/issues/218444#note_478761991
70
59
 
71
- brakeman-sast:
72
- rules:
73
- - if: '$CI_MERGE_REQUEST_IID'
74
- - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
75
-
76
60
  gemnasium-dependency_scanning:
77
61
  rules:
78
62
  - if: '$CI_MERGE_REQUEST_IID'
79
63
  - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
80
64
 
81
- license_scanning:
82
- rules:
83
- - if: '$CI_MERGE_REQUEST_IID'
84
- - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
85
-
86
65
  secret_detection:
87
66
  rules:
88
67
  - if: '$CI_MERGE_REQUEST_IID'
data/.rubocop.yml CHANGED
@@ -25,27 +25,17 @@ RSpec/MultipleMemoizedHelpers:
25
25
  RSpec/FilePath:
26
26
  Enabled: false
27
27
 
28
+ RSpec/SpecFilePathFormat:
29
+ Enabled: false
30
+
31
+ Style/ArrayIntersect:
32
+ Enabled: false # We're still supporting Ruby 3.1 and below
33
+
28
34
  Style/HashSyntax:
29
35
  EnforcedStyle: ruby19_no_mixed_keys
30
36
  # Introduced in Ruby 3.1. Disable for now.
31
37
  EnforcedShorthandSyntax: never
32
38
 
33
- # To respect rufo formatting
34
- Style/StringLiterals:
35
- EnforcedStyle: double_quotes
36
-
37
- # To respect rufo formatting
38
- Style/TrailingCommaInHashLiteral:
39
- EnforcedStyleForMultiline: consistent_comma
40
-
41
- # To respect rufo formatting
42
- Style/TrailingCommaInArguments:
43
- Enabled: false
44
-
45
- # To respect rufo formatting
46
- Layout/MultilineOperationIndentation:
47
- Enabled: false
48
-
49
39
  # Was problematic, and not included in the .rubocop_todo.yml
50
40
  GitlabSecurity/PublicSend:
51
41
  Enabled: false
data/.rubocop_todo.yml CHANGED
@@ -126,11 +126,6 @@ Lint/IdentityComparison:
126
126
  - 'spec/gitlab/dangerfiles/weightage/maintainers_spec.rb'
127
127
  - 'spec/gitlab/dangerfiles/weightage/reviewers_spec.rb'
128
128
 
129
- # Offense count: 1
130
- Lint/NonLocalExitFromIterator:
131
- Exclude:
132
- - 'lib/danger/rules/subtype_label/Dangerfile'
133
-
134
129
  # Offense count: 1
135
130
  # This cop supports safe autocorrection (--autocorrect).
136
131
  Lint/RedundantCopDisableDirective:
@@ -310,7 +305,6 @@ Style/FrozenStringLiteralComment:
310
305
  # Configuration parameters: MinBodyLength, AllowConsecutiveConditionals.
311
306
  Style/GuardClause:
312
307
  Exclude:
313
- - 'lib/danger/rules/subtype_label/Dangerfile'
314
308
  - 'lib/danger/rules/type_label/Dangerfile'
315
309
 
316
310
  # Offense count: 2
@@ -384,7 +378,6 @@ Style/PercentLiteralDelimiters:
384
378
  - 'Guardfile'
385
379
  - 'gitlab-dangerfiles.gemspec'
386
380
  - 'lib/danger/plugins/internal/helper.rb'
387
- - 'lib/danger/rules/subtype_label/Dangerfile'
388
381
  - 'lib/gitlab/dangerfiles/tasks/main.rake'
389
382
  - 'spec/danger/plugins/internal/helper_spec.rb'
390
383
 
@@ -471,7 +464,6 @@ Style/SelectByRegexp:
471
464
  # SupportedStyles: only_raise, only_fail, semantic
472
465
  Style/SignalException:
473
466
  Exclude:
474
- - 'lib/danger/rules/subtype_label/Dangerfile'
475
467
  - 'lib/danger/rules/type_label/Dangerfile'
476
468
 
477
469
  # Offense count: 7
@@ -527,3 +519,8 @@ Style/TrailingCommaInArrayLiteral:
527
519
  - 'spec/gitlab/dangerfiles/title_linting_spec.rb'
528
520
  - 'spec/gitlab/dangerfiles/weightage/maintainers_spec.rb'
529
521
  - 'spec/gitlab/dangerfiles/weightage/reviewers_spec.rb'
522
+
523
+ Style/ArrayIntersect:
524
+ Exclude:
525
+ - 'lib/gitlab/dangerfiles/category.rb'
526
+ - 'lib/danger/plugins/changelog.rb'
data/Gemfile CHANGED
@@ -2,19 +2,3 @@ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in gitlab-dangerfiles.gemspec
4
4
  gemspec
5
-
6
- gem "rake", "~> 12.0"
7
- gem "guard-rspec"
8
- gem "yard"
9
-
10
- group :development do
11
- gem "lefthook", require: false
12
- end
13
-
14
- group :development, :test do
15
- gem "gitlab-styles", "~> 9.0.0", require: false
16
- end
17
-
18
- group :test do
19
- gem "pry-byebug", "~> 3.8", require: false
20
- end
data/Gemfile.lock ADDED
@@ -0,0 +1,234 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ gitlab-dangerfiles (4.10.0)
5
+ danger (>= 9.3.0)
6
+ danger-gitlab (>= 8.0.0)
7
+ rake (~> 13.0)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ activesupport (7.0.4.2)
13
+ concurrent-ruby (~> 1.0, >= 1.0.2)
14
+ i18n (>= 1.6, < 2)
15
+ minitest (>= 5.1)
16
+ tzinfo (~> 2.0)
17
+ addressable (2.8.1)
18
+ public_suffix (>= 2.0.2, < 6.0)
19
+ ast (2.4.2)
20
+ binding_of_caller (1.0.0)
21
+ debug_inspector (>= 0.0.1)
22
+ claide (1.1.0)
23
+ claide-plugins (0.9.2)
24
+ cork
25
+ nap
26
+ open4 (~> 1.3)
27
+ climate_control (1.2.0)
28
+ coderay (1.1.3)
29
+ colored2 (3.1.2)
30
+ concurrent-ruby (1.2.0)
31
+ cork (0.3.0)
32
+ colored2 (~> 3.1)
33
+ crack (0.4.5)
34
+ rexml
35
+ danger (9.3.0)
36
+ claide (~> 1.0)
37
+ claide-plugins (>= 0.9.2)
38
+ colored2 (~> 3.1)
39
+ cork (~> 0.1)
40
+ faraday (>= 0.9.0, < 3.0)
41
+ faraday-http-cache (~> 2.0)
42
+ git (~> 1.13.0)
43
+ kramdown (~> 2.3)
44
+ kramdown-parser-gfm (~> 1.0)
45
+ no_proxy_fix
46
+ octokit (~> 5.0)
47
+ terminal-table (>= 1, < 4)
48
+ danger-gitlab (8.0.0)
49
+ danger
50
+ gitlab (~> 4.2, >= 4.2.0)
51
+ debug_inspector (1.1.0)
52
+ diff-lcs (1.5.0)
53
+ faraday (2.7.10)
54
+ faraday-net_http (>= 2.0, < 3.1)
55
+ ruby2_keywords (>= 0.0.4)
56
+ faraday-http-cache (2.5.0)
57
+ faraday (>= 0.8)
58
+ faraday-net_http (3.0.2)
59
+ ffi (1.15.5)
60
+ formatador (1.1.0)
61
+ git (1.13.2)
62
+ addressable (~> 2.8)
63
+ rchardet (~> 1.8)
64
+ gitlab (4.19.0)
65
+ httparty (~> 0.20)
66
+ terminal-table (>= 1.5.1)
67
+ gitlab-styles (10.0.0)
68
+ rubocop (~> 1.43.0)
69
+ rubocop-graphql (~> 0.18)
70
+ rubocop-performance (~> 1.15)
71
+ rubocop-rails (~> 2.17)
72
+ rubocop-rspec (~> 2.18)
73
+ guard (2.18.0)
74
+ formatador (>= 0.2.4)
75
+ listen (>= 2.7, < 4.0)
76
+ lumberjack (>= 1.0.12, < 2.0)
77
+ nenv (~> 0.1)
78
+ notiffany (~> 0.0)
79
+ pry (>= 0.13.0)
80
+ shellany (~> 0.0)
81
+ thor (>= 0.18.1)
82
+ guard-compat (1.2.1)
83
+ guard-rspec (4.7.3)
84
+ guard (~> 2.1)
85
+ guard-compat (~> 1.1)
86
+ rspec (>= 2.99.0, < 4.0)
87
+ hashdiff (1.0.1)
88
+ httparty (0.21.0)
89
+ mini_mime (>= 1.0.0)
90
+ multi_xml (>= 0.5.2)
91
+ i18n (1.12.0)
92
+ concurrent-ruby (~> 1.0)
93
+ json (2.6.3)
94
+ kramdown (2.4.0)
95
+ rexml
96
+ kramdown-parser-gfm (1.1.0)
97
+ kramdown (~> 2.0)
98
+ lefthook (1.5.2)
99
+ listen (3.8.0)
100
+ rb-fsevent (~> 0.10, >= 0.10.3)
101
+ rb-inotify (~> 0.9, >= 0.9.10)
102
+ lumberjack (1.2.8)
103
+ method_source (1.0.0)
104
+ mini_mime (1.1.2)
105
+ minitest (5.17.0)
106
+ multi_xml (0.6.0)
107
+ nap (1.1.0)
108
+ nenv (0.3.0)
109
+ no_proxy_fix (0.1.2)
110
+ notiffany (0.1.3)
111
+ nenv (~> 0.1)
112
+ shellany (~> 0.0)
113
+ octokit (5.6.1)
114
+ faraday (>= 1, < 3)
115
+ sawyer (~> 0.9)
116
+ open4 (1.3.4)
117
+ parallel (1.22.1)
118
+ parser (3.2.1.0)
119
+ ast (~> 2.4.1)
120
+ racc
121
+ proc_to_ast (0.1.0)
122
+ coderay
123
+ parser
124
+ unparser
125
+ pry (0.14.2)
126
+ coderay (~> 1.1)
127
+ method_source (~> 1.0)
128
+ public_suffix (5.0.1)
129
+ racc (1.8.1)
130
+ rack (3.0.4.1)
131
+ rainbow (3.1.1)
132
+ rake (13.0.6)
133
+ rb-fsevent (0.11.2)
134
+ rb-inotify (0.10.1)
135
+ ffi (~> 1.0)
136
+ rchardet (1.8.0)
137
+ regexp_parser (2.7.0)
138
+ rexml (3.2.5)
139
+ rspec (3.12.0)
140
+ rspec-core (~> 3.12.0)
141
+ rspec-expectations (~> 3.12.0)
142
+ rspec-mocks (~> 3.12.0)
143
+ rspec-core (3.12.1)
144
+ rspec-support (~> 3.12.0)
145
+ rspec-expectations (3.12.2)
146
+ diff-lcs (>= 1.2.0, < 2.0)
147
+ rspec-support (~> 3.12.0)
148
+ rspec-mocks (3.12.3)
149
+ diff-lcs (>= 1.2.0, < 2.0)
150
+ rspec-support (~> 3.12.0)
151
+ rspec-parameterized (1.0.0)
152
+ rspec-parameterized-core (< 2)
153
+ rspec-parameterized-table_syntax (< 2)
154
+ rspec-parameterized-core (1.0.0)
155
+ parser
156
+ proc_to_ast
157
+ rspec (>= 2.13, < 4)
158
+ unparser
159
+ rspec-parameterized-table_syntax (1.0.0)
160
+ binding_of_caller
161
+ rspec-parameterized-core (< 2)
162
+ rspec-support (3.12.0)
163
+ rubocop (1.43.0)
164
+ json (~> 2.3)
165
+ parallel (~> 1.10)
166
+ parser (>= 3.2.0.0)
167
+ rainbow (>= 2.2.2, < 4.0)
168
+ regexp_parser (>= 1.8, < 3.0)
169
+ rexml (>= 3.2.5, < 4.0)
170
+ rubocop-ast (>= 1.24.1, < 2.0)
171
+ ruby-progressbar (~> 1.7)
172
+ unicode-display_width (>= 2.4.0, < 3.0)
173
+ rubocop-ast (1.26.0)
174
+ parser (>= 3.2.1.0)
175
+ rubocop-capybara (2.19.0)
176
+ rubocop (~> 1.41)
177
+ rubocop-factory_bot (2.24.0)
178
+ rubocop (~> 1.33)
179
+ rubocop-graphql (0.19.0)
180
+ rubocop (>= 0.87, < 2)
181
+ rubocop-performance (1.19.1)
182
+ rubocop (>= 1.7.0, < 2.0)
183
+ rubocop-ast (>= 0.4.0)
184
+ rubocop-rails (2.17.4)
185
+ activesupport (>= 4.2.0)
186
+ rack (>= 1.1)
187
+ rubocop (>= 1.33.0, < 2.0)
188
+ rubocop-rspec (2.24.1)
189
+ rubocop (~> 1.33)
190
+ rubocop-capybara (~> 2.17)
191
+ rubocop-factory_bot (~> 2.22)
192
+ ruby-progressbar (1.11.0)
193
+ ruby2_keywords (0.0.5)
194
+ sawyer (0.9.2)
195
+ addressable (>= 2.3.5)
196
+ faraday (>= 0.17.3, < 3)
197
+ shellany (0.0.1)
198
+ terminal-table (3.0.2)
199
+ unicode-display_width (>= 1.1.1, < 3)
200
+ thor (1.2.1)
201
+ timecop (0.9.6)
202
+ tzinfo (2.0.6)
203
+ concurrent-ruby (~> 1.0)
204
+ unicode-display_width (2.4.2)
205
+ unparser (0.6.7)
206
+ diff-lcs (~> 1.3)
207
+ parser (>= 3.2.0)
208
+ webmock (3.18.1)
209
+ addressable (>= 2.8.0)
210
+ crack (>= 0.3.2)
211
+ hashdiff (>= 0.4.0, < 2.0.0)
212
+ webrick (1.7.0)
213
+ yard (0.9.28)
214
+ webrick (~> 1.7.0)
215
+
216
+ PLATFORMS
217
+ ruby
218
+
219
+ DEPENDENCIES
220
+ climate_control
221
+ gitlab-dangerfiles!
222
+ gitlab-styles (~> 10.0)
223
+ guard-rspec (~> 4.7.3)
224
+ lefthook (~> 1.3)
225
+ racc (~> 1.8)
226
+ rspec (~> 3.8)
227
+ rspec-parameterized
228
+ rubocop-rails (< 2.21.2)
229
+ timecop
230
+ webmock
231
+ yard
232
+
233
+ BUNDLED WITH
234
+ 2.5.4
data/README.md CHANGED
@@ -69,6 +69,52 @@ end
69
69
 
70
70
  Note that your custom plugins and rules (unless you exclude them with `except`) are automatically imported by the gem.
71
71
 
72
+ ### Import and load order
73
+
74
+ Plugins are imported in alphabetical order. Gem plugins are loaded before
75
+ project-local plugins.
76
+
77
+ Gem and project-local rules are combined, filtered, and loaded in alphabetical order.
78
+
79
+ Because all rules are executed as soon as they are imported, you should move all
80
+ logic from your root `Dangerfile` to project-local rules in
81
+ `danger/*/Dangerfile`.
82
+
83
+ For example:
84
+
85
+ **Bad**
86
+
87
+ `Dangerfile`:
88
+
89
+ ```ruby
90
+ Gitlab::Dangerfiles.for_project(self) do |dangerfiles|
91
+ dangerfiles.import_dangerfiles(only: %w[z_add_labels])
92
+ end
93
+
94
+ # Bad, because gem rule `z_add_labels` has already been executed with empty labels list.
95
+ helper.labels_to_add << 'important'
96
+ ```
97
+
98
+ **Good**
99
+
100
+ `Dangerfile`:
101
+
102
+ ```ruby
103
+ Gitlab::Dangerfiles.for_project(self) do |dangerfiles|
104
+ dangerfiles.import_dangerfiles(only: %w[z_add_labels])
105
+ end
106
+ ```
107
+
108
+ `danger/labels/Dangerfile`:
109
+
110
+ ```ruby
111
+ # Good. Execution order:
112
+ # * root `Dangerfile`
113
+ # * project-local `danger/my_labels/Dangerfile`
114
+ # * gem rule `danger/z_add_labels/Dangerfile`
115
+ helper.labels_to_add << 'important'
116
+ ```
117
+
72
118
  ### Plugins
73
119
 
74
120
  Danger plugins are located under `lib/danger/plugins`.
@@ -125,6 +171,15 @@ This rule ensures the merge request isn't too big to be reviewed, otherwise it s
125
171
 
126
172
  This rule posts a failure if the merge request has more than 20 commits.
127
173
 
174
+ #### `danger_code_review`
175
+
176
+ This rule posts a warning/failure when `@GitLabDuo` isn't assigned as a reviewer.
177
+
178
+ ##### Available configurations
179
+
180
+ - `duo_code_review`: Whether a review from GitLab Duo Code is `:mandatory` or `:optional`.
181
+ Default to `:optional`.
182
+
128
183
  #### `metadata`
129
184
 
130
185
  This rule ensures basic metadata such as assignee, milestone and description are set on the merge request.
@@ -147,20 +202,42 @@ project. To use it in your project, perform the following steps:
147
202
  dangerfiles.import_dangerfiles(only: %w[simple_roulette])
148
203
  end
149
204
  ```
205
+
206
+ ##### Auto-assignment
150
207
 
151
- #### `subtype_label`
208
+ By default, the simple roulette only suggests reviewers in a comment. You can, optionally, configure it to automatically assign reviewers from the roulette to your merge requests.
152
209
 
153
- This rule warns when the merge request is missing a [subtype label](https://about.gitlab.com/handbook/engineering/metrics/#work-type-classification).
210
+ Configure `auto_assign_for_roulette_roles` to specify which roles to assign (`:reviewer`, `:maintainer`, or both). If empty (default), no auto-assignment occurs.
154
211
 
155
- If the `DANGER_ERROR_WHEN_SUBTYPE_LABEL_IS_MISSING` environment variable evaluates to `true`, Danger will error instead of warning when a subtype label is missing.
212
+ Optionally, configure `auto_assign_for_roulette_labels` to only auto-assign for Merge Requests with specific labels. If empty (default), auto-assignment applies to all MRs.
156
213
 
157
- #### `type_label`
214
+ ###### Examples
158
215
 
159
- This rule warns when the merge request is missing a [type label](https://about.gitlab.com/handbook/engineering/metrics/#work-type-classification).
216
+ ``` ruby
217
+ # Auto-assign reviewers for all MRs
218
+ helper.config.auto_assign_for_roulette_roles = [:reviewer]
160
219
 
161
- If the `DANGER_ERROR_WHEN_TYPE_LABEL_IS_MISSING` environment variable evaluates to `true`, Danger will error instead of warning when a type label is missing.
220
+ # Auto-assign both reviewer and maintainer for all MRs
221
+ helper.config.auto_assign_for_roulette_roles = [:reviewer, :maintainer]
162
222
 
163
- If the `changelog` plugin is available, it also tries to infer a type label from the `Changelog` trailer of the MR.
223
+ # Auto-assign reviewers only for a specific MR label
224
+ helper.config.auto_assign_for_roulette_roles = [:reviewer]
225
+ helper.config.auto_assign_for_roulette_labels = ["maintenance::dependency"]
226
+ ```
227
+
228
+ ##### Available configurations
229
+
230
+ Note: These options aren't actually used in the `simple_roulette` rule, but can be used in your own
231
+ implementation of the roulette if you use `roulette.required_approvals`/`roulette.codeowners_approvals`.
232
+
233
+ - `included_optional_codeowners_sections_for_roulette`: Indicates which optional codeowners sections
234
+ should be included in roulette. Default to `[]`.
235
+ - `excluded_required_codeowners_sections_for_roulette`: Indicates which required codeowners sections
236
+ should be excluded from roulette. Default to `[]`.
237
+
238
+ #### `type_label`
239
+
240
+ If the `changelog` plugin is available, it tries to infer a type label from the `Changelog` trailer of the MR.
164
241
 
165
242
  #### `z_add_labels`
166
243
 
@@ -245,6 +322,16 @@ To run the Danger Rake task in a project that doesn't have `master` as the defau
245
322
  DANGER_LOCAL_BASE="origin/main" bundle exec rake danger_local
246
323
  ```
247
324
 
325
+ ## Warnings vs Errors
326
+
327
+ The following lint violations generate warnings:
328
+
329
+ 1. The commit subject is too short ([code](https://gitlab.com/gitlab-org/ruby/gems/gitlab-dangerfiles/blob/bccb167/lib/gitlab/dangerfiles/base_linter.rb#L74-76)).
330
+ 1. The commit changes too many lines across too many files without describing the changes in the commit body ([code](https://gitlab.com/gitlab-org/ruby/gems/gitlab-dangerfiles/blob/bccb167/lib/gitlab/dangerfiles/commit_linter.rb#L83-85)).
331
+ 1. The commit body contains too many characters per line ([code](https://gitlab.com/gitlab-org/ruby/gems/gitlab-dangerfiles/blob/bccb167/lib/gitlab/dangerfiles/commit_linter.rb#L87-96)).
332
+
333
+ All other lint violations generate errors, except when the MR has [Squash commits when merge request is accepted](https://docs.gitlab.com/ee/user/project/merge_requests/squash_and_merge.html#squash-commits-in-a-merge-request) enabled, which downgrades lint violations to warnings.
334
+
248
335
  ## Documentation
249
336
 
250
337
  Latest documentation can be found at <https://www.rubydoc.info/gems/gitlab-dangerfiles>.
@@ -271,8 +358,8 @@ For example, to test `gitlab-dangerfiles` changes from the `your-branch-name` br
271
358
 
272
359
  ```ruby
273
360
  group :development, :test, :danger do
274
- gem 'gitlab-dangerfiles', '~> 3.4.3', require: false,
275
- git: 'https://gitlab.com/gitlab-org/ruby/gems/gitlab-dangerfiles.git',
361
+ gem 'gitlab-dangerfiles', require: false, feature_category: :tooling,
362
+ git: 'https://gitlab.com/gitlab-org/ruby/gems/gitlab-dangerfiles.git', # rubocop:disable Cop/GemFetcher -- Testing unreleased changes
276
363
  ref: 'your-branch-name'
277
364
  end
278
365
  ```
@@ -27,14 +27,22 @@ Gem::Specification.new do |spec|
27
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ["lib"]
29
29
 
30
- spec.add_dependency "rake", ">= 0"
30
+ spec.add_dependency "rake", "~> 13.0"
31
31
  spec.add_dependency "danger-gitlab", ">= 8.0.0"
32
- spec.add_dependency "danger", ">= 8.4.5"
32
+ spec.add_dependency "danger", ">= 9.3.0"
33
33
 
34
- spec.add_development_dependency "rspec", "~> 3.0"
34
+ spec.add_development_dependency "climate_control"
35
+ spec.add_development_dependency "gitlab-styles", "~> 10.0"
36
+ spec.add_development_dependency "guard-rspec", "~> 4.7.3"
37
+ spec.add_development_dependency "lefthook", "~> 1.3"
35
38
  spec.add_development_dependency "rspec-parameterized"
39
+ spec.add_development_dependency "rspec", "~> 3.8"
40
+ spec.add_development_dependency "racc", "~> 1.8"
41
+ # we do not commit the bundle lockfile, so this temporary workaround needs to be
42
+ # present until 2.21.3 or 2.22.x is released
43
+ # See https://gitlab.com/gitlab-org/ruby/gems/gitlab-styles/-/issues/63
44
+ spec.add_development_dependency "rubocop-rails", "< 2.21.2"
36
45
  spec.add_development_dependency "timecop"
37
46
  spec.add_development_dependency "webmock"
38
- spec.add_development_dependency "climate_control"
39
- spec.add_development_dependency "rufo"
47
+ spec.add_development_dependency "yard"
40
48
  end
data/lefthook.yml CHANGED
@@ -12,8 +12,3 @@ pre-push:
12
12
  rubocop:
13
13
  run: bundle exec rubocop
14
14
  glob: '*.rb'
15
-
16
- # Ruby formatting checks
17
- rufo:
18
- run: bundle exec rufo --check .
19
- glob: '*.rb'