gitlab-dangerfiles 3.6.6 → 3.7.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: fe954dbacd967eb64f63f537578e4960bc9047e4669c3e5829eafab2d7a09bcf
4
- data.tar.gz: fb0f4784b78d62d8fcf4d7c695a3589e0ca6cfb345043fee4538ae8513a1226d
3
+ metadata.gz: 2c8b3755415a3a732fc13c70da4176927062a9d5b6452a7d2513d3ef29617c89
4
+ data.tar.gz: 1822e18dcc9e51d93f0ea1f3df574aaf5c1dd5ec1b0fd552bfea34f8b114971d
5
5
  SHA512:
6
- metadata.gz: c28b7ea174d422b1963fb450d2a25d470fca59992c3659262a577ecb29c48eb551fa29856c3c48c929ff26bc42fc6cb9e4cac997125fa51273cf9efb8b131cfb
7
- data.tar.gz: 7e64f86bb7ed4c3805d6e1d229e6bcba37583b5e33f33fe8bbba230a8e603f08083b049c20de7d0621b78e88c6179bfc97087cee05577cdbe6de18519b5a35f2
6
+ metadata.gz: d86af6131e0703fcab736fb75f09b62d1e656bec379f76f8bee6223899e99b34a085c86dc94d7c6d99ce88642acbea4d9079050ab50331abbc10d6c47c0fcc76
7
+ data.tar.gz: dc878dcd339bed44e0cb4059ec965cce1f6e0513099002126779640c3f8986417bbfabdbbec1ffd4137729839d682d8f7bc6f69cf1654ee03b9a75007f561f93
data/.gitlab-ci.yml CHANGED
@@ -35,7 +35,7 @@ test:rspec:
35
35
  - bundle exec rspec
36
36
  parallel:
37
37
  matrix:
38
- - RUBY_VERSION: ['2.7', '3.0']
38
+ - RUBY_VERSION: ['3.0', '3.1', '3.2']
39
39
 
40
40
  test:rubocop:
41
41
  extends: .default
@@ -44,7 +44,7 @@ test:rubocop:
44
44
  - bundle exec rubocop -P -E .
45
45
  parallel:
46
46
  matrix:
47
- - RUBY_VERSION: ['2.7', '3.0']
47
+ - RUBY_VERSION: ['3.0', '3.1', '3.2']
48
48
 
49
49
  test:rufo:
50
50
  extends: .default
@@ -53,7 +53,7 @@ test:rufo:
53
53
  - bundle exec rufo --check .
54
54
  parallel:
55
55
  matrix:
56
- - RUBY_VERSION: ['2.7', '3.0']
56
+ - RUBY_VERSION: ['3.0', '3.1', '3.2']
57
57
 
58
58
  include:
59
59
  - template: Security/Dependency-Scanning.gitlab-ci.yml
data/.rubocop.yml CHANGED
@@ -27,6 +27,8 @@ RSpec/FilePath:
27
27
 
28
28
  Style/HashSyntax:
29
29
  EnforcedStyle: ruby19_no_mixed_keys
30
+ # Introduced in Ruby 3.1. Disable for now.
31
+ EnforcedShorthandSyntax: never
30
32
 
31
33
  # To respect rufo formatting
32
34
  Style/StringLiterals:
@@ -36,6 +38,10 @@ Style/StringLiterals:
36
38
  Style/TrailingCommaInHashLiteral:
37
39
  EnforcedStyleForMultiline: consistent_comma
38
40
 
41
+ # To respect rufo formatting
42
+ Style/TrailingCommaInArguments:
43
+ Enabled: false
44
+
39
45
  # To respect rufo formatting
40
46
  Layout/MultilineOperationIndentation:
41
47
  Enabled: false
@@ -134,7 +134,7 @@ module Danger
134
134
  def critical_checks
135
135
  check_result = ChangelogCheckResult.empty
136
136
 
137
- check_result.error(modified_text) if git.modified_files.include?("CHANGELOG.md")
137
+ check_result.warning(modified_text) if git.modified_files.include?("CHANGELOG.md")
138
138
 
139
139
  # Help the user to apply the correct labels to skip this danger check in case it's a revert MR
140
140
  check_result.warning(IF_REVERT_MR_TEXT) if helper.revert_mr?
@@ -120,6 +120,10 @@ module Danger
120
120
  end
121
121
  end
122
122
 
123
+ def warnings
124
+ @warnings ||= []
125
+ end
126
+
123
127
  private
124
128
 
125
129
  def spin_for_approval_rule?(rule)
@@ -258,16 +262,18 @@ module Danger
258
262
  #
259
263
  # @param [String] url
260
264
  #
261
- # @return [Hash, Array]
265
+ # @return [Hash, Array, NilClass]
262
266
  def http_get_json(url)
263
267
  rsp = Net::HTTP.get_response(URI.parse(url))
264
268
 
265
269
  if rsp.is_a?(Net::HTTPRedirection)
266
- raise "Redirection detected: #{rsp.header["location"]}"
270
+ warnings << "Redirection detected. Stopping."
271
+ return nil
267
272
  end
268
273
 
269
274
  unless rsp.is_a?(Net::HTTPOK)
270
- raise HTTPError, "Failed to read #{url}: #{rsp.code} #{rsp.message}"
275
+ warnings << "HTTPError: Failed to read #{url}: #{rsp.code}."
276
+ return nil
271
277
  end
272
278
 
273
279
  JSON.parse(rsp.body)
@@ -279,10 +285,11 @@ module Danger
279
285
  # @return [Array<Gitlab::Dangerfiles::Teammate>]
280
286
  def company_members
281
287
  @company_members ||= begin
282
- data = http_get_json(ROULETTE_DATA_URL)
288
+ data = http_get_json(ROULETTE_DATA_URL) || []
283
289
  data.map { |hash| Gitlab::Dangerfiles::Teammate.new(hash) }
284
290
  rescue JSON::ParserError
285
- raise "Failed to parse JSON response from #{ROULETTE_DATA_URL}"
291
+ warnings << "Failed to parse JSON response from #{ROULETTE_DATA_URL}"
292
+ []
286
293
  end
287
294
  end
288
295
 
@@ -39,6 +39,11 @@ TABLE_HEADER_WITHOUT_CATEGORIES = <<MARKDOWN
39
39
  | -------- | ---------- |
40
40
  MARKDOWN
41
41
 
42
+ WARNING_MESSAGE = <<MARKDOWN
43
+ ⚠ Failed to retrieve information ⚠
44
+ %{warnings}
45
+ MARKDOWN
46
+
42
47
  OPTIONAL_REVIEW_TEMPLATE = '%{role} review is optional'
43
48
  NOT_AVAILABLE_TEMPLATE = 'No %{role} available'
44
49
 
@@ -69,6 +74,12 @@ def markdown_row_for_spins(category, spins_array, show_category_column:)
69
74
  row
70
75
  end
71
76
 
77
+ def warning_list(roulette)
78
+ return unless roulette.warnings.any?
79
+
80
+ roulette.warnings.map { |warning| "* #{warning}" }.join("\n")
81
+ end
82
+
72
83
  changes = helper.changes_by_category
73
84
 
74
85
  # Replicating label based categories from:
@@ -101,5 +112,10 @@ if changes.any?
101
112
  table_header = show_category_column ? TABLE_HEADER_WITH_CATEGORIES : TABLE_HEADER_WITHOUT_CATEGORIES
102
113
 
103
114
  markdown(MESSAGE)
115
+
116
+ if (warnings = warning_list(roulette))
117
+ markdown(format(WARNING_MESSAGE, warnings: warnings))
118
+ end
119
+
104
120
  markdown(TABLE_MARKDOWN + table_header + rows.join("\n")) unless rows.empty?
105
121
  end
@@ -92,11 +92,46 @@ module Gitlab
92
92
  class UX < Category
93
93
  private
94
94
 
95
+ def has_particular_capability?(teammate)
96
+ if labels.any?("Community contribution")
97
+ can_review_wider_community_contribution?(teammate)
98
+ else
99
+ super
100
+ end
101
+ end
102
+
95
103
  def has_universal_capability?(teammate)
96
- teammate.projects.each_value.find do |capabilities|
104
+ # No universal reviewer for community contribution.
105
+ # If we do, then picking from corresponding group won't be accurate.
106
+ # After solving the following issue, then we can revisit this:
107
+ # https://gitlab.com/gitlab-org/ruby/gems/gitlab-dangerfiles/-/issues/58
108
+ return false if labels.any?("Community contribution")
109
+
110
+ teammate.projects.each_value.any? do |capabilities|
97
111
  capabilities.include?(capability)
98
112
  end
99
113
  end
114
+
115
+ def can_review_wider_community_contribution?(teammate)
116
+ # Pick corresponding group for community contribution
117
+ # Role can be:
118
+ # Product Designer, Create:Source Code
119
+ # Product Designer, Verify:Pipeline Insights, Verify:Runner
120
+ # Product Designer, Release
121
+ # Specialty can be:
122
+ # Source Code
123
+ # [Growth: Activation, Growth: Expansion]
124
+ # Runner
125
+ areas = teammate.role[/Product Designer(?:.*?, (.+))/, 1]&.split(",")
126
+
127
+ group_labels = [*teammate.specialty, *areas].map do |field|
128
+ group = field.strip.sub(/^.+: ?/, "").downcase
129
+
130
+ "group::#{group}"
131
+ end
132
+
133
+ (group_labels & labels).any?
134
+ end
100
135
  end
101
136
  end
102
137
  end
@@ -5,10 +5,10 @@ require_relative "category"
5
5
  module Gitlab
6
6
  module Dangerfiles
7
7
  class Teammate
8
- attr_reader :options, :username, :name, :role, :projects, :available, :hungry, :reduced_capacity, :tz_offset_hours,
8
+ attr_reader :options, :username, :name, :role, :specialty, :projects, :available, :hungry, :reduced_capacity, :tz_offset_hours,
9
9
  :only_maintainer_reviews
10
10
 
11
- # The options data are produced by https://gitlab.com/gitlab-org/gitlab-roulette/-/blob/master/lib/team_member.rb
11
+ # The options data are produced by https://gitlab.com/gitlab-org/gitlab-roulette/-/blob/main/lib/team_member.rb
12
12
  def initialize(options = {})
13
13
  @options = options
14
14
  @username = options["username"]
@@ -16,6 +16,7 @@ module Gitlab
16
16
  @markdown_name = options["markdown_name"] ||
17
17
  default_markdown_name(*options.values_at("username", "name"))
18
18
  @role = options["role"]
19
+ @specialty = options["specialty"]
19
20
  @projects = process_projects(options["projects"])
20
21
  @available = options["available"]
21
22
  @hungry = options["hungry"]
@@ -1,5 +1,5 @@
1
1
  module Gitlab
2
2
  module Dangerfiles
3
- VERSION = "3.6.6"
3
+ VERSION = "3.7.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: 3.6.6
4
+ version: 3.7.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-01-25 00:00:00.000000000 Z
11
+ date: 2023-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake