gitlab_quality-test_tooling 1.11.0 → 1.17.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 (36) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +93 -68
  3. data/README.md +35 -2
  4. data/exe/flaky-test-issues +7 -2
  5. data/exe/knapsack-report-issues +54 -0
  6. data/exe/update-test-meta +70 -0
  7. data/lefthook.yml +13 -0
  8. data/lib/gitlab_quality/test_tooling/concerns/find_set_dri.rb +47 -0
  9. data/lib/gitlab_quality/test_tooling/gitlab_client/branches_client.rb +18 -0
  10. data/lib/gitlab_quality/test_tooling/gitlab_client/branches_dry_client.rb +15 -0
  11. data/lib/gitlab_quality/test_tooling/gitlab_client/commits_client.rb +20 -0
  12. data/lib/gitlab_quality/test_tooling/gitlab_client/commits_dry_client.rb +14 -0
  13. data/lib/gitlab_quality/test_tooling/gitlab_client/gitlab_client.rb +12 -13
  14. data/lib/gitlab_quality/test_tooling/gitlab_client/issues_client.rb +6 -6
  15. data/lib/gitlab_quality/test_tooling/gitlab_client/merge_requests_client.rb +18 -10
  16. data/lib/gitlab_quality/test_tooling/gitlab_client/merge_requests_dry_client.rb +4 -2
  17. data/lib/gitlab_quality/test_tooling/gitlab_client/repository_files_client.rb +23 -0
  18. data/lib/gitlab_quality/test_tooling/knapsack_reports/spec_run_time.rb +85 -0
  19. data/lib/gitlab_quality/test_tooling/knapsack_reports/spec_run_time_report.rb +60 -0
  20. data/lib/gitlab_quality/test_tooling/report/concerns/issue_reports.rb +41 -28
  21. data/lib/gitlab_quality/test_tooling/report/concerns/utils.rb +23 -1
  22. data/lib/gitlab_quality/test_tooling/report/flaky_test_issue.rb +89 -44
  23. data/lib/gitlab_quality/test_tooling/report/generate_test_session.rb +1 -4
  24. data/lib/gitlab_quality/test_tooling/report/knapsack_report_issue.rb +139 -0
  25. data/lib/gitlab_quality/test_tooling/report/relate_failure_issue.rb +6 -12
  26. data/lib/gitlab_quality/test_tooling/report/report_as_issue.rb +16 -5
  27. data/lib/gitlab_quality/test_tooling/report/slow_test_issue.rb +71 -80
  28. data/lib/gitlab_quality/test_tooling/runtime/env.rb +5 -1
  29. data/lib/gitlab_quality/test_tooling/slack/post_to_slack_dry.rb +14 -0
  30. data/lib/gitlab_quality/test_tooling/test_meta/processor/add_to_blocking_processor.rb +143 -0
  31. data/lib/gitlab_quality/test_tooling/test_meta/processor/add_to_quarantine_processor.rb +199 -0
  32. data/lib/gitlab_quality/test_tooling/test_meta/processor/meta_processor.rb +44 -0
  33. data/lib/gitlab_quality/test_tooling/test_meta/test_meta_updater.rb +313 -0
  34. data/lib/gitlab_quality/test_tooling/version.rb +1 -1
  35. metadata +40 -9
  36. data/lib/gitlab_quality/test_tooling/report/concerns/find_set_dri.rb +0 -49
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9d5389523997b69a28fe068d576dc92e77c1bcc461fda4ed50292bb2ce6d8c9c
4
- data.tar.gz: 541341b34aa04d235d8c1b068f28533ff804b57411ce56237cb16f64e3381ad3
3
+ metadata.gz: b8709476aafe6dc96d2b49d1d74b18b2e3dbf6c37cb8ebb0acd631d05dbfe2ac
4
+ data.tar.gz: 26d4d54613a522014b5f3b93f38c0cb62027c2e209573727265a5c2b630a6d9d
5
5
  SHA512:
6
- metadata.gz: 17a53fa74d99ebd6bde6397ed9a5976cdce5a7fef4eb2ac20256bf93ffd8f346b15ff467b6ff6207f07a930597ec5b7814c131293d8d9a29548b5f39b10ca90e
7
- data.tar.gz: 1a918bc5b005653e9ce263c728f0068256df77c638961d59a62b0461cdeb9d774556a58fe41e2409a81e0fac98f838c53d057c5ba7483ab04facc17c0e54e999
6
+ metadata.gz: 194294ffed245e88a96e35480485f98c1748a8417766cdca1cf737ece2b090a4e29efc444fa449f5f569e292333ba50954f7c07a72fbb2f9225c9195c4b6f411
7
+ data.tar.gz: 30cc7f3a5da1c15b5c3508e0850c007bddf9f22a85c9ec1361821be7bc330afd3869cd9fe74d3b424afc2d0ad2d180c4c0649b5f502f4740ca68f1b2c8119933
data/Gemfile.lock CHANGED
@@ -1,14 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gitlab_quality-test_tooling (1.11.0)
5
- activesupport (>= 6.1, < 7.2)
4
+ gitlab_quality-test_tooling (1.17.0)
5
+ activesupport (>= 6.1, < 7.1)
6
6
  amatch (~> 0.4.1)
7
7
  gitlab (~> 4.19)
8
8
  http (~> 5.0)
9
9
  nokogiri (~> 1.10)
10
10
  parallel (>= 1, < 2)
11
11
  rainbow (>= 3, < 4)
12
+ rspec-parameterized (~> 1.0.0)
12
13
  table_print (= 1.5.7)
13
14
  zeitwerk (>= 2, < 3)
14
15
 
@@ -20,15 +21,16 @@ GEM
20
21
  i18n (>= 1.6, < 2)
21
22
  minitest (>= 5.1)
22
23
  tzinfo (~> 2.0)
23
- zeitwerk (~> 2.3)
24
- addressable (2.8.4)
24
+ addressable (2.8.6)
25
25
  public_suffix (>= 2.0.2, < 6.0)
26
26
  amatch (0.4.1)
27
27
  mize
28
28
  tins (~> 1.0)
29
29
  ast (2.4.2)
30
30
  backport (1.2.0)
31
- benchmark (0.2.1)
31
+ benchmark (0.3.0)
32
+ binding_of_caller (1.0.0)
33
+ debug_inspector (>= 0.0.1)
32
34
  byebug (11.1.3)
33
35
  claide (1.1.0)
34
36
  claide-plugins (0.9.2)
@@ -38,60 +40,60 @@ GEM
38
40
  climate_control (1.2.0)
39
41
  coderay (1.1.3)
40
42
  colored2 (3.1.2)
41
- concurrent-ruby (1.2.2)
43
+ concurrent-ruby (1.2.3)
42
44
  cork (0.3.0)
43
45
  colored2 (~> 3.1)
44
46
  crack (0.4.5)
45
47
  rexml
46
- danger (9.3.0)
48
+ danger (9.4.2)
47
49
  claide (~> 1.0)
48
50
  claide-plugins (>= 0.9.2)
49
51
  colored2 (~> 3.1)
50
52
  cork (~> 0.1)
51
53
  faraday (>= 0.9.0, < 3.0)
52
54
  faraday-http-cache (~> 2.0)
53
- git (~> 1.13.0)
55
+ git (~> 1.13)
54
56
  kramdown (~> 2.3)
55
57
  kramdown-parser-gfm (~> 1.0)
56
58
  no_proxy_fix
57
- octokit (~> 5.0)
59
+ octokit (>= 4.0)
58
60
  terminal-table (>= 1, < 4)
59
61
  danger-gitlab (8.0.0)
60
62
  danger
61
63
  gitlab (~> 4.2, >= 4.2.0)
64
+ debug_inspector (1.2.0)
62
65
  diff-lcs (1.5.0)
63
66
  docile (1.4.0)
64
- domain_name (0.5.20190701)
65
- unf (>= 0.0.5, < 1.0.0)
67
+ domain_name (0.6.20240107)
66
68
  e2mmap (0.1.0)
67
- faraday (2.7.4)
68
- faraday-net_http (>= 2.0, < 3.1)
69
- ruby2_keywords (>= 0.0.4)
70
- faraday-http-cache (2.5.0)
69
+ faraday (2.9.0)
70
+ faraday-net_http (>= 2.0, < 3.2)
71
+ faraday-http-cache (2.5.1)
71
72
  faraday (>= 0.8)
72
- faraday-net_http (3.0.2)
73
- ffi (1.15.5)
73
+ faraday-net_http (3.1.0)
74
+ net-http
75
+ ffi (1.16.3)
74
76
  ffi-compiler (1.0.1)
75
77
  ffi (>= 1.0.0)
76
78
  rake
77
79
  formatador (1.1.0)
78
- git (1.13.2)
80
+ git (1.19.1)
79
81
  addressable (~> 2.8)
80
82
  rchardet (~> 1.8)
81
83
  gitlab (4.19.0)
82
84
  httparty (~> 0.20)
83
85
  terminal-table (>= 1.5.1)
84
- gitlab-dangerfiles (3.8.0)
86
+ gitlab-dangerfiles (3.13.0)
85
87
  danger (>= 8.4.5)
86
88
  danger-gitlab (>= 8.0.0)
87
89
  rake
88
- gitlab-styles (10.0.0)
89
- rubocop (~> 1.43.0)
90
+ gitlab-styles (10.1.0)
91
+ rubocop (~> 1.50.2)
90
92
  rubocop-graphql (~> 0.18)
91
93
  rubocop-performance (~> 1.15)
92
94
  rubocop-rails (~> 2.17)
93
- rubocop-rspec (~> 2.18)
94
- guard (2.18.0)
95
+ rubocop-rspec (~> 2.22)
96
+ guard (2.18.1)
95
97
  formatador (>= 0.2.4)
96
98
  listen (>= 2.7, < 4.0)
97
99
  lumberjack (>= 1.0.12, < 2.0)
@@ -105,7 +107,7 @@ GEM
105
107
  guard (~> 2.1)
106
108
  guard-compat (~> 1.1)
107
109
  rspec (>= 2.99.0, < 4.0)
108
- hashdiff (1.0.1)
110
+ hashdiff (1.1.0)
109
111
  http (5.1.1)
110
112
  addressable (~> 2.8)
111
113
  http-cookie (~> 1.0)
@@ -117,45 +119,52 @@ GEM
117
119
  httparty (0.21.0)
118
120
  mini_mime (>= 1.0.0)
119
121
  multi_xml (>= 0.5.2)
120
- i18n (1.13.0)
122
+ i18n (1.14.1)
121
123
  concurrent-ruby (~> 1.0)
122
- jaro_winkler (1.5.4)
123
- json (2.6.3)
124
+ jaro_winkler (1.5.6)
125
+ json (2.7.1)
124
126
  kramdown (2.4.0)
125
127
  rexml
126
128
  kramdown-parser-gfm (1.1.0)
127
129
  kramdown (~> 2.0)
128
- lefthook (1.3.11)
130
+ lefthook (1.6.1)
129
131
  listen (3.8.0)
130
132
  rb-fsevent (~> 0.10, >= 0.10.3)
131
133
  rb-inotify (~> 0.9, >= 0.9.10)
132
134
  llhttp-ffi (0.4.0)
133
135
  ffi-compiler (~> 1.0)
134
136
  rake (~> 13.0)
135
- lumberjack (1.2.8)
137
+ lumberjack (1.2.10)
136
138
  method_source (1.0.0)
137
- mini_mime (1.1.2)
138
- mini_portile2 (2.8.1)
139
- minitest (5.18.0)
139
+ mini_mime (1.1.5)
140
+ mini_portile2 (2.8.5)
141
+ minitest (5.21.2)
140
142
  mize (0.4.1)
141
143
  protocol (~> 2.0)
142
144
  multi_xml (0.6.0)
143
145
  nap (1.1.0)
144
146
  nenv (0.3.0)
147
+ net-http (0.4.1)
148
+ uri
145
149
  no_proxy_fix (0.1.2)
146
- nokogiri (1.14.3)
147
- mini_portile2 (~> 2.8.0)
150
+ nokogiri (1.16.0)
151
+ mini_portile2 (~> 2.8.2)
148
152
  racc (~> 1.4)
149
153
  notiffany (0.1.3)
150
154
  nenv (~> 0.1)
151
155
  shellany (~> 0.0)
152
- octokit (5.6.1)
156
+ octokit (8.0.0)
153
157
  faraday (>= 1, < 3)
154
158
  sawyer (~> 0.9)
155
159
  open4 (1.3.4)
156
- parallel (1.23.0)
157
- parser (3.2.2.1)
160
+ parallel (1.24.0)
161
+ parser (3.3.0.5)
158
162
  ast (~> 2.4.1)
163
+ racc
164
+ proc_to_ast (0.1.0)
165
+ coderay
166
+ parser
167
+ unparser
159
168
  protocol (2.0.0)
160
169
  ruby_parser (~> 3.0)
161
170
  pry (0.14.2)
@@ -164,20 +173,20 @@ GEM
164
173
  pry-byebug (3.10.1)
165
174
  byebug (~> 11.0)
166
175
  pry (>= 0.13, < 0.15)
167
- public_suffix (5.0.1)
168
- racc (1.6.2)
169
- rack (3.0.7)
176
+ public_suffix (5.0.4)
177
+ racc (1.7.3)
178
+ rack (3.0.8)
170
179
  rainbow (3.1.1)
171
- rake (13.0.6)
180
+ rake (13.1.0)
172
181
  rb-fsevent (0.11.2)
173
182
  rb-inotify (0.10.1)
174
183
  ffi (~> 1.0)
175
184
  rbs (2.8.4)
176
185
  rchardet (1.8.0)
177
- regexp_parser (2.8.0)
186
+ regexp_parser (2.9.0)
178
187
  reverse_markdown (2.1.1)
179
188
  nokogiri
180
- rexml (3.2.5)
189
+ rexml (3.2.6)
181
190
  rspec (3.12.0)
182
191
  rspec-core (~> 3.12.0)
183
192
  rspec-expectations (~> 3.12.0)
@@ -187,44 +196,59 @@ GEM
187
196
  rspec-expectations (3.12.3)
188
197
  diff-lcs (>= 1.2.0, < 2.0)
189
198
  rspec-support (~> 3.12.0)
190
- rspec-mocks (3.12.5)
199
+ rspec-mocks (3.12.6)
191
200
  diff-lcs (>= 1.2.0, < 2.0)
192
201
  rspec-support (~> 3.12.0)
193
- rspec-support (3.12.0)
194
- rubocop (1.43.0)
202
+ rspec-parameterized (1.0.0)
203
+ rspec-parameterized-core (< 2)
204
+ rspec-parameterized-table_syntax (< 2)
205
+ rspec-parameterized-core (1.0.0)
206
+ parser
207
+ proc_to_ast
208
+ rspec (>= 2.13, < 4)
209
+ unparser
210
+ rspec-parameterized-table_syntax (1.0.1)
211
+ binding_of_caller
212
+ rspec-parameterized-core (< 2)
213
+ rspec-support (3.12.1)
214
+ rubocop (1.50.2)
195
215
  json (~> 2.3)
196
216
  parallel (~> 1.10)
197
217
  parser (>= 3.2.0.0)
198
218
  rainbow (>= 2.2.2, < 4.0)
199
219
  regexp_parser (>= 1.8, < 3.0)
200
220
  rexml (>= 3.2.5, < 4.0)
201
- rubocop-ast (>= 1.24.1, < 2.0)
221
+ rubocop-ast (>= 1.28.0, < 2.0)
202
222
  ruby-progressbar (~> 1.7)
203
223
  unicode-display_width (>= 2.4.0, < 3.0)
204
- rubocop-ast (1.28.0)
224
+ rubocop-ast (1.30.0)
205
225
  parser (>= 3.2.1.0)
206
- rubocop-capybara (2.18.0)
226
+ rubocop-capybara (2.20.0)
227
+ rubocop (~> 1.41)
228
+ rubocop-factory_bot (2.25.1)
207
229
  rubocop (~> 1.41)
208
230
  rubocop-graphql (0.19.0)
209
231
  rubocop (>= 0.87, < 2)
210
- rubocop-performance (1.17.1)
211
- rubocop (>= 1.7.0, < 2.0)
212
- rubocop-ast (>= 0.4.0)
213
- rubocop-rails (2.19.1)
232
+ rubocop-performance (1.20.2)
233
+ rubocop (>= 1.48.1, < 2.0)
234
+ rubocop-ast (>= 1.30.0, < 2.0)
235
+ rubocop-rails (2.23.1)
214
236
  activesupport (>= 4.2.0)
215
237
  rack (>= 1.1)
216
238
  rubocop (>= 1.33.0, < 2.0)
217
- rubocop-rspec (2.20.0)
218
- rubocop (~> 1.33)
239
+ rubocop-ast (>= 1.30.0, < 2.0)
240
+ rubocop-rspec (2.26.1)
241
+ rubocop (~> 1.40)
219
242
  rubocop-capybara (~> 2.17)
243
+ rubocop-factory_bot (~> 2.22)
220
244
  ruby-progressbar (1.13.0)
221
- ruby2_keywords (0.0.5)
222
- ruby_parser (3.20.3)
245
+ ruby_parser (3.21.0)
246
+ racc (~> 1.5)
223
247
  sexp_processor (~> 4.16)
224
248
  sawyer (0.9.2)
225
249
  addressable (>= 2.3.5)
226
250
  faraday (>= 0.17.3, < 3)
227
- sexp_processor (4.17.0)
251
+ sexp_processor (4.17.1)
228
252
  shellany (0.0.1)
229
253
  simplecov (0.22.0)
230
254
  docile (~> 1.1)
@@ -235,7 +259,7 @@ GEM
235
259
  simplecov (~> 0.19)
236
260
  simplecov-html (0.12.3)
237
261
  simplecov_json_formatter (0.1.4)
238
- solargraph (0.49.0)
262
+ solargraph (0.50.0)
239
263
  backport (~> 1.2)
240
264
  benchmark
241
265
  bundler (~> 2.0)
@@ -255,23 +279,24 @@ GEM
255
279
  table_print (1.5.7)
256
280
  terminal-table (3.0.2)
257
281
  unicode-display_width (>= 1.1.1, < 3)
258
- thor (1.2.1)
259
- tilt (2.1.0)
260
- timecop (0.9.6)
282
+ thor (1.3.0)
283
+ tilt (2.3.0)
284
+ timecop (0.9.8)
261
285
  tins (1.32.1)
262
286
  sync
263
287
  tzinfo (2.0.6)
264
288
  concurrent-ruby (~> 1.0)
265
- unf (0.1.4)
266
- unf_ext
267
- unf_ext (0.0.8.2)
268
- unicode-display_width (2.4.2)
289
+ unicode-display_width (2.5.0)
290
+ unparser (0.6.12)
291
+ diff-lcs (~> 1.3)
292
+ parser (>= 3.2.2.4)
293
+ uri (0.13.0)
269
294
  webmock (3.7.0)
270
295
  addressable (>= 2.3.6)
271
296
  crack (>= 0.3.2)
272
297
  hashdiff (>= 0.4.0, < 2.0.0)
273
298
  yard (0.9.34)
274
- zeitwerk (2.6.7)
299
+ zeitwerk (2.6.12)
275
300
 
276
301
  PLATFORMS
277
302
  ruby
@@ -293,4 +318,4 @@ DEPENDENCIES
293
318
  webmock (= 3.7.0)
294
319
 
295
320
  BUNDLED WITH
296
- 2.4.2
321
+ 2.5.4
data/README.md CHANGED
@@ -141,15 +141,32 @@ Usage: exe/slow-test-issues [options]
141
141
  -h, --help Show the usage
142
142
  ```
143
143
 
144
+ ### `exe/knapsack-report-issues`
145
+
146
+ ```shell
147
+ Purpose: Create spec run time issue when a spec file almost caused job timeout because it ran significantly longer than what Knapsack expected.
148
+ Usage: exe/knapsack-report-issues [options]
149
+ -i, --input-file INPUT_FILE Knapsack actual run time report file path glob
150
+ -e EXPECTED_REPORT, Knapsack expected report file path
151
+ --expected-report
152
+ -p, --project PROJECT Can be an integer or a group/project string
153
+ -t, --token TOKEN A valid access token with `api` scope and Maintainer permission in PROJECT
154
+ --dry-run Perform a dry-run (don't create issues)
155
+ -v, --version Show the version
156
+ -h, --help Show the usage
157
+ ```
158
+
144
159
  ### `exe/flaky-test-issues`
145
160
 
146
161
  ```shell
147
- Purpose: Purpose: Create flaky test issues for any passed test coming from rspec-retry JSON report files
162
+ Purpose: Create flaky test issues for any passed test coming from rspec-retry JSON report files.
148
163
  Usage: exe/flaky-test-issues [options]
149
164
  -i, --input-files INPUT_FILES JSON rspec-retry report files
150
165
  -p, --project PROJECT Can be an integer or a group/project string
151
166
  -m MERGE_REQUEST_IID, An integer merge request IID
152
167
  --merge_request_iid
168
+ --base-issue-labels BASE_ISSUE_LABELS
169
+ Comma-separated labels (without tilde) to add to new flaky test issues
153
170
  -t, --token TOKEN A valid access token with `api` scope and Maintainer permission in PROJECT
154
171
  --dry-run Perform a dry-run (don't create issues)
155
172
  -v, --version Show the version
@@ -171,6 +188,22 @@ Usage: exe/slow-test-merge-request-report-note [options]
171
188
  -h, --help Show the usage
172
189
  ```
173
190
 
191
+ ### `exe/update-test-meta`
192
+
193
+ ```shell
194
+ Purpose: Add quarantine or reliable meta to specs
195
+ Usage: exe/update-test-meta [options]
196
+ -u INPUT_FILES, File with list of unstable specs (JSON) to quarantine
197
+ --unstable-specs-file
198
+ -s INPUT_FILES, File with list of stable specs (JSON) to add :reliable meta
199
+ --stable-specs-file
200
+ -p, --project PROJECT Can be an integer or a group/project string
201
+ -t, --token TOKEN A valid access token with `api` scope and Maintainer permission in PROJECT
202
+ --dry-run Perform a dry-run (don't create branches, commits or MRs)
203
+ -v, --version Show the version
204
+ -h, --help Show the usage
205
+ ```
206
+
174
207
  ## Development
175
208
 
176
209
  ### Initial setup
@@ -217,7 +250,7 @@ If you forget to set the changelog entry in your commit messages, you can also e
217
250
 
218
251
  ### Steps to release
219
252
 
220
- Use a `Release` merge request template and create a merge requet to update the version number in `version.rb`, and get the merge request merged by a maintainer.
253
+ 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.
221
254
 
222
255
  This will then be packaged into a gem and pushed to [rubygems.org](https://rubygems.org) by the CI/CD.
223
256
 
@@ -19,14 +19,19 @@ options = OptionParser.new do |opts|
19
19
  params[:project] = project
20
20
  end
21
21
 
22
- opts.on('-m', '--merge_request_iid MERGE_REQUEST_IID', String, 'An integer merge request IID') do |merge_request_iid|
23
- params[:merge_request_iid] = merge_request_iid
22
+ opts.on('--base-issue-labels BASE_ISSUE_LABELS', String,
23
+ 'Comma-separated labels (without tilde) to add to new flaky test issues') do |base_issue_labels|
24
+ params[:base_issue_labels] = base_issue_labels.split(',')
24
25
  end
25
26
 
26
27
  opts.on('-t', '--token TOKEN', String, 'A valid access token with `api` scope and Maintainer permission in PROJECT') do |token|
27
28
  params[:token] = token
28
29
  end
29
30
 
31
+ opts.on('-r', '--related-issues-file RELATED_ISSUES_FILE', String, 'The file path for the related issues') do |related_issues_file|
32
+ params[:related_issues_file] = related_issues_file
33
+ end
34
+
30
35
  opts.on('--dry-run', "Perform a dry-run (don't create issues)") do
31
36
  params[:dry_run] = true
32
37
  end
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "optparse"
6
+
7
+ require_relative "../lib/gitlab_quality/test_tooling"
8
+
9
+ params = {}
10
+
11
+ options = OptionParser.new do |opts|
12
+ opts.banner = "Usage: #{$PROGRAM_NAME} [options]"
13
+
14
+ opts.on("-i", "--input-file INPUT_FILE", String, "Knapsack actual run time report file path glob") do |input_file|
15
+ params[:input_files] = input_file
16
+ end
17
+
18
+ opts.on("-e", "--expected-report EXPECTED_REPORT", String, "Knapsack expected report file path") do |report_path|
19
+ params[:expected_report] = report_path.strip
20
+ end
21
+
22
+ opts.on('-p', '--project PROJECT', String, 'Can be an integer or a group/project string') do |project|
23
+ params[:project] = project
24
+ end
25
+
26
+ opts.on('-t', '--token TOKEN', String, 'A valid access token with `api` scope and Maintainer permission in PROJECT') do |token|
27
+ params[:token] = token
28
+ end
29
+
30
+ opts.on('--dry-run', "Perform a dry-run (don't create issues)") do
31
+ params[:dry_run] = true
32
+ end
33
+
34
+ opts.on_tail('-v', '--version', 'Show the version') do
35
+ require_relative "../lib/gitlab_quality/test_tooling/version"
36
+ puts "#{$PROGRAM_NAME} : #{GitlabQuality::TestTooling::VERSION}"
37
+ exit
38
+ end
39
+
40
+ opts.on_tail('-h', '--help', 'Show the usage') do
41
+ puts "Purpose: Create spec run time issue when a spec file almost caused job timeout because it ran significantly longer than what Knapsack expected."
42
+ puts opts
43
+ exit
44
+ end
45
+
46
+ opts.parse(ARGV)
47
+ end
48
+
49
+ if params.any?
50
+ GitlabQuality::TestTooling::Report::KnapsackReportIssue.new(**params).invoke!
51
+ else
52
+ puts options
53
+ exit 1
54
+ end
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "optparse"
6
+
7
+ require_relative "../lib/gitlab_quality/test_tooling"
8
+
9
+ params = {}
10
+
11
+ options = OptionParser.new do |opts|
12
+ opts.banner = "Usage: #{$PROGRAM_NAME} [options]"
13
+
14
+ opts.on('-u', '--unstable-specs-file INPUT_FILES', String, 'File with list of unstable specs (JSON) to quarantine') do |unstable_specs_file|
15
+ params[:unstable_specs_file] = unstable_specs_file
16
+ end
17
+
18
+ opts.on('-s', '--stable-specs-file INPUT_FILES', String, 'File with list of stable specs (JSON) to add :blocking meta') do |stable_specs_file|
19
+ params[:stable_specs_file] = stable_specs_file
20
+ end
21
+
22
+ opts.on('-p', '--project PROJECT', String, 'Can be an integer or a group/project string') do |project|
23
+ params[:project] = project
24
+ end
25
+
26
+ opts.on('-t', '--token TOKEN', String, 'A valid access token with `api` scope and Maintainer permission in PROJECT') do |token|
27
+ params[:token] = token
28
+ end
29
+
30
+ opts.on('--dry-run', "Perform a dry-run (don't create branches, commits or MRs)") do
31
+ params[:dry_run] = true
32
+ end
33
+
34
+ opts.on_tail('-v', '--version', 'Show the version') do
35
+ require_relative "../lib/gitlab_quality/test_tooling/version"
36
+ puts "#{$PROGRAM_NAME} : #{GitlabQuality::TestTooling::VERSION}"
37
+ exit
38
+ end
39
+
40
+ opts.on_tail('-h', '--help', 'Show the usage') do
41
+ puts "Purpose: Add quarantine or blocking meta to specs"
42
+ puts opts
43
+ exit
44
+ end
45
+
46
+ opts.parse(ARGV)
47
+ end
48
+
49
+ if params.any?
50
+ if params[:unstable_specs_file] && params[:stable_specs_file]
51
+ puts "Please provide only one of one of -u and -s"
52
+ exit 1
53
+ elsif !params[:unstable_specs_file] && !params[:stable_specs_file]
54
+ puts "Please provide at least one of one of -u and -s"
55
+ exit 1
56
+ end
57
+
58
+ if params[:unstable_specs_file]
59
+ params[:specs_file] = params.delete(:unstable_specs_file)
60
+ params[:processor] = GitlabQuality::TestTooling::TestMeta::Processor::AddToQuarantineProcessor
61
+ else
62
+ params[:specs_file] = params.delete(:stable_specs_file)
63
+ params[:processor] = GitlabQuality::TestTooling::TestMeta::Processor::AddToBlockingProcessor
64
+ end
65
+
66
+ GitlabQuality::TestTooling::TestMeta::TestMetaUpdater.new(**params).invoke!
67
+ else
68
+ puts options
69
+ exit 1
70
+ end
data/lefthook.yml CHANGED
@@ -13,3 +13,16 @@ pre-push:
13
13
  rubocop:
14
14
  run: bundle exec rubocop
15
15
  glob: '*.rb'
16
+
17
+ # Changelog git trailer for the first commit of the branch
18
+ changelog-on-first-commit:
19
+ run: |
20
+ first_commit_message=$(git log --format=%B -n 1 $(git log main..HEAD --pretty=format:"%h" | tail -1))
21
+ if ! echo ${first_commit_message} | grep "Changelog:"; then
22
+ echo Could not find a Changelog: git trailer on the first commit for this branch.
23
+ echo
24
+ echo Please add a trailer by amending the git commit message.
25
+ echo
26
+ echo See https://docs.gitlab.com/ee/development/changelog.html#overview for more info.
27
+ exit 1
28
+ fi
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+
5
+ module GitlabQuality
6
+ module TestTooling
7
+ module Concerns
8
+ module FindSetDri
9
+ def set_dri_via_group(product_group, stage)
10
+ parse_json_with_sets
11
+ fetch_stage_sets(stage)
12
+
13
+ return @sets.sample['username'] if @stage_sets.empty?
14
+
15
+ fetch_group_sets(product_group)
16
+
17
+ if @group_sets.empty?
18
+ @stage_sets.sample['username']
19
+ else
20
+ @group_sets.sample['username']
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def parse_json_with_sets
27
+ response = Support::HttpRequest.make_http_request(
28
+ url: 'https://gitlab-org.gitlab.io/gitlab-roulette/roulette.json'
29
+ )
30
+ @sets = JSON.parse(response.body).select { |user| user['role'].include?('software-engineer-in-test') }
31
+ end
32
+
33
+ def fetch_stage_sets(stage)
34
+ @stage_sets = @sets.select do |user|
35
+ user['role'].include?(stage.split("_").map(&:capitalize).join(" "))
36
+ end
37
+ end
38
+
39
+ def fetch_group_sets(product_group)
40
+ @group_sets = @stage_sets.select do |user|
41
+ user['role'].downcase.tr(' ', '_').include?(product_group)
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GitlabQuality
4
+ module TestTooling
5
+ module GitlabClient
6
+ class BranchesClient < GitlabClient
7
+ def create(branch_name, ref)
8
+ branch = handle_gitlab_client_exceptions do
9
+ client.create_branch(project, branch_name, ref)
10
+ end
11
+
12
+ Runtime::Logger.debug("Created branch #{branch['name']} (#{branch['web_url']})") if branch
13
+ branch
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GitlabQuality
4
+ module TestTooling
5
+ module GitlabClient
6
+ class BranchesDryClient < BranchesClient
7
+ def create(branch_name, ref)
8
+ branch = { 'name' => branch_name, 'web_url' => 'https://example.com/dummy/branch/url' }
9
+ puts "A branch would have been created with name: #{branch['name']}, web_url: #{branch['web_url']} and ref: #{ref}"
10
+ branch
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end