gitlab-dangerfiles 4.6.0 → 4.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 501394f58303715430e058da5fbc46a6c539136b8a888ed22521ab56da6595c3
4
- data.tar.gz: 520c933eb21695e1cdc9e74cea42ec1e636b08455377d2b9dc3ebafe405977ac
3
+ metadata.gz: '0535903212a08369cccb1b24b1753e1cfa5a637b0827a706a8b37fd3e0fb0dc2'
4
+ data.tar.gz: c69bcd32f34546130f7b74ccb946be09e876a2820c53d7546b58d21ceed62f0b
5
5
  SHA512:
6
- metadata.gz: 5d68efa303d47210a6e1d126d9e7706f8872ae61a5a24dacce6b6a48242f8e9d0854f8067d35c64e6340602768e4ed65bd1fcfab71f7447798576172095497bc
7
- data.tar.gz: 79b38327e2b8a133c58124952b2ff371cb551fde1d61aeb29b5f67d29ee212f93c1c423842121f0247304af52414efd5e690d3fa1c4e50083a9dfacdca7f4d33
6
+ metadata.gz: 84e215eee590bde5eb47905ffbf44a14763964695e3d80637d5f8483337f1f792dd7dfee1f5ae0baeb734c85967f47060005a0a6a052e3b1ebf4c53c55243756
7
+ data.tar.gz: 57657967dcbce6d66f68780c04d57b39601160d26e07f20f4b529a083cfdeb7c71f9f20286f6724ad2a15610fa2793850900959d6961c3b5ece4c8f7d4725b67
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-ci.yml CHANGED
@@ -2,9 +2,6 @@ stages:
2
2
  - test
3
3
  - deploy
4
4
 
5
- variables:
6
- DEFAULT_CI_IMAGE: "ruby:${RUBY_VERSION}"
7
-
8
5
  workflow:
9
6
  rules:
10
7
  # For merge requests, create a pipeline.
@@ -15,12 +12,8 @@ workflow:
15
12
  - if: '$CI_COMMIT_TAG'
16
13
 
17
14
  default:
18
- image: "${DEFAULT_CI_IMAGE}"
19
15
  tags:
20
16
  - gitlab-org
21
- before_script:
22
- - gem install bundler
23
- - bundle install -j $(nproc) --path vendor
24
17
  cache:
25
18
  key:
26
19
  files:
@@ -28,12 +21,14 @@ default:
28
21
  - gitlab-dangerfiles.gemspec
29
22
  paths:
30
23
  - vendor/ruby
31
- - Gemfile.lock
32
- policy: pull
33
24
 
34
25
  .default-test-job:
26
+ image: "ruby:${RUBY_VERSION}"
35
27
  stage: test
36
28
  needs: []
29
+ before_script:
30
+ - gem install bundler
31
+ - bundle install -j $(nproc) --path vendor
37
32
  parallel:
38
33
  matrix:
39
34
  - RUBY_VERSION: ['3.0', '3.1', '3.2']
@@ -49,24 +44,19 @@ test:rubocop:
49
44
  - bundle exec rubocop -P -E .
50
45
 
51
46
  include:
52
- - template: Security/Dependency-Scanning.gitlab-ci.yml
53
- - template: Security/SAST.gitlab-ci.yml
54
- - template: Security/Secret-Detection.gitlab-ci.yml
55
- - project: 'gitlab-org/quality/pipeline-common'
56
- file:
57
- - '/ci/danger-review.yml'
58
- - component: "gitlab.com/gitlab-org/quality/pipeline-common/gem-release@7.6.1"
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
59
50
  inputs:
60
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
55
+ - template: Security/Dependency-Scanning.gitlab-ci.yml
61
56
 
62
57
  # run security jobs on MRs
63
58
  # see: https://gitlab.com/gitlab-org/gitlab/-/issues/218444#note_478761991
64
59
 
65
- brakeman-sast:
66
- rules:
67
- - if: '$CI_MERGE_REQUEST_IID'
68
- - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
69
-
70
60
  gemnasium-dependency_scanning:
71
61
  rules:
72
62
  - if: '$CI_MERGE_REQUEST_IID'
data/.rubocop.yml CHANGED
@@ -28,27 +28,14 @@ RSpec/FilePath:
28
28
  RSpec/SpecFilePathFormat:
29
29
  Enabled: false
30
30
 
31
+ Style/ArrayIntersect:
32
+ Enabled: false # We're still supporting Ruby 3.1 and below
33
+
31
34
  Style/HashSyntax:
32
35
  EnforcedStyle: ruby19_no_mixed_keys
33
36
  # Introduced in Ruby 3.1. Disable for now.
34
37
  EnforcedShorthandSyntax: never
35
38
 
36
- # To respect rufo formatting
37
- Style/StringLiterals:
38
- EnforcedStyle: double_quotes
39
-
40
- # To respect rufo formatting
41
- Style/TrailingCommaInHashLiteral:
42
- EnforcedStyleForMultiline: consistent_comma
43
-
44
- # To respect rufo formatting
45
- Style/TrailingCommaInArguments:
46
- Enabled: false
47
-
48
- # To respect rufo formatting
49
- Layout/MultilineOperationIndentation:
50
- Enabled: false
51
-
52
39
  # Was problematic, and not included in the .rubocop_todo.yml
53
40
  GitlabSecurity/PublicSend:
54
41
  Enabled: false
data/Gemfile.lock ADDED
@@ -0,0 +1,231 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ gitlab-dangerfiles (4.8.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
+ proc_to_ast (0.1.0)
121
+ coderay
122
+ parser
123
+ unparser
124
+ pry (0.14.2)
125
+ coderay (~> 1.1)
126
+ method_source (~> 1.0)
127
+ public_suffix (5.0.1)
128
+ rack (3.0.4.1)
129
+ rainbow (3.1.1)
130
+ rake (13.0.6)
131
+ rb-fsevent (0.11.2)
132
+ rb-inotify (0.10.1)
133
+ ffi (~> 1.0)
134
+ rchardet (1.8.0)
135
+ regexp_parser (2.7.0)
136
+ rexml (3.2.5)
137
+ rspec (3.12.0)
138
+ rspec-core (~> 3.12.0)
139
+ rspec-expectations (~> 3.12.0)
140
+ rspec-mocks (~> 3.12.0)
141
+ rspec-core (3.12.1)
142
+ rspec-support (~> 3.12.0)
143
+ rspec-expectations (3.12.2)
144
+ diff-lcs (>= 1.2.0, < 2.0)
145
+ rspec-support (~> 3.12.0)
146
+ rspec-mocks (3.12.3)
147
+ diff-lcs (>= 1.2.0, < 2.0)
148
+ rspec-support (~> 3.12.0)
149
+ rspec-parameterized (1.0.0)
150
+ rspec-parameterized-core (< 2)
151
+ rspec-parameterized-table_syntax (< 2)
152
+ rspec-parameterized-core (1.0.0)
153
+ parser
154
+ proc_to_ast
155
+ rspec (>= 2.13, < 4)
156
+ unparser
157
+ rspec-parameterized-table_syntax (1.0.0)
158
+ binding_of_caller
159
+ rspec-parameterized-core (< 2)
160
+ rspec-support (3.12.0)
161
+ rubocop (1.43.0)
162
+ json (~> 2.3)
163
+ parallel (~> 1.10)
164
+ parser (>= 3.2.0.0)
165
+ rainbow (>= 2.2.2, < 4.0)
166
+ regexp_parser (>= 1.8, < 3.0)
167
+ rexml (>= 3.2.5, < 4.0)
168
+ rubocop-ast (>= 1.24.1, < 2.0)
169
+ ruby-progressbar (~> 1.7)
170
+ unicode-display_width (>= 2.4.0, < 3.0)
171
+ rubocop-ast (1.26.0)
172
+ parser (>= 3.2.1.0)
173
+ rubocop-capybara (2.19.0)
174
+ rubocop (~> 1.41)
175
+ rubocop-factory_bot (2.24.0)
176
+ rubocop (~> 1.33)
177
+ rubocop-graphql (0.19.0)
178
+ rubocop (>= 0.87, < 2)
179
+ rubocop-performance (1.19.1)
180
+ rubocop (>= 1.7.0, < 2.0)
181
+ rubocop-ast (>= 0.4.0)
182
+ rubocop-rails (2.17.4)
183
+ activesupport (>= 4.2.0)
184
+ rack (>= 1.1)
185
+ rubocop (>= 1.33.0, < 2.0)
186
+ rubocop-rspec (2.24.1)
187
+ rubocop (~> 1.33)
188
+ rubocop-capybara (~> 2.17)
189
+ rubocop-factory_bot (~> 2.22)
190
+ ruby-progressbar (1.11.0)
191
+ ruby2_keywords (0.0.5)
192
+ sawyer (0.9.2)
193
+ addressable (>= 2.3.5)
194
+ faraday (>= 0.17.3, < 3)
195
+ shellany (0.0.1)
196
+ terminal-table (3.0.2)
197
+ unicode-display_width (>= 1.1.1, < 3)
198
+ thor (1.2.1)
199
+ timecop (0.9.6)
200
+ tzinfo (2.0.6)
201
+ concurrent-ruby (~> 1.0)
202
+ unicode-display_width (2.4.2)
203
+ unparser (0.6.7)
204
+ diff-lcs (~> 1.3)
205
+ parser (>= 3.2.0)
206
+ webmock (3.18.1)
207
+ addressable (>= 2.8.0)
208
+ crack (>= 0.3.2)
209
+ hashdiff (>= 0.4.0, < 2.0.0)
210
+ webrick (1.7.0)
211
+ yard (0.9.28)
212
+ webrick (~> 1.7.0)
213
+
214
+ PLATFORMS
215
+ ruby
216
+
217
+ DEPENDENCIES
218
+ climate_control
219
+ gitlab-dangerfiles!
220
+ gitlab-styles (~> 10.0)
221
+ guard-rspec (~> 4.7.3)
222
+ lefthook (~> 1.3)
223
+ rspec (~> 3.8)
224
+ rspec-parameterized
225
+ rubocop-rails (< 2.21.2)
226
+ timecop
227
+ webmock
228
+ yard
229
+
230
+ BUNDLED WITH
231
+ 2.5.4
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
 
@@ -27,8 +27,9 @@ module Danger
27
27
  analytics_instrumentation: '~"analytics instrumentation"',
28
28
  import_integrate_be: '~"group::import and integrate" (backend)',
29
29
  import_integrate_fe: '~"group::import and integrate" (frontend)',
30
- "Authentication and Authorization": '~"group::authentication and authorization"',
31
- Compliance: '~"group::compliance"',
30
+ Authentication: '~"group::authentication"',
31
+ Authorization: '~"group::authorization"',
32
+ Compliance: '~"group::compliance"'
32
33
  }.freeze
33
34
  # rubocop:enable Style/HashSyntax
34
35
 
@@ -344,11 +345,18 @@ module Danger
344
345
  )
345
346
  end
346
347
 
347
- # @return [Boolean] +false+ when not in the CI context, and returns +true+ if the MR title starts with Revert or revert
348
- def revert_mr?
349
- return false unless ci?
348
+ MR_REVERT_START_WITH = /[Rr]evert /
350
349
 
351
- 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
352
360
  end
353
361
 
354
362
  # @return [Boolean] +true+ when not in the CI context, and whether the MR is set to be squashed otherwise.
@@ -475,7 +483,10 @@ module Danger
475
483
  @labels_to_add ||= []
476
484
  end
477
485
 
486
+ # @return [Hash] the current API milestone object or +nil+ if run in dry-run mode
478
487
  def current_milestone
488
+ return unless ci?
489
+
479
490
  @current_milestone ||= gitlab_helper.api.group_milestones(GITLAB_ORG_GROUP_ID, state: "active")
480
491
  .auto_paginate
481
492
  .select { |m| m.title.match?(/\A\d+\.\d+\z/) && !m.expired && m.start_date && m.due_date }