dri 0.10.2 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +2 -2
- data/.rubocop.yml +9 -1
- data/.ruby-version +1 -1
- data/.tool-versions +1 -1
- data/Gemfile.lock +39 -32
- data/README.md +2 -17
- data/dri.gemspec +5 -4
- data/faq.yaml +7 -7
- data/lib/dri/api_client.rb +48 -2
- data/lib/dri/cli.rb +6 -0
- data/lib/dri/command.rb +4 -1
- data/lib/dri/commands/add/fast_quarantine.rb +74 -0
- data/lib/dri/commands/add.rb +46 -0
- data/lib/dri/commands/analyze/stack_traces.rb +1 -1
- data/lib/dri/commands/faq.rb +1 -1
- data/lib/dri/commands/fetch/failures.rb +82 -23
- data/lib/dri/commands/fetch/featureflags.rb +1 -1
- data/lib/dri/commands/fetch/pipelines.rb +3 -3
- data/lib/dri/commands/fetch/runbooks.rb +1 -1
- data/lib/dri/commands/fetch/testcases.rb +1 -1
- data/lib/dri/commands/fetch/triaged.rb +1 -1
- data/lib/dri/commands/fetch.rb +0 -24
- data/lib/dri/commands/incidents.rb +1 -1
- data/lib/dri/commands/init.rb +1 -1
- data/lib/dri/commands/profile.rb +3 -3
- data/lib/dri/commands/publish/report.rb +2 -4
- data/lib/dri/commands/rm/emoji.rb +1 -1
- data/lib/dri/commands/rm/profile.rb +1 -1
- data/lib/dri/commands/rm/reports.rb +1 -1
- data/lib/dri/commands/view/fast_quarantine.rb +27 -0
- data/lib/dri/commands/view.rb +23 -0
- data/lib/dri/feature_flag_report.rb +1 -1
- data/lib/dri/report.rb +12 -52
- data/lib/dri/support/influxdb_tools.rb +37 -0
- data/lib/dri/utils/constants.rb +2 -1
- data/lib/dri/version.rb +1 -1
- metadata +26 -8
- data/lib/dri/commands/fetch/quarantines.rb +0 -55
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 030e595feea9f3659c75e7079815b88eb654b124a338211f9226cb979ad73a5c
|
4
|
+
data.tar.gz: 29ff03db73c44f4aee4d905820e423477e43a182cbc85677ff21a0ea54c98a28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf0b085cff259d0e0bb3f3cffe31699bb50c6b900239d1cad1cd270333097094ae73d0478fe870681d8609f968bbea8a26c85c900c8717c65447e3c5266672cc
|
7
|
+
data.tar.gz: 0da07b06c6052457549eac9b7f116248dd4d534dee659a3fa8bcccb4d55fd796fd4ae4d328914d6ed1e4cf7026fe1fab9cfda2f9bced61d0848eb4276c49ba08
|
data/.gitlab-ci.yml
CHANGED
@@ -26,7 +26,7 @@ include:
|
|
26
26
|
- /ci/ref-update.gitlab-ci.yml
|
27
27
|
|
28
28
|
variables:
|
29
|
-
RUBY_VERSION: "3.
|
29
|
+
RUBY_VERSION: "3.1"
|
30
30
|
|
31
31
|
stages:
|
32
32
|
- build
|
@@ -53,6 +53,6 @@ rspec:
|
|
53
53
|
extends: .job_base
|
54
54
|
parallel:
|
55
55
|
matrix:
|
56
|
-
- RUBY_VERSION: ['
|
56
|
+
- RUBY_VERSION: ['3.0', '3.1']
|
57
57
|
script:
|
58
58
|
- bundle exec rspec --force-color
|
data/.rubocop.yml
CHANGED
@@ -10,7 +10,9 @@ inherit_gem:
|
|
10
10
|
- rubocop-style.yml
|
11
11
|
|
12
12
|
AllCops:
|
13
|
-
TargetRubyVersion:
|
13
|
+
TargetRubyVersion: 3.0
|
14
|
+
SuggestExtensions: false
|
15
|
+
NewCops: enable
|
14
16
|
|
15
17
|
RSpec/MultipleMemoizedHelpers:
|
16
18
|
Max: 25
|
@@ -51,3 +53,9 @@ Lint/RedundantSafeNavigation:
|
|
51
53
|
|
52
54
|
Style/ClassEqualityComparison:
|
53
55
|
Enabled: true
|
56
|
+
|
57
|
+
InternalAffairs/MissingCopDepartment:
|
58
|
+
Enabled: false
|
59
|
+
|
60
|
+
Gemspec/RequireMFA:
|
61
|
+
Enabled: false
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.1.4
|
data/.tool-versions
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby 3.
|
1
|
+
ruby 3.1.4
|
data/Gemfile.lock
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dri (0.
|
4
|
+
dri (0.11.0)
|
5
5
|
amatch (~> 0.4.1)
|
6
6
|
gitlab (~> 4.19)
|
7
7
|
httparty (~> 0.21.0)
|
8
|
+
influxdb-client (~> 2.9)
|
8
9
|
json (~> 2.6.1)
|
9
10
|
launchy (~> 2.4)
|
10
11
|
markdown-tables (~> 1.1.1)
|
@@ -23,7 +24,7 @@ PATH
|
|
23
24
|
GEM
|
24
25
|
remote: https://rubygems.org/
|
25
26
|
specs:
|
26
|
-
activesupport (7.0.
|
27
|
+
activesupport (7.0.6)
|
27
28
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
28
29
|
i18n (>= 1.6, < 2)
|
29
30
|
minitest (>= 5.1)
|
@@ -42,19 +43,19 @@ GEM
|
|
42
43
|
gitlab (4.19.0)
|
43
44
|
httparty (~> 0.20)
|
44
45
|
terminal-table (>= 1.5.1)
|
45
|
-
gitlab-styles (
|
46
|
-
rubocop (~>
|
47
|
-
rubocop-
|
48
|
-
rubocop-
|
49
|
-
rubocop-
|
50
|
-
rubocop-
|
51
|
-
rubocop-rspec (~> 1.44)
|
46
|
+
gitlab-styles (10.1.0)
|
47
|
+
rubocop (~> 1.50.2)
|
48
|
+
rubocop-graphql (~> 0.18)
|
49
|
+
rubocop-performance (~> 1.15)
|
50
|
+
rubocop-rails (~> 2.17)
|
51
|
+
rubocop-rspec (~> 2.22)
|
52
52
|
hashdiff (1.0.1)
|
53
53
|
httparty (0.21.0)
|
54
54
|
mini_mime (>= 1.0.0)
|
55
55
|
multi_xml (>= 0.5.2)
|
56
|
-
i18n (1.
|
56
|
+
i18n (1.14.1)
|
57
57
|
concurrent-ruby (~> 1.0)
|
58
|
+
influxdb-client (2.9.0)
|
58
59
|
json (2.6.3)
|
59
60
|
kramdown (2.4.0)
|
60
61
|
rexml
|
@@ -63,13 +64,14 @@ GEM
|
|
63
64
|
markdown-tables (1.1.1)
|
64
65
|
method_source (1.0.0)
|
65
66
|
mini_mime (1.1.2)
|
66
|
-
minitest (5.18.
|
67
|
+
minitest (5.18.1)
|
67
68
|
mize (0.4.1)
|
68
69
|
protocol (~> 2.0)
|
69
70
|
multi_xml (0.6.0)
|
70
71
|
parallel (1.23.0)
|
71
|
-
parser (3.2.2.
|
72
|
+
parser (3.2.2.3)
|
72
73
|
ast (~> 2.4.1)
|
74
|
+
racc
|
73
75
|
pastel (0.8.0)
|
74
76
|
tty-color (~> 0.5)
|
75
77
|
protocol (2.0.0)
|
@@ -78,10 +80,11 @@ GEM
|
|
78
80
|
coderay (~> 1.1)
|
79
81
|
method_source (~> 1.0)
|
80
82
|
public_suffix (5.0.1)
|
81
|
-
|
83
|
+
racc (1.7.1)
|
84
|
+
rack (3.0.8)
|
82
85
|
rainbow (3.1.1)
|
83
86
|
rake (13.0.6)
|
84
|
-
regexp_parser (2.8.
|
87
|
+
regexp_parser (2.8.1)
|
85
88
|
rexml (3.2.5)
|
86
89
|
rouge (4.1.1)
|
87
90
|
rspec (3.10.0)
|
@@ -97,31 +100,35 @@ GEM
|
|
97
100
|
diff-lcs (>= 1.2.0, < 2.0)
|
98
101
|
rspec-support (~> 3.10.0)
|
99
102
|
rspec-support (3.10.3)
|
100
|
-
rubocop (
|
103
|
+
rubocop (1.50.2)
|
104
|
+
json (~> 2.3)
|
101
105
|
parallel (~> 1.10)
|
102
|
-
parser (>= 2.
|
106
|
+
parser (>= 3.2.0.0)
|
103
107
|
rainbow (>= 2.2.2, < 4.0)
|
104
|
-
regexp_parser (>= 1.8)
|
105
|
-
rexml
|
106
|
-
rubocop-ast (>=
|
108
|
+
regexp_parser (>= 1.8, < 3.0)
|
109
|
+
rexml (>= 3.2.5, < 4.0)
|
110
|
+
rubocop-ast (>= 1.28.0, < 2.0)
|
107
111
|
ruby-progressbar (~> 1.7)
|
108
|
-
unicode-display_width (>=
|
109
|
-
rubocop-ast (1.
|
112
|
+
unicode-display_width (>= 2.4.0, < 3.0)
|
113
|
+
rubocop-ast (1.29.0)
|
110
114
|
parser (>= 3.2.1.0)
|
111
|
-
rubocop-
|
112
|
-
rubocop (
|
115
|
+
rubocop-capybara (2.18.0)
|
116
|
+
rubocop (~> 1.41)
|
117
|
+
rubocop-factory_bot (2.23.1)
|
118
|
+
rubocop (~> 1.33)
|
113
119
|
rubocop-graphql (0.19.0)
|
114
120
|
rubocop (>= 0.87, < 2)
|
115
|
-
rubocop-performance (1.
|
116
|
-
rubocop (>=
|
121
|
+
rubocop-performance (1.18.0)
|
122
|
+
rubocop (>= 1.7.0, < 2.0)
|
117
123
|
rubocop-ast (>= 0.4.0)
|
118
|
-
rubocop-rails (2.
|
124
|
+
rubocop-rails (2.20.2)
|
119
125
|
activesupport (>= 4.2.0)
|
120
126
|
rack (>= 1.1)
|
121
|
-
rubocop (>=
|
122
|
-
rubocop-rspec (
|
123
|
-
rubocop (~>
|
124
|
-
rubocop-
|
127
|
+
rubocop (>= 1.33.0, < 2.0)
|
128
|
+
rubocop-rspec (2.22.0)
|
129
|
+
rubocop (~> 1.33)
|
130
|
+
rubocop-capybara (~> 2.17)
|
131
|
+
rubocop-factory_bot (~> 2.22)
|
125
132
|
ruby-progressbar (1.13.0)
|
126
133
|
ruby_parser (3.20.1)
|
127
134
|
sexp_processor (~> 4.16)
|
@@ -173,7 +180,7 @@ GEM
|
|
173
180
|
tty-screen (~> 0.8)
|
174
181
|
tzinfo (2.0.6)
|
175
182
|
concurrent-ruby (~> 1.0)
|
176
|
-
unicode-display_width (
|
183
|
+
unicode-display_width (2.4.2)
|
177
184
|
unicode_utils (1.4.0)
|
178
185
|
webmock (3.18.1)
|
179
186
|
addressable (>= 2.8.0)
|
@@ -186,7 +193,7 @@ PLATFORMS
|
|
186
193
|
|
187
194
|
DEPENDENCIES
|
188
195
|
dri!
|
189
|
-
gitlab-styles (~>
|
196
|
+
gitlab-styles (~> 10)
|
190
197
|
pry (~> 0.14.1)
|
191
198
|
rake (~> 13.0)
|
192
199
|
rspec (~> 3.10.0)
|
data/README.md
CHANGED
@@ -56,8 +56,6 @@ $ dri profile
|
|
56
56
|
- failures
|
57
57
|
- testcases
|
58
58
|
- triaged
|
59
|
-
- quarantines
|
60
|
-
- dequarantines
|
61
59
|
- featureflags
|
62
60
|
- runbooks
|
63
61
|
- [4. publish](#4-publish)
|
@@ -103,8 +101,8 @@ There is the possibility to customise the timeframe for such failures by passing
|
|
103
101
|
a `--cutoff=HH:MM` to just show failures after a certain period of the day. The cutoff
|
104
102
|
time will be converted to UTC.
|
105
103
|
|
106
|
-
|
107
|
-
|
104
|
+
Smoke and Reliable failures will be highlighted in bold and in between *'s. These require
|
105
|
+
to have set `QA_INFLUXDB_URL` and `QA_INFLUXDB_TOKEN` environment variables to be found in 1Password.
|
108
106
|
|
109
107
|
```shell
|
110
108
|
$ dri fetch testcases
|
@@ -120,19 +118,6 @@ $ dri fetch triaged
|
|
120
118
|
|
121
119
|
Fetches triaged failures which use the triage emoji specified in `dri profile`.
|
122
120
|
|
123
|
-
```shell
|
124
|
-
$ dri fetch quarantines
|
125
|
-
```
|
126
|
-
|
127
|
-
Fetches open quarantine Merge Requests to be reviewed
|
128
|
-
|
129
|
-
```shell
|
130
|
-
$ dri fetch dequarantines
|
131
|
-
```
|
132
|
-
|
133
|
-
Fetches open dequarantine Merge Requests to be reviewed
|
134
|
-
|
135
|
-
Results are organized by environment (production, staging, staging ref and preprod).
|
136
121
|
```shell
|
137
122
|
$ dri fetch featureflags
|
138
123
|
```
|
data/dri.gemspec
CHANGED
@@ -6,12 +6,12 @@ Gem::Specification.new do |spec|
|
|
6
6
|
spec.name = 'dri'
|
7
7
|
spec.license = 'MIT'
|
8
8
|
spec.version = Dri::VERSION
|
9
|
-
spec.authors = ['
|
9
|
+
spec.authors = ['Test Platform']
|
10
10
|
spec.email = ['quality+dri@gitlab.com']
|
11
11
|
|
12
12
|
spec.summary = 'CLI app to help triage GitLab QA pipelines'
|
13
|
-
spec.homepage = 'https://gitlab.com/gitlab-org/
|
14
|
-
spec.required_ruby_version =
|
13
|
+
spec.homepage = 'https://gitlab.com/gitlab-org/ruby/gems/dri'
|
14
|
+
spec.required_ruby_version = '>= 3.0.0'
|
15
15
|
|
16
16
|
# Specify which files should be added to the gem when it is released.
|
17
17
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_dependency 'amatch', '~> 0.4.1'
|
26
26
|
spec.add_dependency "gitlab", "~> 4.19"
|
27
27
|
spec.add_dependency 'httparty', '~> 0.21.0'
|
28
|
+
spec.add_dependency 'influxdb-client', '~> 2.9'
|
28
29
|
spec.add_dependency 'json', '~> 2.6.1'
|
29
30
|
spec.add_dependency 'launchy', '~> 2.4'
|
30
31
|
spec.add_dependency 'markdown-tables', '~> 1.1.1'
|
@@ -40,7 +41,7 @@ Gem::Specification.new do |spec|
|
|
40
41
|
spec.add_dependency 'tty-spinner', '~> 0.9'
|
41
42
|
spec.add_dependency 'tty-table', '~> 0.12.0'
|
42
43
|
|
43
|
-
spec.add_development_dependency 'gitlab-styles', '~>
|
44
|
+
spec.add_development_dependency 'gitlab-styles', '~> 10'
|
44
45
|
spec.add_development_dependency "pry", "~> 0.14.1"
|
45
46
|
spec.add_development_dependency 'rake', "~> 13.0"
|
46
47
|
spec.add_development_dependency 'rspec', '~> 3.10.0'
|
data/faq.yaml
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
---
|
2
2
|
- question: "Which pipelines we currently have and what is their running cadence?"
|
3
|
-
link: "https://about.gitlab.com/handbook/engineering/
|
3
|
+
link: "https://about.gitlab.com/handbook/engineering/infrastructure/test-platform/debugging-qa-test-failures/#qa-test-pipelines"
|
4
4
|
- question: "Where can I find the rotation schedule?"
|
5
5
|
link: "https://gitlab.com/gitlab-org/quality/pipeline-triage#dri-weekly-rotation-schedule"
|
6
6
|
- question: "What is the process to quarantine a test?"
|
7
|
-
link: "https://about.gitlab.com/handbook/engineering/
|
7
|
+
link: "https://about.gitlab.com/handbook/engineering/infrastructure/test-platform/debugging-qa-test-failures/#quarantining-tests"
|
8
8
|
- question: "What is the process to dequarantine a test?"
|
9
|
-
link: "https://about.gitlab.com/handbook/engineering/
|
9
|
+
link: "https://about.gitlab.com/handbook/engineering/infrastructure/test-platform/debugging-qa-test-failures/#dequarantining-tests"
|
10
10
|
- question: "What are the failure classification labels?"
|
11
|
-
link: "https://about.gitlab.com/handbook/engineering/
|
11
|
+
link: "https://about.gitlab.com/handbook/engineering/infrastructure/test-platform/debugging-qa-test-failures/#classify-and-triage-the-test-failure"
|
12
12
|
- question: "I have a correlation ID. How to find logs from various GitLab components?"
|
13
|
-
link: "https://about.gitlab.com/handbook/engineering/
|
13
|
+
link: "https://about.gitlab.com/handbook/engineering/infrastructure/test-platform/debugging-qa-test-failures/#kibana-correlation-dashboards"
|
14
14
|
- question: "Where do I find the MR that introduced a feature flag?"
|
15
15
|
link: "https://samdbeckham.gitlab.io/feature-flags/#%5B%7B%22type%22:%22filtered-search-term%22,%22value%22:%7B%22data%22:%22%22%7D%7D%5D"
|
16
16
|
- question: "What to do when a failure needs escalation?"
|
17
|
-
link: "https://about.gitlab.com/handbook/engineering/
|
17
|
+
link: "https://about.gitlab.com/handbook/engineering/infrastructure/test-platform/debugging-qa-test-failures/#failure-needs-escalation"
|
18
18
|
- question: "I have an MR to fix the failure. How I make sure it is merged as soon as possible?"
|
19
|
-
link: "https://about.gitlab.com/handbook/engineering/
|
19
|
+
link: "https://about.gitlab.com/handbook/engineering/infrastructure/test-platform/debugging-qa-test-failures/#fixing-the-test"
|
20
20
|
|
21
21
|
|
data/lib/dri/api_client.rb
CHANGED
@@ -22,7 +22,7 @@ module Dri
|
|
22
22
|
@ops_token = config.read.dig("settings", "ops_token")
|
23
23
|
if @token.nil? || @ops_token.nil?
|
24
24
|
raise TokenNotProvidedError, "Gitlab API client cannot be initialized without both access tokens. " \
|
25
|
-
|
25
|
+
"Run `dri init` again or `dri profile --edit` to add an ops_token entry."
|
26
26
|
end
|
27
27
|
|
28
28
|
@ops_instance = ops
|
@@ -93,7 +93,7 @@ module Dri
|
|
93
93
|
labels: "#{pipeline}::failed",
|
94
94
|
state: state,
|
95
95
|
scope: "all",
|
96
|
-
|
96
|
+
'not[labels]': QUARANTINE
|
97
97
|
).auto_paginate
|
98
98
|
end
|
99
99
|
|
@@ -313,6 +313,52 @@ module Dri
|
|
313
313
|
gitlab.get_file(project_id, path, ref)
|
314
314
|
end
|
315
315
|
|
316
|
+
def get_fast_quarantine_tests
|
317
|
+
gitlab.file_contents(
|
318
|
+
FAST_QUARANTINE_PROJECT_ID,
|
319
|
+
'rspec/fast_quarantine-gitlab.txt',
|
320
|
+
'main'
|
321
|
+
)
|
322
|
+
end
|
323
|
+
|
324
|
+
def get_failure_issue_title(issue_id)
|
325
|
+
issue = gitlab.issue(GITLAB_PROJECT_ID, issue_id)
|
326
|
+
issue.title
|
327
|
+
end
|
328
|
+
|
329
|
+
def add_test_to_fast_quarantine(failure_url, new_branch, test_path, new_file_content)
|
330
|
+
gitlab.create_branch(
|
331
|
+
FAST_QUARANTINE_PROJECT_ID,
|
332
|
+
new_branch,
|
333
|
+
'main'
|
334
|
+
)
|
335
|
+
|
336
|
+
gitlab.edit_file(
|
337
|
+
FAST_QUARANTINE_PROJECT_ID,
|
338
|
+
'rspec/fast_quarantine-gitlab.txt',
|
339
|
+
new_branch,
|
340
|
+
new_file_content,
|
341
|
+
'Add test to quarantine'
|
342
|
+
)
|
343
|
+
|
344
|
+
gitlab.create_merge_request(
|
345
|
+
FAST_QUARANTINE_PROJECT_ID,
|
346
|
+
"Quarantine #{test_path}", {
|
347
|
+
source_branch: new_branch,
|
348
|
+
target_branch: 'main',
|
349
|
+
description: "Fast quarantine for `#{test_path}`. Failure: #{failure_url}."
|
350
|
+
}
|
351
|
+
)
|
352
|
+
end
|
353
|
+
|
354
|
+
def add_note_failure_issue(issue_id, merge_request)
|
355
|
+
gitlab.create_issue_note(
|
356
|
+
GITLAB_PROJECT_ID,
|
357
|
+
issue_id,
|
358
|
+
"Applying fast quarantine at #{merge_request.web_url}."
|
359
|
+
)
|
360
|
+
end
|
361
|
+
|
316
362
|
private
|
317
363
|
|
318
364
|
attr_reader :token, :ops_token
|
data/lib/dri/cli.rb
CHANGED
@@ -102,5 +102,11 @@ module Dri
|
|
102
102
|
|
103
103
|
require_relative 'commands/analyze'
|
104
104
|
register Dri::Commands::Analyze, 'analyze', 'analyze [SUBCOMMAND]', 'Analysis of test failures and issues'
|
105
|
+
|
106
|
+
require_relative 'commands/view'
|
107
|
+
register Dri::Commands::View, 'view', 'view [SUBCOMMAND]', 'View relevant items to help triage'
|
108
|
+
|
109
|
+
require_relative 'commands/add'
|
110
|
+
register Dri::Commands::Add, 'add', 'add [SUBCOMMAND]', 'Add relevant items to help triage'
|
105
111
|
end
|
106
112
|
end
|
data/lib/dri/command.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'command'
|
4
3
|
require_relative 'api_client'
|
5
4
|
require_relative 'gitlab/issues'
|
6
5
|
|
@@ -79,6 +78,10 @@ module Dri
|
|
79
78
|
@options[:no_color] ? str : pastel.decorate(str, *color)
|
80
79
|
end
|
81
80
|
|
81
|
+
def bold(str)
|
82
|
+
pastel.bold(str)
|
83
|
+
end
|
84
|
+
|
82
85
|
# Execute this command
|
83
86
|
#
|
84
87
|
# @api public
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../command'
|
4
|
+
|
5
|
+
module Dri
|
6
|
+
module Commands
|
7
|
+
class Add
|
8
|
+
class FastQuarantine < Dri::Command
|
9
|
+
def initialize(options)
|
10
|
+
@options = options
|
11
|
+
end
|
12
|
+
|
13
|
+
def execute(*) # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
14
|
+
verify_config_exists
|
15
|
+
|
16
|
+
logger.info "Adding to fast quarantined tests..."
|
17
|
+
current_content = api_client.get_fast_quarantine_tests
|
18
|
+
current_content += "\n" unless current_content.end_with?("\n")
|
19
|
+
|
20
|
+
if @options[:failure_url]
|
21
|
+
failure_url = @options[:failure_url]
|
22
|
+
issue_id = extract_issue_id_from_url(failure_url)
|
23
|
+
|
24
|
+
issue_title = api_client.get_failure_issue_title(issue_id)
|
25
|
+
test_path = extract_file_path(issue_title)
|
26
|
+
|
27
|
+
full_path = "qa/specs/features/#{test_path}"
|
28
|
+
new_file_content = "#{current_content}#{full_path}\n"
|
29
|
+
|
30
|
+
new_branch = "fast-quarantine-failure-#{issue_id}"
|
31
|
+
|
32
|
+
merge_request = api_client.add_test_to_fast_quarantine(
|
33
|
+
failure_url,
|
34
|
+
new_branch,
|
35
|
+
test_path,
|
36
|
+
new_file_content
|
37
|
+
)
|
38
|
+
|
39
|
+
logger.info "Opened an MR to review at #{merge_request.web_url}"
|
40
|
+
|
41
|
+
api_client.add_note_failure_issue(issue_id, merge_request)
|
42
|
+
logger.success "Note added to failure issue with link to fastquarantine merge request"
|
43
|
+
elsif @options[:test_id]
|
44
|
+
test_id = @options[:test_id]
|
45
|
+
parsed_test_name = test_id.match(%r{([^/]+)_spec})[1]
|
46
|
+
new_branch = "fast-quarantine-failure-#{parsed_test_name.tr('_', '-')}"
|
47
|
+
|
48
|
+
new_file_content = "#{current_content}#{test_id}\n"
|
49
|
+
merge_request = api_client.add_test_to_fast_quarantine(
|
50
|
+
"N/A",
|
51
|
+
new_branch,
|
52
|
+
test_id,
|
53
|
+
new_file_content
|
54
|
+
)
|
55
|
+
|
56
|
+
logger.info "Opened an MR to review at #{merge_request.web_url}"
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def extract_issue_id_from_url(url)
|
63
|
+
match = url.match(%r{/issues/(\d+)$})
|
64
|
+
match ? match[1].to_i : nil
|
65
|
+
end
|
66
|
+
|
67
|
+
def extract_file_path(title)
|
68
|
+
match = title.match(/Failure in (.*?\.rb)/)
|
69
|
+
match ? match[1] : nil
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'thor'
|
4
|
+
|
5
|
+
module Dri
|
6
|
+
module Commands
|
7
|
+
class Add < Thor
|
8
|
+
namespace :add
|
9
|
+
# rubocop:disable Layout/LineLength
|
10
|
+
full_description = <<-DESC
|
11
|
+
Creates a fast-quarantine merge request
|
12
|
+
|
13
|
+
Examples:#{' '}
|
14
|
+
dri add fastquarantine -f https://gitlab.com/gitlab-org/gitlab/-/issues/431736 # using failure issue
|
15
|
+
dri add fastquarantine -t qa/specs/features/ee/api/14_model_ops/code_suggestions_spec.rb # using test file
|
16
|
+
dri add fastquarantine -t ee/spec/features/boards/swimlanes/epics_swimlanes_sidebar_spec.rb:42 # using test file and line number
|
17
|
+
dri add fastquarantine -t "spec/tasks/gitlab/usage_data_rake_spec.rb[1:5:2:1]" # using test id
|
18
|
+
DESC
|
19
|
+
desc 'fastquarantine', full_description
|
20
|
+
method_option :failure_url, aliases: '-f', type: :string,
|
21
|
+
desc: 'Failure URL, for example: https://gitlab.com/gitlab-org/gitlab/-/issues/431736'
|
22
|
+
method_option :test_id, aliases: '-t', type: :string,
|
23
|
+
desc: 'Test path, for example: qa/specs/features/ee/api/14_model_ops/code_suggestions_spec.rb'
|
24
|
+
method_option :help, aliases: '-h', type: :boolean,
|
25
|
+
desc: 'Display usage information'
|
26
|
+
# rubocop:enable Layout/LineLength
|
27
|
+
def fastquarantine(*)
|
28
|
+
if options[:help]
|
29
|
+
invoke :help, ['fastquarantine']
|
30
|
+
return
|
31
|
+
end
|
32
|
+
|
33
|
+
if options[:failure_url].nil? && options[:test_id].nil?
|
34
|
+
say 'Validation error: either failure_url or test_id is required.', :red
|
35
|
+
return
|
36
|
+
elsif options[:failure_url] && options[:test_id]
|
37
|
+
say 'Validation error: only one of failure_url or test_id should be provided, not both.', :red
|
38
|
+
return
|
39
|
+
end
|
40
|
+
|
41
|
+
require_relative 'add/fast_quarantine'
|
42
|
+
Dri::Commands::Add::FastQuarantine.new(options).execute
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -20,7 +20,7 @@ module Dri
|
|
20
20
|
@similarity_score_threshold = options[:similarity_score_threshold] || 0.9
|
21
21
|
end
|
22
22
|
|
23
|
-
def execute(
|
23
|
+
def execute(_input: $stdin, output: $stdout) # rubocop:disable Metrics/AbcSize
|
24
24
|
verify_config_exists
|
25
25
|
logger.info "#{Time.now.utc} Fetching issues"
|
26
26
|
|
data/lib/dri/commands/faq.rb
CHANGED
@@ -9,7 +9,7 @@ module Dri
|
|
9
9
|
class FAQ < Dri::Command
|
10
10
|
ExitCommand = Class.new(StandardError)
|
11
11
|
|
12
|
-
def execute(
|
12
|
+
def execute(*)
|
13
13
|
root_dir = File.expand_path('../../..', __dir__)
|
14
14
|
faq_file = File.join(root_dir, 'faq.yaml')
|
15
15
|
faq_data = YAML.load_file(faq_file)
|