gitlab-dangerfiles 4.7.0 → 4.8.0

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: a3462c1433faf49899f1472e4411ce488ada1b6f59da331ede45114703fe2dfa
4
- data.tar.gz: 37b7134a0cec36afed2dc1a4d78321cf9c9a80a405c5551fe52b2ce4834fd312
3
+ metadata.gz: '0535903212a08369cccb1b24b1753e1cfa5a637b0827a706a8b37fd3e0fb0dc2'
4
+ data.tar.gz: c69bcd32f34546130f7b74ccb946be09e876a2820c53d7546b58d21ceed62f0b
5
5
  SHA512:
6
- metadata.gz: 9a7d44496574a8336bd42665f3c096e4b5c4bb7eeb322533b0b0a84d901d541104878fa13ab214a80fecea15c5c875ad4cb6f98d751b290b8f00108d2d837816
7
- data.tar.gz: c032a92c6fb18de185e1552faabc9b648573ff95ee1d0b5e88fe3f57c7668e502d251cb51f2bd9e4b36d555c147cb9f538f6904223546b3e4fbbb5591d9826b5
6
+ metadata.gz: 84e215eee590bde5eb47905ffbf44a14763964695e3d80637d5f8483337f1f792dd7dfee1f5ae0baeb734c85967f47060005a0a6a052e3b1ebf4c53c55243756
7
+ data.tar.gz: 57657967dcbce6d66f68780c04d57b39601160d26e07f20f4b529a083cfdeb7c71f9f20286f6724ad2a15610fa2793850900959d6961c3b5ece4c8f7d4725b67
data/.gitlab-ci.yml CHANGED
@@ -50,16 +50,13 @@ include:
50
50
  inputs:
51
51
  smoke_test_script: "ruby -r 'gitlab-dangerfiles' -e \"puts Gitlab::Dangerfiles::VERSION\""
52
52
  - component: gitlab.com/gitlab-org/components/danger-review/danger-review@~latest
53
+ inputs:
54
+ dry_run: true
53
55
  - template: Security/Dependency-Scanning.gitlab-ci.yml
54
56
 
55
57
  # run security jobs on MRs
56
58
  # see: https://gitlab.com/gitlab-org/gitlab/-/issues/218444#note_478761991
57
59
 
58
- brakeman-sast:
59
- rules:
60
- - if: '$CI_MERGE_REQUEST_IID'
61
- - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
62
-
63
60
  gemnasium-dependency_scanning:
64
61
  rules:
65
62
  - if: '$CI_MERGE_REQUEST_IID'
data/.rubocop.yml CHANGED
@@ -36,22 +36,6 @@ Style/HashSyntax:
36
36
  # Introduced in Ruby 3.1. Disable for now.
37
37
  EnforcedShorthandSyntax: never
38
38
 
39
- # To respect rufo formatting
40
- Style/StringLiterals:
41
- EnforcedStyle: double_quotes
42
-
43
- # To respect rufo formatting
44
- Style/TrailingCommaInHashLiteral:
45
- EnforcedStyleForMultiline: consistent_comma
46
-
47
- # To respect rufo formatting
48
- Style/TrailingCommaInArguments:
49
- Enabled: false
50
-
51
- # To respect rufo formatting
52
- Layout/MultilineOperationIndentation:
53
- Enabled: false
54
-
55
39
  # Was problematic, and not included in the .rubocop_todo.yml
56
40
  GitlabSecurity/PublicSend:
57
41
  Enabled: false
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gitlab-dangerfiles (4.7.0)
4
+ gitlab-dangerfiles (4.8.0)
5
5
  danger (>= 9.3.0)
6
6
  danger-gitlab (>= 8.0.0)
7
7
  rake (~> 13.0)
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'
@@ -23,7 +23,7 @@ module Danger
23
23
 
24
24
  OPTIONAL_CHANGELOG_MESSAGE = {
25
25
  local: "If this merge request [doesn't need a CHANGELOG entry](https://docs.gitlab.com/ee/development/changelog.html#what-warrants-a-changelog-entry), feel free to ignore this message.",
26
- ci: <<~MSG,
26
+ ci: <<~MSG
27
27
  If this merge request needs a changelog entry, add the `Changelog` trailer to the commit message you want to add to the changelog.
28
28
 
29
29
  If this merge request [doesn't need a CHANGELOG entry](https://docs.gitlab.com/ee/development/changelog.html#what-warrants-a-changelog-entry), feel free to ignore this message.
@@ -33,11 +33,11 @@ module Danger
33
33
 
34
34
  REQUIRED_CHANGELOG_REASONS = {
35
35
  db_changes: "introduces a database migration",
36
- feature_flag_removed: "removes a feature flag",
36
+ feature_flag_removed: "removes a feature flag"
37
37
  }.freeze
38
38
  REQUIRED_CHANGELOG_MESSAGE = {
39
39
  local: "This merge request requires a changelog entry because it [%<reason>s](https://docs.gitlab.com/ee/development/changelog.html#what-warrants-a-changelog-entry).",
40
- ci: <<~MSG,
40
+ ci: <<~MSG
41
41
  To create a changelog entry, add the `Changelog` trailer to one of your Git commit messages.
42
42
 
43
43
  This merge request requires a changelog entry because it [%<reason>s](https://docs.gitlab.com/ee/development/changelog.html#what-warrants-a-changelog-entry).
@@ -123,6 +123,10 @@ module Danger
123
123
 
124
124
  def revert_in_current_milestone?
125
125
  return false unless helper.revert_mr?
126
+ # In dry-run mode, without the API token, we are able to fetch the current milestone nor the labels.
127
+ # We simply assume that we are reverting in the current milestone.
128
+ return true unless helper.ci?
129
+ return false unless helper.current_milestone
126
130
 
127
131
  current_regression_label = "regression:#{helper.current_milestone.title}"
128
132
 
@@ -249,7 +253,7 @@ module Danger
249
253
  required_reasons.each_with_object({}) do |required_reason, memo|
250
254
  memo[required_reason] =
251
255
  CHANGELOG_MISSING_URL_TEXT +
252
- (helper.ci? ? format(REQUIRED_CHANGELOG_MESSAGE[:ci], reason: REQUIRED_CHANGELOG_REASONS.fetch(required_reason)) : REQUIRED_CHANGELOG_MESSAGE[:local])
256
+ format(REQUIRED_CHANGELOG_MESSAGE[helper.ci? ? :ci : :local], reason: REQUIRED_CHANGELOG_REASONS.fetch(required_reason))
253
257
  end
254
258
  end
255
259
 
@@ -29,7 +29,7 @@ module Danger
29
29
  import_integrate_fe: '~"group::import and integrate" (frontend)',
30
30
  Authentication: '~"group::authentication"',
31
31
  Authorization: '~"group::authorization"',
32
- Compliance: '~"group::compliance"',
32
+ Compliance: '~"group::compliance"'
33
33
  }.freeze
34
34
  # rubocop:enable Style/HashSyntax
35
35
 
@@ -345,11 +345,18 @@ module Danger
345
345
  )
346
346
  end
347
347
 
348
- # @return [Boolean] +false+ when not in the CI context, and returns +true+ if the MR title starts with Revert or revert
349
- def revert_mr?
350
- return false unless ci?
348
+ MR_REVERT_START_WITH = /[Rr]evert /
351
349
 
352
- mr_title.start_with?(/[Rr]evert/)
350
+ # When API token is available matches MR title to start with "Revert " or "revert ".
351
+ # Otherwise, matches if the single commit's message starts with "Revert " or "revert ".
352
+ #
353
+ # @return [Boolean] whether an MR is a revert
354
+ def revert_mr?
355
+ if ci?
356
+ mr_title.start_with?(MR_REVERT_START_WITH)
357
+ else
358
+ git.commits.size == 1 && git.commits.first.message.start_with?(MR_REVERT_START_WITH)
359
+ end
353
360
  end
354
361
 
355
362
  # @return [Boolean] +true+ when not in the CI context, and whether the MR is set to be squashed otherwise.
@@ -476,7 +483,10 @@ module Danger
476
483
  @labels_to_add ||= []
477
484
  end
478
485
 
486
+ # @return [Hash] the current API milestone object or +nil+ if run in dry-run mode
479
487
  def current_milestone
488
+ return unless ci?
489
+
480
490
  @current_milestone ||= gitlab_helper.api.group_milestones(GITLAB_ORG_GROUP_ID, state: "active")
481
491
  .auto_paginate
482
492
  .select { |m| m.title.match?(/\A\d+\.\d+\z/) && !m.expired && m.start_date && m.due_date }
@@ -136,10 +136,10 @@ module Danger
136
136
 
137
137
  def prepare_ux_category!(categories)
138
138
  if labels.include?("Community contribution") ||
139
- # We only want to spin a reviewer for merge requests which has a
140
- # designer for the team.
141
- Gitlab::Dangerfiles::Teammate.has_member_for_the_group?(
142
- :ux, project: config_project_name.downcase, labels: labels)
139
+ # We only want to spin a reviewer for merge requests which has a
140
+ # designer for the team.
141
+ Gitlab::Dangerfiles::Teammate.has_member_for_the_group?(
142
+ :ux, project: config_project_name.downcase, labels: labels)
143
143
  categories << :ux
144
144
  end
145
145
  end
@@ -96,11 +96,6 @@ def lint_commits(commits)
96
96
  if multi_line_commit_linter && multi_line_commit_linter.failed?
97
97
  warn_or_fail_commits(multi_line_commit_linter)
98
98
  commit_linters.delete(multi_line_commit_linter) # Don't show an error (here) and a warning (below)
99
- elsif helper.ci? # We don't have access to the MR title locally
100
- title_linter = lint_mr_title(helper.mr_title)
101
- if title_linter.failed?
102
- warn_or_fail_commits(title_linter)
103
- end
104
99
  end
105
100
  else
106
101
  if count_non_fixup_commits(commit_linters) > MAX_COMMITS_COUNT
@@ -16,13 +16,15 @@ To spread load more evenly across eligible reviewers, Danger has picked a candid
16
16
  review slot. Feel free to
17
17
  [override these selections](https://about.gitlab.com/handbook/engineering/projects/##{PROJECT_NAME})
18
18
  if you think someone else would be better-suited
19
- or use the [GitLab Review Workload Dashboard](https://gitlab-org.gitlab.io/gitlab-roulette/) to find other available reviewers.
19
+ or use the [GitLab Review Workload Dashboard](https://gitlab-org.gitlab.io/gitlab-roulette/?currentProject=#{PROJECT_NAME})
20
+ to find other available reviewers.
20
21
 
21
22
  To read more on how to use the reviewer roulette, please take a look at the
22
23
  [Engineering workflow](https://about.gitlab.com/handbook/engineering/workflow/#basics)
23
24
  and [code review guidelines](https://docs.gitlab.com/ee/development/code_review.html).
24
25
  Please consider assigning a reviewer or maintainer who is a
25
- [domain expert](https://about.gitlab.com/handbook/engineering/projects/#gitlab-development-kit) in the area of the merge request.
26
+ [domain expert](https://about.gitlab.com/handbook/engineering/projects/##{PROJECT_NAME})
27
+ in the area of the merge request.
26
28
 
27
29
  Once you've decided who will review this merge request, mention them as you
28
30
  normally would! Danger does not automatically notify them for you.
@@ -16,7 +16,7 @@ module Gitlab
16
16
  subject_too_long: "The %s may not be longer than #{MAX_LINE_LENGTH} characters",
17
17
  subject_starts_with_a_space: "The %s must not start with a space",
18
18
  subject_starts_with_lowercase: "The %s must start with a capital letter",
19
- subject_ends_with_a_period: "The %s must not end with a period",
19
+ subject_ends_with_a_period: "The %s must not end with a period"
20
20
  }
21
21
  end
22
22
 
@@ -17,7 +17,7 @@ module Gitlab
17
17
  tooling: Tooling,
18
18
  import_integrate_be: ImportIntegrateBE,
19
19
  import_integrate_fe: ImportIntegrateFE,
20
- ux: UX,
20
+ ux: UX
21
21
  }.freeze
22
22
  end
23
23
  private_class_method :category_to_class
@@ -26,7 +26,7 @@ module Gitlab
26
26
  message_contains_unicode_emoji: "Avoid the use of Unicode Emoji. These add no value to the commit " \
27
27
  "message, and may not be displayed properly everywhere",
28
28
  message_contains_short_reference: "Use full URLs instead of short references (`gitlab-org/gitlab#123` or " \
29
- "`!123`), as short references are displayed as plain text outside of GitLab",
29
+ "`!123`), as short references are displayed as plain text outside of GitLab"
30
30
  }
31
31
  )
32
32
  end
@@ -148,7 +148,7 @@ module Gitlab
148
148
 
149
149
  def message_contains_short_reference?
150
150
  match_data = commit.message.match(SHORT_REFERENCE_REGEX) ||
151
- commit.message.match(MS_SHORT_REFERENCE_REGEX)
151
+ commit.message.match(MS_SHORT_REFERENCE_REGEX)
152
152
 
153
153
  return false unless match_data
154
154
 
@@ -27,7 +27,7 @@ module Gitlab
27
27
 
28
28
  def initialize
29
29
  names = JSON.parse(File.read(DIGESTS)).keys +
30
- JSON.parse(File.read(ALIASES)).keys
30
+ JSON.parse(File.read(ALIASES)).keys
31
31
 
32
32
  @emoji = names.map { |name| ":#{name}:" }
33
33
  end
@@ -17,7 +17,7 @@ module DangerSpecHelper
17
17
  "GITLAB_CI" => "true",
18
18
  "DANGER_GITLAB_HOST" => "gitlab.example.com",
19
19
  "CI_MERGE_REQUEST_IID" => 28_493,
20
- "DANGER_GITLAB_API_TOKEN" => "123sbdq54erfsd3422gdfio",
20
+ "DANGER_GITLAB_API_TOKEN" => "123sbdq54erfsd3422gdfio"
21
21
  }
22
22
  end
23
23
 
@@ -93,7 +93,7 @@ RSpec.shared_context "with teammates" do
93
93
  "role" => "Backend engineer",
94
94
  "projects" => backend_maintainer_project,
95
95
  "available" => backend_available,
96
- "tz_offset_hours" => backend_tz_offset_hours,
96
+ "tz_offset_hours" => backend_tz_offset_hours
97
97
  )
98
98
  end
99
99
 
@@ -104,7 +104,7 @@ RSpec.shared_context "with teammates" do
104
104
  "role" => "Backend engineer",
105
105
  "projects" => backend_maintainer_project,
106
106
  "available" => backend_available,
107
- "tz_offset_hours" => backend_tz_offset_hours,
107
+ "tz_offset_hours" => backend_tz_offset_hours
108
108
  )
109
109
  end
110
110
 
@@ -116,7 +116,7 @@ RSpec.shared_context "with teammates" do
116
116
  "role" => "Backend engineer",
117
117
  "projects" => { "gitlab" => "reviewer backend" },
118
118
  "available" => backend_reviewer_available,
119
- "tz_offset_hours" => 1.0,
119
+ "tz_offset_hours" => 1.0
120
120
  )
121
121
  end
122
122
 
@@ -127,7 +127,7 @@ RSpec.shared_context "with teammates" do
127
127
  "role" => "Frontend engineer",
128
128
  "projects" => { "gitlab" => "reviewer frontend" },
129
129
  "available" => true,
130
- "tz_offset_hours" => 2.0,
130
+ "tz_offset_hours" => 2.0
131
131
  )
132
132
  end
133
133
 
@@ -138,7 +138,7 @@ RSpec.shared_context "with teammates" do
138
138
  "role" => "Frontend engineer",
139
139
  "projects" => { "gitlab" => "maintainer frontend" },
140
140
  "available" => true,
141
- "tz_offset_hours" => 2.0,
141
+ "tz_offset_hours" => 2.0
142
142
  )
143
143
  end
144
144
 
@@ -150,7 +150,7 @@ RSpec.shared_context "with teammates" do
150
150
  "projects" => { "gitlab" => "reviewer ux" },
151
151
  "specialty" => "Create: Source Code",
152
152
  "available" => true,
153
- "tz_offset_hours" => 2.0,
153
+ "tz_offset_hours" => 2.0
154
154
  )
155
155
  end
156
156
 
@@ -161,7 +161,7 @@ RSpec.shared_context "with teammates" do
161
161
  "role" => "Software Engineer in Test, Create:Source Code",
162
162
  "projects" => { "gitlab" => "maintainer qa", "gitlab-qa" => "maintainer" },
163
163
  "available" => true,
164
- "tz_offset_hours" => 2.0,
164
+ "tz_offset_hours" => 2.0
165
165
  )
166
166
  end
167
167
 
@@ -172,7 +172,7 @@ RSpec.shared_context "with teammates" do
172
172
  "role" => "Frontend Engineer, Manage:Import and Integrate",
173
173
  "projects" => { "gitlab" => "reviewer frontend" },
174
174
  "available" => true,
175
- "tz_offset_hours" => 2.0,
175
+ "tz_offset_hours" => 2.0
176
176
  )
177
177
  end
178
178
 
@@ -183,7 +183,7 @@ RSpec.shared_context "with teammates" do
183
183
  "role" => "Backend Engineer, Manage:Import and Integrate",
184
184
  "projects" => { "gitlab" => "reviewer backend" },
185
185
  "available" => true,
186
- "tz_offset_hours" => 2.0,
186
+ "tz_offset_hours" => 2.0
187
187
  )
188
188
  end
189
189
 
@@ -194,7 +194,7 @@ RSpec.shared_context "with teammates" do
194
194
  "role" => "Engineering Productivity",
195
195
  "projects" => { "gitlab" => "reviewer tooling" },
196
196
  "available" => true,
197
- "tz_offset_hours" => 2.0,
197
+ "tz_offset_hours" => 2.0
198
198
  )
199
199
  end
200
200
 
@@ -205,7 +205,7 @@ RSpec.shared_context "with teammates" do
205
205
  "role" => '~"ci::templates"',
206
206
  "projects" => { "gitlab" => "reviewer ci_template" },
207
207
  "available" => true,
208
- "tz_offset_hours" => 2.0,
208
+ "tz_offset_hours" => 2.0
209
209
  )
210
210
  end
211
211
 
@@ -216,7 +216,7 @@ RSpec.shared_context "with teammates" do
216
216
  "role" => "Backend Engineer, Analytics: Analytics Instrumentation",
217
217
  "projects" => { "gitlab" => "reviewer analytics_instrumentation" },
218
218
  "available" => true,
219
- "tz_offset_hours" => 2.0,
219
+ "tz_offset_hours" => 2.0
220
220
  )
221
221
  end
222
222
 
@@ -227,7 +227,7 @@ RSpec.shared_context "with teammates" do
227
227
  "role" => "Backend Engineer, Manage:Import and Integrate",
228
228
  "projects" => { "gitlab" => "reviewer backend" },
229
229
  "available" => backend_reviewer_available,
230
- "tz_offset_hours" => 2.0,
230
+ "tz_offset_hours" => 2.0
231
231
  )
232
232
  end
233
233
 
@@ -238,7 +238,7 @@ RSpec.shared_context "with teammates" do
238
238
  "role" => "Frontend Engineer, Manage:Import and Integrate",
239
239
  "projects" => { "gitlab" => "reviewer frontend" },
240
240
  "available" => true,
241
- "tz_offset_hours" => 2.0,
241
+ "tz_offset_hours" => 2.0
242
242
  )
243
243
  end
244
244
 
@@ -249,7 +249,7 @@ RSpec.shared_context "with teammates" do
249
249
  "role" => "Backend engineer",
250
250
  "projects" => { "gitlab-workhorse" => "reviewer" },
251
251
  "available" => true,
252
- "tz_offset_hours" => 2.0,
252
+ "tz_offset_hours" => 2.0
253
253
  )
254
254
  end
255
255
 
@@ -260,7 +260,7 @@ RSpec.shared_context "with teammates" do
260
260
  "role" => "Backend engineer",
261
261
  "projects" => { "gitlab-workhorse" => "maintainer" },
262
262
  "available" => true,
263
- "tz_offset_hours" => 2.0,
263
+ "tz_offset_hours" => 2.0
264
264
  )
265
265
  end
266
266
 
@@ -71,8 +71,8 @@ module Gitlab
71
71
  # contribution even without a team designer. We assign this to Pedro.
72
72
  spin.reviewer = ux_fallback_wider_community_reviewer if
73
73
  labels.include?("Community contribution") &&
74
- spin.no_reviewer? &&
75
- spin.no_maintainer?
74
+ spin.no_reviewer? &&
75
+ spin.no_maintainer?
76
76
  end
77
77
  end
78
78
 
@@ -86,7 +86,7 @@ module Gitlab
86
86
  @username = options["username"]
87
87
  @name = options["name"]
88
88
  @markdown_name = options["markdown_name"] ||
89
- default_markdown_name(options["username"])
89
+ default_markdown_name(options["username"])
90
90
  @role = options["role"]
91
91
  @specialty = options["specialty"]
92
92
  @projects = process_projects(options["projects"])
@@ -9,7 +9,7 @@ module Gitlab
9
9
  performance: %w[type::bug bug::performance],
10
10
  added: %w[type::feature feature::addition],
11
11
  deprecated: %w[type::maintenance maintenance::removal],
12
- removed: %w[type::maintenance maintenance::removal],
12
+ removed: %w[type::maintenance maintenance::removal]
13
13
  }.freeze
14
14
 
15
15
  def labels_from_changelog_categories(categories)
@@ -1,5 +1,5 @@
1
1
  module Gitlab
2
2
  module Dangerfiles
3
- VERSION = "4.7.0"
3
+ VERSION = "4.8.0"
4
4
  end
5
5
  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: 4.7.0
4
+ version: 4.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitLab
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-03-11 00:00:00.000000000 Z
11
+ date: 2024-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -282,7 +282,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
282
282
  - !ruby/object:Gem::Version
283
283
  version: '0'
284
284
  requirements: []
285
- rubygems_version: 3.3.26
285
+ rubygems_version: 3.3.27
286
286
  signing_key:
287
287
  specification_version: 4
288
288
  summary: This gem provides common Dangerfile and plugins for GitLab projects.