gitlab-dangerfiles 3.8.0 → 3.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.
- checksums.yaml +4 -4
- data/README.md +32 -13
- data/lib/danger/plugins/internal/helper.rb +15 -4
- data/lib/danger/plugins/roulette.rb +14 -9
- data/lib/danger/rules/changes_size/Dangerfile +2 -0
- data/lib/danger/rules/metadata/Dangerfile +0 -4
- data/lib/danger/rules/simple_roulette/Dangerfile +4 -4
- data/lib/gitlab/dangerfiles/category.rb +6 -6
- data/lib/gitlab/dangerfiles/teammate.rb +4 -4
- data/lib/gitlab/dangerfiles/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ad2ad158af390c0b6b52fdd86927b4dd0a6118b7b2eca3ad60aaa88ac40b840a
|
4
|
+
data.tar.gz: 2872e01e85bf7190e2a3fd4cab71868f2e4924234443797e7479a3ab03497120
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7dccc5481318999e83be3a9535983ebbf69d731d5394cf66543df0fd77bf7e274d1b012255c9582a503caae5248956aa2441af1b9ad6ffddf6c5bc2bc730013b
|
7
|
+
data.tar.gz: 5d217f45be9fb3c68032bbffd9a7eee4eb4cdb4056200c8dabdaf8255aa084a28ff3cd3ac74a5fa2588634607c4a5d23ffc6d58cc709e9343296112b6b3457b3
|
data/README.md
CHANGED
@@ -218,17 +218,32 @@ danger-review:
|
|
218
218
|
- bundle add gitlab-dangerfiles --version 3.1.0
|
219
219
|
```
|
220
220
|
|
221
|
-
## Rake
|
221
|
+
## Local Danger Rake task
|
222
222
|
|
223
|
-
You can
|
223
|
+
You can run a Danger Rake task locally in a project to detect Danger errors before pushing commits to a remote
|
224
|
+
branch.
|
224
225
|
|
225
|
-
|
226
|
-
|
226
|
+
1. [Install `gitlab-dangerfiles`](#installation) in your project.
|
227
|
+
1. Add the following to your project's `Rakefile`:
|
228
|
+
|
229
|
+
```ruby
|
230
|
+
require 'gitlab-dangerfiles'
|
231
|
+
|
232
|
+
Gitlab::Dangerfiles.load_tasks
|
233
|
+
```
|
234
|
+
|
235
|
+
To run the Danger Rake task in a project that has `master` as the default branch, run:
|
227
236
|
|
228
|
-
|
237
|
+
```shell
|
238
|
+
bundle exec rake danger_local
|
229
239
|
```
|
230
240
|
|
231
|
-
|
241
|
+
To run the Danger Rake task in a project that doesn't have `master` as the default branch, you must set the
|
242
|
+
`DANGER_LOCAL_BASE` environment variable. For example, in a project with `main` as the default branch:
|
243
|
+
|
244
|
+
```shell
|
245
|
+
DANGER_LOCAL_BASE="origin/main" bundle exec rake danger_local
|
246
|
+
```
|
232
247
|
|
233
248
|
## Documentation
|
234
249
|
|
@@ -264,6 +279,12 @@ end
|
|
264
279
|
|
265
280
|
See an [example](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/92580) for more details.
|
266
281
|
|
282
|
+
## Contributing
|
283
|
+
|
284
|
+
Bug reports and merge requests are welcome at https://gitlab.com/gitlab-org/gitlab-dangerfiles. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://gitlab.com/gitlab-org/gitlab-dangerfiles/blob/master/CODE_OF_CONDUCT.md).
|
285
|
+
|
286
|
+
Make sure to include a changelog entry in your commit message and read the [changelog entries section](https://docs.gitlab.com/ee/development/changelog.html).
|
287
|
+
|
267
288
|
## Release
|
268
289
|
|
269
290
|
[Automated gem release process](https://gitlab.com/gitlab-org/quality/pipeline-common#release-process) is used to release new version of `gitlab-dangerfiles` through [pipelines](https://gitlab.com/gitlab-org/ruby/gems/gitlab-dangerfiles/-/blob/4f33cf30cab84f7e27ca0cb9a7c0da3ecc675c11/.gitlab-ci.yml#L51), and this will:
|
@@ -272,24 +293,22 @@ See an [example](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/92580) fo
|
|
272
293
|
- Add a release in the `gitlab-dangerfiles` project: https://gitlab.com/gitlab-org/ruby/gems/gitlab-dangerfiles/-/releases
|
273
294
|
- Populate the release log with the API contents. For example: https://gitlab.com/api/v4/projects/19861191/repository/changelog?version=3.4.4
|
274
295
|
|
296
|
+
We follow this release process in a separate merge request from the one that introduced the changes. The release merge request should just contain a version bump.
|
297
|
+
|
275
298
|
### Before release
|
276
299
|
|
277
|
-
|
300
|
+
Changes merged since the last release should have had changelog entries (see [Contributing](#contributing)).
|
278
301
|
|
279
|
-
If
|
302
|
+
If changelog entries are missing, you can also edit the release notes after it's being released.
|
280
303
|
|
281
304
|
### Steps to release
|
282
305
|
|
283
|
-
Use a `Release` merge request template and create a merge
|
306
|
+
Use a `Release` merge request template and create a merge request to update the version number in `version.rb`, and get the merge request merged by a maintainer.
|
284
307
|
|
285
308
|
This will then be packaged into a gem and pushed to [rubygems.org](https://rubygems.org) by the CI/CD.
|
286
309
|
|
287
310
|
For example: [Bump version to 3.4.3](https://gitlab.com/gitlab-org/ruby/gems/gitlab-dangerfiles/-/merge_requests/149).
|
288
311
|
|
289
|
-
## Contributing
|
290
|
-
|
291
|
-
Bug reports and merge requests are welcome at https://gitlab.com/gitlab-org/gitlab-dangerfiles. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://gitlab.com/gitlab-org/gitlab-dangerfiles/blob/master/CODE_OF_CONDUCT.md).
|
292
|
-
|
293
312
|
## License
|
294
313
|
|
295
314
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -25,9 +25,9 @@ module Danger
|
|
25
25
|
engineering_productivity: '~"Engineering Productivity" for CI, Danger',
|
26
26
|
tooling: '~"maintenance::workflow" / ~"maintenance::pipelines" for CI, Danger',
|
27
27
|
ci_template: '~"ci::templates"',
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
analytics_instrumentation: '~"analytics instrumentation"',
|
29
|
+
import_integrate_be: '~"group::import and integrate" (backend)',
|
30
|
+
import_integrate_fe: '~"group::import and integrate" (frontend)',
|
31
31
|
"Authentication and Authorization": '~"group::authentication and authorization"',
|
32
32
|
Compliance: '~"group::compliance"',
|
33
33
|
}.freeze
|
@@ -35,6 +35,8 @@ module Danger
|
|
35
35
|
|
36
36
|
GITLAB_ORG_GROUP_ID = "9970"
|
37
37
|
|
38
|
+
STABLE_BRANCH_REGEX = %r{\A(?<version>\d+-\d+)-stable-ee\z}
|
39
|
+
|
38
40
|
# Allows to set specific rule's configuration by passing a block.
|
39
41
|
#
|
40
42
|
# @yield [c] Yield a Gitlab::Dangerfiles::Config object
|
@@ -369,6 +371,10 @@ module Danger
|
|
369
371
|
mr_web_url.include?("/gitlab-org/security/")
|
370
372
|
end
|
371
373
|
|
374
|
+
def stable_branch_mr?
|
375
|
+
!!mr_target_branch.match(STABLE_BRANCH_REGEX) && !security_mr?
|
376
|
+
end
|
377
|
+
|
372
378
|
# @return [Boolean] whether a MR title includes "cherry-pick" or not.
|
373
379
|
def cherry_pick_mr?
|
374
380
|
Gitlab::Dangerfiles::TitleLinting.has_cherry_pick_flag?(mr_title)
|
@@ -449,11 +455,16 @@ module Danger
|
|
449
455
|
all_changed_files.grep(regex)
|
450
456
|
end
|
451
457
|
|
452
|
-
# @return [
|
458
|
+
# @return [String] the group label (i.e. +"group::*"+) set on the MR.
|
453
459
|
def group_label
|
454
460
|
mr_labels.find { |label| label.start_with?("group::") }
|
455
461
|
end
|
456
462
|
|
463
|
+
# @return [String] the stage label (i.e. +"devops::*"+) set on the MR.
|
464
|
+
def stage_label
|
465
|
+
mr_labels.find { |label| label.start_with?("devops::") }
|
466
|
+
end
|
467
|
+
|
457
468
|
# Accessor for storing labels to add so that other rules can check if labels will be added after Danger
|
458
469
|
# has evaluated all the rules.
|
459
470
|
# For instance, a rule might require a specific label to be set, but another rule could add this label
|
@@ -52,7 +52,7 @@ module Danger
|
|
52
52
|
def spin(project = nil, categories = [:none], timezone_experiment: false)
|
53
53
|
project = (project || config_project_name).downcase
|
54
54
|
categories = categories.map { |category| category&.downcase || :none }
|
55
|
-
categories.reject! { |category|
|
55
|
+
categories.reject! { |category| import_and_integrate_reject_category?(category, project) }
|
56
56
|
|
57
57
|
spins = categories.sort_by(&:to_s).map do |category|
|
58
58
|
including_timezone = INCLUDE_TIMEZONE_FOR_CATEGORY.fetch(category, timezone_experiment)
|
@@ -89,14 +89,14 @@ module Danger
|
|
89
89
|
# Fetch an already picked backend maintainer, or pick one otherwise
|
90
90
|
spin.maintainer = backend_spin&.maintainer || spin_for_category(project, :backend, timezone_experiment: including_timezone).maintainer
|
91
91
|
end
|
92
|
-
when :
|
92
|
+
when :analytics_instrumentation
|
93
93
|
spin.optional_role = :maintainer
|
94
94
|
|
95
95
|
if spin.maintainer.nil?
|
96
96
|
# Fetch an already picked maintainer, or pick one otherwise
|
97
97
|
spin.maintainer = backend_spin&.maintainer || frontend_spin&.maintainer || spin_for_category(project, :backend, timezone_experiment: including_timezone).maintainer
|
98
98
|
end
|
99
|
-
when :
|
99
|
+
when :import_integrate_be, :import_integrate_fe
|
100
100
|
spin.optional_role = :maintainer
|
101
101
|
when :ux
|
102
102
|
spin.optional_role = :maintainer
|
@@ -173,10 +173,10 @@ module Danger
|
|
173
173
|
|
174
174
|
# @param [String] category name
|
175
175
|
# @return [Boolean]
|
176
|
-
def
|
177
|
-
# Reject
|
178
|
-
team_mr_author&.
|
179
|
-
team_mr_author&.
|
176
|
+
def import_and_integrate_reject_category?(category, project)
|
177
|
+
# Reject Import and Integrate categories if the MR author has reviewing abilities for the category.
|
178
|
+
team_mr_author&.import_integrate_be?(project, category, helper.mr_labels) ||
|
179
|
+
team_mr_author&.import_integrate_fe?(project, category, helper.mr_labels)
|
180
180
|
end
|
181
181
|
|
182
182
|
def random
|
@@ -267,12 +267,17 @@ module Danger
|
|
267
267
|
rsp = Net::HTTP.get_response(URI.parse(url))
|
268
268
|
|
269
269
|
if rsp.is_a?(Net::HTTPRedirection)
|
270
|
-
|
270
|
+
if (uri = URI.parse(rsp.header["location"]))
|
271
|
+
uri.query = nil
|
272
|
+
end
|
273
|
+
|
274
|
+
warnings << "Redirection detected: #{uri}."
|
271
275
|
return nil
|
272
276
|
end
|
273
277
|
|
274
278
|
unless rsp.is_a?(Net::HTTPOK)
|
275
|
-
|
279
|
+
message = rsp.message[0, 30]
|
280
|
+
warnings << "HTTPError: Failed to read #{url}: #{rsp.code} #{message}."
|
276
281
|
return nil
|
277
282
|
end
|
278
283
|
|
@@ -5,7 +5,3 @@ fail("Merge request description is too short. Please provide a proper merge requ
|
|
5
5
|
warn("This merge request does not have any assignee yet. Setting an assignee clarifies who needs to take action on the merge request at any given time.") if helper.mr_assignees.empty?
|
6
6
|
|
7
7
|
warn("This merge request does not refer to an existing milestone.", sticky: false) if helper.mr_milestone.nil?
|
8
|
-
|
9
|
-
default_branch = ENV['CI_DEFAULT_BRANCH'] || 'main'
|
10
|
-
has_pick_into_stable_label = helper.mr_labels.find { |label| label.start_with?('Pick into') }
|
11
|
-
warn("Most of the time, merge requests should target `#{default_branch}`. Otherwise, please set the relevant `Pick into X.Y` label.") if helper.mr_target_branch != default_branch && !has_pick_into_stable_label && !helper.security_mr?
|
@@ -92,11 +92,11 @@ categories << :database if helper.mr_labels.include?('database')
|
|
92
92
|
# Ensure to spin for UX reviewer when ~UX is applied (e.g. to review changes to the UI) except when it's from wider community contribution where we want to assign from the corresponding group
|
93
93
|
categories << :ux if helper.mr_labels.include?('UX') && !helper.mr_labels.include?('Community contribution')
|
94
94
|
|
95
|
-
# Ensure to spin for
|
96
|
-
categories << :
|
95
|
+
# Ensure to spin for Analytics Instrumentation reviewer when ~"analytics instrumentation::review pending" is applied
|
96
|
+
categories << :analytics_instrumentation if helper.mr_labels.include?("analytics instrumentation::review pending")
|
97
97
|
|
98
|
-
# Skip
|
99
|
-
categories.delete(:
|
98
|
+
# Skip Analytics Instrumentation reviews for growth experiment MRs
|
99
|
+
categories.delete(:analytics_instrumentation) if helper.mr_labels.include?("growth experiment")
|
100
100
|
|
101
101
|
# Remove disabled categories
|
102
102
|
categories.subtract(helper.config.disabled_roulette_categories)
|
@@ -14,8 +14,8 @@ module Gitlab
|
|
14
14
|
none: None,
|
15
15
|
test: Test,
|
16
16
|
tooling: Tooling,
|
17
|
-
|
18
|
-
|
17
|
+
import_integrate_be: ImportIntegrateBE,
|
18
|
+
import_integrate_fe: ImportIntegrateFE,
|
19
19
|
ux: UX,
|
20
20
|
}.freeze
|
21
21
|
end
|
@@ -71,21 +71,21 @@ module Gitlab
|
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
-
class
|
74
|
+
class ImportIntegrateBE < Category
|
75
75
|
private
|
76
76
|
|
77
77
|
def has_particular_capability?(teammate)
|
78
78
|
kind == :reviewer &&
|
79
|
-
teammate.role.match?(/Backend Engineer.+Manage:
|
79
|
+
teammate.role.match?(/Backend Engineer.+Manage:Import and Integrate/)
|
80
80
|
end
|
81
81
|
end
|
82
82
|
|
83
|
-
class
|
83
|
+
class ImportIntegrateFE < Category
|
84
84
|
private
|
85
85
|
|
86
86
|
def has_particular_capability?(teammate)
|
87
87
|
kind == :reviewer &&
|
88
|
-
teammate.role.match?(/Frontend Engineer.+Manage:
|
88
|
+
teammate.role.match?(/Frontend Engineer.+Manage:Import and Integrate/)
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
@@ -55,14 +55,14 @@ module Gitlab
|
|
55
55
|
has_capability?(project, category, :maintainer, labels)
|
56
56
|
end
|
57
57
|
|
58
|
-
def
|
59
|
-
return false unless category == :
|
58
|
+
def import_integrate_be?(project, category, labels)
|
59
|
+
return false unless category == :import_integrate_be
|
60
60
|
|
61
61
|
has_capability?(project, category, :reviewer, labels)
|
62
62
|
end
|
63
63
|
|
64
|
-
def
|
65
|
-
return false unless category == :
|
64
|
+
def import_integrate_fe?(project, category, labels)
|
65
|
+
return false unless category == :import_integrate_fe
|
66
66
|
|
67
67
|
has_capability?(project, category, :reviewer, labels)
|
68
68
|
end
|
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.
|
4
|
+
version: 3.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GitLab
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|