dri 0.10.2 → 1.1.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 +4 -4
- data/.gitlab/changelog_config.yml +13 -0
- data/.gitlab/merge_request_templates/Default.md +27 -0
- data/.gitlab/merge_request_templates/Release.md +8 -23
- data/.gitlab-ci.yml +6 -4
- data/.rubocop.yml +9 -1
- data/.ruby-version +1 -1
- data/.tool-versions +1 -1
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile.lock +58 -32
- data/README.md +88 -113
- data/dri.gemspec +9 -4
- data/exe/dri +2 -1
- data/faq.yaml +7 -7
- data/lefthook.yml +24 -0
- data/lib/dri/api_client.rb +66 -25
- data/lib/dri/cli.rb +2 -11
- data/lib/dri/command.rb +21 -52
- data/lib/dri/commands/add/fast_quarantine.rb +72 -0
- data/lib/dri/commands/add.rb +45 -0
- data/lib/dri/commands/analyze/stack_traces.rb +1 -4
- data/lib/dri/commands/analyze.rb +0 -1
- data/lib/dri/commands/faq.rb +1 -2
- data/lib/dri/commands/fetch/failures.rb +102 -43
- data/lib/dri/commands/fetch/{featureflags.rb → feature_flags.rb} +1 -6
- data/lib/dri/commands/fetch/pipelines.rb +3 -7
- data/lib/dri/commands/fetch/runbooks.rb +1 -3
- data/lib/dri/commands/fetch/testcases.rb +1 -3
- data/lib/dri/commands/fetch/triaged.rb +2 -6
- data/lib/dri/commands/fetch.rb +0 -30
- data/lib/dri/commands/incidents.rb +2 -6
- data/lib/dri/commands/init.rb +1 -3
- data/lib/dri/commands/profile.rb +3 -5
- data/lib/dri/commands/publish/report.rb +24 -26
- data/lib/dri/commands/publish.rb +0 -1
- data/lib/dri/commands/rm/emoji.rb +1 -3
- data/lib/dri/commands/rm/profile.rb +1 -2
- data/lib/dri/commands/rm/reports.rb +1 -2
- data/lib/dri/commands/rm.rb +0 -3
- data/lib/dri/commands/view/fast_quarantine.rb +25 -0
- data/lib/dri/commands/view.rb +22 -0
- data/lib/dri/feature_flag_report.rb +1 -3
- data/lib/dri/refinements/gitlab.rb +22 -0
- data/lib/dri/refinements/string.rb +19 -0
- data/lib/dri/report.rb +13 -55
- data/lib/dri/support/configuration.rb +62 -0
- data/lib/dri/support/influxdb_tools.rb +37 -0
- data/lib/dri/utils/constants.rb +2 -1
- data/lib/dri/utils/helpers.rb +15 -0
- data/lib/dri/version.rb +1 -1
- data/lib/dri.rb +8 -1
- metadata +96 -16
- data/lib/dri/commands/fetch/quarantines.rb +0 -55
- data/lib/dri/gitlab/issues.rb +0 -19
- data/lib/dri/refinements/truncate.rb +0 -15
data/README.md
CHANGED
@@ -1,95 +1,88 @@
|
|
1
|
-
# DRI
|
1
|
+
# DRI Gem
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
Welcome to your new gem! DRI is a CLI ready to help:
|
3
|
+
The DRI (Directly Responsible Individual) gem is your CLI companion for managing GitLab's QA pipelines. Tailored for those in charge of pipeline quality assurance, it simplifies the triage and reporting of failing tests. Key features include:
|
6
4
|
|
7
5
|
- Fetching failing test cases by pipeline
|
8
|
-
- Reporting at the end of the timezone shift
|
9
|
-
-
|
10
|
-
-
|
6
|
+
- Reporting failures at the end of the timezone shift
|
7
|
+
- Viewing today's newest and untriaged failures
|
8
|
+
- Marking actions on failures
|
11
9
|
|
12
|
-
... and more
|
13
10
|
|
14
11
|
## Installation
|
15
12
|
|
16
|
-
|
13
|
+
Install dri using the following command:
|
17
14
|
|
18
15
|
```shell
|
19
16
|
$ gem install dri
|
20
17
|
```
|
21
18
|
|
22
|
-
|
19
|
+
Execute `dri` to see all available options:
|
23
20
|
|
24
21
|
```shell
|
25
22
|
$ dri
|
26
23
|
```
|
27
24
|
|
28
|
-
##
|
25
|
+
## Installing from source
|
29
26
|
|
30
|
-
|
27
|
+
After cloning this repository, build dri from source using the following command:
|
28
|
+
|
29
|
+
```shell
|
30
|
+
$ gem build dri.gemspec
|
31
|
+
```
|
31
32
|
|
32
|
-
|
33
|
+
A gemfile will be generated with the current version number, e.g. `dri-0.11.0.gem`. Install using the command:
|
33
34
|
|
34
|
-
|
35
|
-
|
35
|
+
```shell
|
36
|
+
$ gem install dri-0.11.0.gem
|
37
|
+
```
|
36
38
|
|
37
|
-
|
39
|
+
## Getting Started
|
38
40
|
|
39
|
-
|
41
|
+
### Configuration
|
42
|
+
|
43
|
+
Before diving into dri, ensure you have:
|
44
|
+
|
45
|
+
* A Personal Access Token for authentication.
|
46
|
+
* A triage emoji to mark triaged failures
|
47
|
+
|
48
|
+
Configure your profile with:
|
40
49
|
|
41
50
|
```shell
|
42
51
|
$ dri init
|
43
52
|
```
|
44
53
|
|
45
|
-
To
|
54
|
+
To view or edit your profile:
|
46
55
|
|
47
56
|
```shell
|
48
57
|
$ dri profile
|
49
58
|
```
|
50
59
|
|
51
|
-
###
|
52
|
-
|
53
|
-
- [1. init](#1-init)
|
54
|
-
- [2. profile](#2-profile)
|
55
|
-
- [3. fetch](#3-fetch)
|
56
|
-
- failures
|
57
|
-
- testcases
|
58
|
-
- triaged
|
59
|
-
- quarantines
|
60
|
-
- dequarantines
|
61
|
-
- featureflags
|
62
|
-
- runbooks
|
63
|
-
- [4. publish](#4-publish)
|
64
|
-
- report
|
65
|
-
- [5. rm](#5-rm)
|
66
|
-
- emoji
|
67
|
-
- profile
|
68
|
-
- reports
|
69
|
-
- [6. incidents](#6-incidents)
|
70
|
-
- [7. analyze](#7-analyze)
|
71
|
-
- stacktraces
|
72
|
-
- [8. version](#8-version)
|
73
|
-
- [9. faq](#8-faq)
|
74
|
-
|
75
|
-
#### 1. init
|
60
|
+
### Usage
|
76
61
|
|
77
62
|
```shell
|
78
|
-
$ dri
|
63
|
+
$ dri help
|
79
64
|
```
|
80
65
|
|
81
|
-
|
66
|
+
`dri` supports a variety of commands to streamline your workflow:
|
82
67
|
|
83
|
-
|
68
|
+
- init: Set up dri with necessary configurations.
|
69
|
+
- profile: Display or edit your user profile.
|
70
|
+
- fetch: Retrieve information on failures, test cases, triaged issues, feature flags, and more.
|
71
|
+
- publish: Generate and publish reports.
|
72
|
+
- rm: Remove emojis, profiles, or reports.
|
73
|
+
- incidents: View active or mitigated incidents.
|
74
|
+
- analyze: Analyze stack traces for common failures.
|
75
|
+
- version: Check the installed version of dri.
|
76
|
+
- faq: Access FAQs related to on-call operations.
|
84
77
|
|
85
|
-
```shell
|
86
|
-
$ dri profile
|
87
|
-
```
|
88
78
|
|
89
|
-
|
90
|
-
Pass the option `--edit` to edit the current profile.
|
79
|
+
#### Command Details
|
91
80
|
|
92
|
-
|
81
|
+
- fetch: Use options like --start_date, --end_date, and --cutoff to customize your queries.
|
82
|
+
- publish report: Customize reports with --format, --dry-run, --actions, and --feature-flags options.
|
83
|
+
- rm: Manage your environment by cleaning up emojis, profiles, or locally stored reports.
|
84
|
+
|
85
|
+
Example Commands:
|
93
86
|
|
94
87
|
```shell
|
95
88
|
$ dri fetch failures
|
@@ -98,13 +91,8 @@ $ dri fetch failures
|
|
98
91
|
Fetches today's opened failures and lists them according to their triage status.
|
99
92
|
Helpful to understand if there are missing recent failures to be reviewed.
|
100
93
|
|
101
|
-
|
102
|
-
|
103
|
-
a `--cutoff=HH:MM` to just show failures after a certain period of the day. The cutoff
|
104
|
-
time will be converted to UTC.
|
105
|
-
|
106
|
-
To surface most urgent issues pass the `--urgent` flag to see issues that are both
|
107
|
-
in `canary` and `staging-canary` pipelines just during today's timespan.
|
94
|
+
**Note:** Smoke and Reliable failures will be highlighted in bold and in between *'s. These require
|
95
|
+
to have set `QA_INFLUXDB_URL` and `QA_INFLUXDB_TOKEN` environment variables, to be found in 1Password.
|
108
96
|
|
109
97
|
```shell
|
110
98
|
$ dri fetch testcases
|
@@ -118,33 +106,13 @@ To filter the pipelines, pass the `--filter-pipelines` options to multi-select t
|
|
118
106
|
$ dri fetch triaged
|
119
107
|
```
|
120
108
|
|
121
|
-
Fetches triaged failures
|
122
|
-
|
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
|
-
```shell
|
137
|
-
$ dri fetch featureflags
|
138
|
-
```
|
139
|
-
|
140
|
-
Fetches a list of today's feature flag changes, including the date and time in UTC of when the change occurred as well as a link to the corresponding issue from the feature-flag-log project.
|
109
|
+
Fetches triaged failures.
|
141
110
|
|
142
111
|
```shell
|
143
112
|
$ dri fetch pipelines
|
144
113
|
```
|
145
114
|
|
146
115
|
Fetches a table containing last executed pipeline and its test report link for all monitored pipelines.
|
147
|
-
The timestamps are in UTC
|
148
116
|
|
149
117
|
```shell
|
150
118
|
$ dri fetch runbooks [runbook]
|
@@ -153,14 +121,11 @@ $ dri fetch runbooks [runbook]
|
|
153
121
|
Fetches a runbook from the [runbooks](https://gitlab.com/gitlab-org/quality/runbooks) project.
|
154
122
|
If `[runbook]` is omitted, the command will prompt the user to select from a list of available runbooks.
|
155
123
|
|
156
|
-
#### 4. publish
|
157
|
-
|
158
124
|
```shell
|
159
125
|
$ dri publish report
|
160
126
|
```
|
161
127
|
|
162
|
-
Publishes a handover report on the latest triage issue
|
163
|
-
The report includes automatically both triaged failures and incidents.
|
128
|
+
Publishes a handover report on the latest weekly triage issue.
|
164
129
|
|
165
130
|
**Options**
|
166
131
|
|
@@ -172,22 +137,13 @@ $ dri publish report --actions # activate the actions prompt for each failure
|
|
172
137
|
$ dri publish report --feature-flags # includes a summary of the feature flag changes on each environment
|
173
138
|
$ dri publish report --update # update the report note if has already been posted
|
174
139
|
```
|
175
|
-
|
140
|
+
---
|
176
141
|
**Note:** These options above can be combined like:
|
177
142
|
|
178
143
|
```shell
|
179
144
|
$ dri publish report --format=list --dry-run --actions --update
|
180
145
|
```
|
181
|
-
|
182
|
-
**Actions**
|
183
|
-
|
184
|
-
When using `--actions` a set of actions are prompt on each failure. Use `Space` to
|
185
|
-
mark several actions: `pinged SET`, `quarantined`, `reproduced`, `transient`.
|
186
|
-
Hitting `Enter` without a selected action will skip marking the actions for a given
|
187
|
-
failure.
|
188
|
-
|
189
|
-
#### 5. rm
|
190
|
-
|
146
|
+
---
|
191
147
|
```shell
|
192
148
|
$ dri rm emoji
|
193
149
|
```
|
@@ -208,41 +164,60 @@ $ dri rm profile
|
|
208
164
|
|
209
165
|
Removes the profile currently in use.
|
210
166
|
|
211
|
-
#### 6. incidents
|
212
|
-
|
213
167
|
```shell
|
214
168
|
$ dri incidents
|
215
169
|
```
|
216
170
|
|
217
171
|
Have a quick look at currently active/mitigated incidents on GitLab services.
|
218
172
|
|
219
|
-
#### 7. analyze
|
220
|
-
|
221
173
|
```shell
|
222
|
-
$ dri
|
174
|
+
$ dri faq
|
223
175
|
```
|
224
|
-
Searches through any open test failure issues and publishes a report that identifies
|
225
|
-
issues that have similar stack traces.
|
226
|
-
This may be useful to identify situations where a common test failure is presenting
|
227
|
-
itself across multiple individual test cases, over a period of time.
|
228
176
|
|
229
|
-
|
177
|
+
Returns a list of questions and answers related to on-call operations. This leverages
|
178
|
+
existing pages of documentation, redirecting directly to the relevant section to help
|
179
|
+
with a problem.
|
180
|
+
|
181
|
+
## Development
|
182
|
+
|
183
|
+
### Initial setup
|
184
|
+
- Check out the repo [dri](https://gitlab.com/gitlab-org/ruby/gems/dri)
|
185
|
+
- Then run
|
230
186
|
|
231
187
|
```shell
|
232
|
-
|
188
|
+
bundle install
|
233
189
|
```
|
234
190
|
|
235
|
-
|
236
|
-
|
237
|
-
#### 9. faq
|
191
|
+
### Activate lefthook locally
|
238
192
|
|
239
193
|
```shell
|
240
|
-
|
194
|
+
lefthook install
|
241
195
|
```
|
242
196
|
|
243
|
-
|
244
|
-
|
245
|
-
|
197
|
+
## Release
|
198
|
+
|
199
|
+
[Automated gem release process](https://gitlab.com/gitlab-org/components/gem-release/-/tree/main?ref_type=heads#gem-release-component) is used to release new version of `dri` through pipelines, and this will:
|
200
|
+
|
201
|
+
- Publish the gem: https://rubygems.org/gems/dri
|
202
|
+
- Add a release in the `dri` project: https://gitlab.com/gitlab-org/ruby/gems/dri/-/releases
|
203
|
+
- Populate the release log with the API contents. For example: https://gitlab.com/api/v4/projects/52612795/repository/changelog?version=1.0.0
|
204
|
+
|
205
|
+
### Before release
|
206
|
+
|
207
|
+
Make sure to include a changelog entry in your commit message and read the [changelog entries section](https://docs.gitlab.com/ee/development/changelog.html).
|
208
|
+
|
209
|
+
If you forget to set the changelog entry in your commit messages, you can also edit the release notes after it's being released.
|
210
|
+
|
211
|
+
### Steps to release
|
212
|
+
|
213
|
+
- Update the version number in `lib/dri/version.rb` with the new gem version.
|
214
|
+
- Run `bundle install` locally to update gem version in `Gemfile.lock` .
|
215
|
+
- Use the `Release` merge request template and create a merge request to submit these changes. Then get the merge request merged by a maintainer.
|
216
|
+
|
217
|
+
This will then be packaged into a gem and pushed to [rubygems.org](https://rubygems.org) by the CI/CD.
|
218
|
+
|
219
|
+
For example: [Upgrades gem from 2.7.0 to 2.8.0](https://gitlab.com/gitlab-org/ruby/gems/gitlab_quality-test_tooling/-/merge_requests/286).
|
220
|
+
|
246
221
|
## Copyright
|
247
222
|
|
248
223
|
Copyright (c) 2022 GitLab, Inc. See [MIT License](LICENSE.txt) for further details.
|
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.
|
@@ -22,9 +22,11 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
23
|
spec.require_paths = ['lib']
|
24
24
|
|
25
|
+
spec.add_dependency 'activesupport', '~> 7.1'
|
25
26
|
spec.add_dependency 'amatch', '~> 0.4.1'
|
26
27
|
spec.add_dependency "gitlab", "~> 4.19"
|
27
28
|
spec.add_dependency 'httparty', '~> 0.21.0'
|
29
|
+
spec.add_dependency 'influxdb-client', '~> 2.9'
|
28
30
|
spec.add_dependency 'json', '~> 2.6.1'
|
29
31
|
spec.add_dependency 'launchy', '~> 2.4'
|
30
32
|
spec.add_dependency 'markdown-tables', '~> 1.1.1'
|
@@ -39,11 +41,14 @@ Gem::Specification.new do |spec|
|
|
39
41
|
spec.add_dependency 'tty-prompt', '~> 0.23.1'
|
40
42
|
spec.add_dependency 'tty-spinner', '~> 0.9'
|
41
43
|
spec.add_dependency 'tty-table', '~> 0.12.0'
|
44
|
+
spec.add_dependency 'zeitwerk', '~> 2.6'
|
42
45
|
|
43
|
-
spec.add_development_dependency 'gitlab-styles', '~>
|
46
|
+
spec.add_development_dependency 'gitlab-styles', '~> 10'
|
47
|
+
spec.add_development_dependency "lefthook", "~> 1.3"
|
44
48
|
spec.add_development_dependency "pry", "~> 0.14.1"
|
45
49
|
spec.add_development_dependency 'rake', "~> 13.0"
|
46
50
|
spec.add_development_dependency 'rspec', '~> 3.10.0'
|
47
51
|
spec.add_development_dependency "timecop", "~> 0.9.1"
|
52
|
+
spec.add_development_dependency 'vcr', '~> 6.2.0'
|
48
53
|
spec.add_development_dependency 'webmock', '~> 3.5'
|
49
54
|
end
|
data/exe/dri
CHANGED
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/lefthook.yml
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# Lefthook configuration. For more information, see:
|
2
|
+
# https://lefthook.dev/configuration/index.html
|
3
|
+
|
4
|
+
pre-push:
|
5
|
+
parallel: true
|
6
|
+
commands:
|
7
|
+
# Run ruby linting
|
8
|
+
rubocop:
|
9
|
+
run: bundle exec rubocop
|
10
|
+
glob: '*.rb'
|
11
|
+
|
12
|
+
# Changelog git trailer for the first commit of the branch
|
13
|
+
changelog-on-first-commit:
|
14
|
+
run: |
|
15
|
+
git fetch origin main
|
16
|
+
first_commit_message=$(git log --format=%B -n 1 $(git log origin/main..HEAD --pretty=format:"%h" | tail -1))
|
17
|
+
if ! echo ${first_commit_message} | grep "Changelog:"; then
|
18
|
+
echo Could not find a Changelog: git trailer on the first commit for this branch.
|
19
|
+
echo
|
20
|
+
echo Please add a trailer by amending the git commit message.
|
21
|
+
echo
|
22
|
+
echo See https://docs.gitlab.com/ee/development/changelog.html#overview for more info.
|
23
|
+
exit 1
|
24
|
+
fi
|
data/lib/dri/api_client.rb
CHANGED
@@ -6,13 +6,12 @@ require "tty-config"
|
|
6
6
|
require "cgi"
|
7
7
|
require "gitlab"
|
8
8
|
|
9
|
-
require_relative './utils/constants'
|
10
|
-
|
11
9
|
module Dri
|
12
10
|
TokenNotProvidedError = Class.new(StandardError)
|
13
11
|
class ApiClient # rubocop:disable Metrics/ClassLength
|
14
12
|
include Dri::Utils::Constants::ProjectIDs
|
15
13
|
include Dri::Utils::Constants::Triage::Labels
|
14
|
+
using Refinements::Gitlab
|
16
15
|
|
17
16
|
API_URL = "https://gitlab.com/api/v4"
|
18
17
|
OPS_API_URL = "https://ops.gitlab.net/api/v4"
|
@@ -22,7 +21,7 @@ module Dri
|
|
22
21
|
@ops_token = config.read.dig("settings", "ops_token")
|
23
22
|
if @token.nil? || @ops_token.nil?
|
24
23
|
raise TokenNotProvidedError, "Gitlab API client cannot be initialized without both access tokens. " \
|
25
|
-
|
24
|
+
"Run `dri init` again or `dri profile --edit` to add an ops_token entry."
|
26
25
|
end
|
27
26
|
|
28
27
|
@ops_instance = ops
|
@@ -93,7 +92,7 @@ module Dri
|
|
93
92
|
labels: "#{pipeline}::failed",
|
94
93
|
state: state,
|
95
94
|
scope: "all",
|
96
|
-
|
95
|
+
'not[labels]': QUARANTINE
|
97
96
|
).auto_paginate
|
98
97
|
end
|
99
98
|
|
@@ -136,7 +135,11 @@ module Dri
|
|
136
135
|
#
|
137
136
|
# @return [Gitlab::ObjectifiedHash]
|
138
137
|
def fetch_current_triage_issue
|
139
|
-
gitlab.issues(TRIAGE_PROJECT_ID,
|
138
|
+
issues = gitlab.issues(TRIAGE_PROJECT_ID, labels: "triage report", state: "opened")
|
139
|
+
|
140
|
+
issues.find do |issue|
|
141
|
+
issue.title.include?('Pipeline Triage Report')
|
142
|
+
end
|
140
143
|
end
|
141
144
|
|
142
145
|
# Create triage report note
|
@@ -160,34 +163,26 @@ module Dri
|
|
160
163
|
|
161
164
|
# Fetch all new failures
|
162
165
|
#
|
163
|
-
# @param [
|
164
|
-
# @param [
|
166
|
+
# @param [Time] start_date
|
167
|
+
# @param [Time] end_date
|
165
168
|
# @param [String] state
|
166
169
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
167
170
|
def fetch_all_new_failures(start_date:, end_date:, state:)
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
start_date_iso = start_date.strftime('%Y-%m-%dT00:00:00Z')
|
172
|
-
end_date_iso = end_date.strftime('%Y-%m-%dT23:59:59Z')
|
173
|
-
|
174
|
-
project_ids.each do |project_id|
|
175
|
-
failures += fetch_new_failures(
|
171
|
+
[GITLAB_PROJECT_ID, CUSTOMERSDOT_PROJECT_ID].flat_map do |project_id|
|
172
|
+
fetch_new_failures(
|
176
173
|
project_id: project_id,
|
177
|
-
start_date:
|
178
|
-
end_date:
|
174
|
+
start_date: start_date,
|
175
|
+
end_date: end_date,
|
179
176
|
state: state
|
180
177
|
)
|
181
178
|
end
|
182
|
-
|
183
|
-
failures
|
184
179
|
end
|
185
180
|
|
186
181
|
# Fetch new failures for a given project
|
187
182
|
#
|
188
183
|
# @param [Integer] project_id
|
189
|
-
# @param [
|
190
|
-
# @param [
|
184
|
+
# @param [Time] start_date
|
185
|
+
# @param [Time] end_date
|
191
186
|
# @param [String] state
|
192
187
|
# @return [Array<Gitlab::ObjectifiedHash>]
|
193
188
|
def fetch_new_failures(project_id:, start_date:, end_date:, state:)
|
@@ -198,8 +193,8 @@ module Dri
|
|
198
193
|
sort: 'desc',
|
199
194
|
state: state,
|
200
195
|
scope: "all",
|
201
|
-
created_after: start_date,
|
202
|
-
created_before: end_date,
|
196
|
+
created_after: start_date.dup.utc.iso8601, # utc modifies the receiver, so making a copy
|
197
|
+
created_before: end_date.dup.utc.iso8601,
|
203
198
|
per_page: 100
|
204
199
|
)
|
205
200
|
end
|
@@ -313,6 +308,52 @@ module Dri
|
|
313
308
|
gitlab.get_file(project_id, path, ref)
|
314
309
|
end
|
315
310
|
|
311
|
+
def get_fast_quarantine_tests
|
312
|
+
gitlab.file_contents(
|
313
|
+
FAST_QUARANTINE_PROJECT_ID,
|
314
|
+
'rspec/fast_quarantine-gitlab.txt',
|
315
|
+
'main'
|
316
|
+
)
|
317
|
+
end
|
318
|
+
|
319
|
+
def get_failure_issue_title(issue_id)
|
320
|
+
issue = gitlab.issue(GITLAB_PROJECT_ID, issue_id)
|
321
|
+
issue.title
|
322
|
+
end
|
323
|
+
|
324
|
+
def add_test_to_fast_quarantine(failure_url, new_branch, test_path, new_file_content)
|
325
|
+
gitlab.create_branch(
|
326
|
+
FAST_QUARANTINE_PROJECT_ID,
|
327
|
+
new_branch,
|
328
|
+
'main'
|
329
|
+
)
|
330
|
+
|
331
|
+
gitlab.edit_file(
|
332
|
+
FAST_QUARANTINE_PROJECT_ID,
|
333
|
+
'rspec/fast_quarantine-gitlab.txt',
|
334
|
+
new_branch,
|
335
|
+
new_file_content,
|
336
|
+
'Add test to quarantine'
|
337
|
+
)
|
338
|
+
|
339
|
+
gitlab.create_merge_request(
|
340
|
+
FAST_QUARANTINE_PROJECT_ID,
|
341
|
+
"Quarantine #{test_path}", {
|
342
|
+
source_branch: new_branch,
|
343
|
+
target_branch: 'main',
|
344
|
+
description: "Fast quarantine for `#{test_path}`. Failure: #{failure_url}."
|
345
|
+
}
|
346
|
+
)
|
347
|
+
end
|
348
|
+
|
349
|
+
def add_note_failure_issue(issue_id, merge_request)
|
350
|
+
gitlab.create_issue_note(
|
351
|
+
GITLAB_PROJECT_ID,
|
352
|
+
issue_id,
|
353
|
+
"Applying fast quarantine at #{merge_request.web_url}."
|
354
|
+
)
|
355
|
+
end
|
356
|
+
|
316
357
|
private
|
317
358
|
|
318
359
|
attr_reader :token, :ops_token
|
@@ -322,12 +363,12 @@ module Dri
|
|
322
363
|
# @return [Gitlab::Client]
|
323
364
|
def gitlab
|
324
365
|
if @ops_instance
|
325
|
-
@ops_client ||= Gitlab.client(
|
366
|
+
@ops_client ||= ::Gitlab.client(
|
326
367
|
endpoint: OPS_API_URL,
|
327
368
|
private_token: ops_token
|
328
369
|
)
|
329
370
|
else
|
330
|
-
@gitlab_client ||= Gitlab.client(
|
371
|
+
@gitlab_client ||= ::Gitlab.client(
|
331
372
|
endpoint: API_URL,
|
332
373
|
private_token: token
|
333
374
|
)
|
data/lib/dri/cli.rb
CHANGED
@@ -29,7 +29,6 @@ module Dri
|
|
29
29
|
|
30
30
|
desc 'version', 'dri version'
|
31
31
|
def version
|
32
|
-
require_relative 'version'
|
33
32
|
puts "v#{Dri::VERSION}"
|
34
33
|
end
|
35
34
|
map %w[--version -v] => :version
|
@@ -41,12 +40,10 @@ module Dri
|
|
41
40
|
if options[:help]
|
42
41
|
invoke :help, ['incidents']
|
43
42
|
else
|
44
|
-
require_relative 'commands/incidents'
|
45
43
|
Dri::Commands::Incidents.new(options).execute
|
46
44
|
end
|
47
45
|
end
|
48
46
|
|
49
|
-
require_relative 'commands/rm'
|
50
47
|
register Dri::Commands::Rm, 'rm', 'rm [SUBCOMMAND]', 'Remove triage-related items'
|
51
48
|
|
52
49
|
desc 'profile', 'View current user settings'
|
@@ -60,7 +57,6 @@ module Dri
|
|
60
57
|
if options[:help]
|
61
58
|
invoke :help, ['profile']
|
62
59
|
else
|
63
|
-
require_relative 'commands/profile'
|
64
60
|
Dri::Commands::Profile.new(options).execute
|
65
61
|
end
|
66
62
|
end
|
@@ -72,7 +68,6 @@ module Dri
|
|
72
68
|
if options[:help]
|
73
69
|
invoke :help, ['init']
|
74
70
|
else
|
75
|
-
require_relative 'commands/init'
|
76
71
|
Dri::Commands::Init.new(options).execute
|
77
72
|
end
|
78
73
|
end
|
@@ -86,7 +81,6 @@ module Dri
|
|
86
81
|
invoke :help, ['faq']
|
87
82
|
else
|
88
83
|
begin
|
89
|
-
require_relative 'commands/faq'
|
90
84
|
Dri::Commands::FAQ.new(options).execute
|
91
85
|
rescue Dri::Commands::FAQ::ExitCommand
|
92
86
|
puts "Exiting faq command..."
|
@@ -94,13 +88,10 @@ module Dri
|
|
94
88
|
end
|
95
89
|
end
|
96
90
|
|
97
|
-
require_relative 'commands/fetch'
|
98
91
|
register Dri::Commands::Fetch, 'fetch', 'fetch [SUBCOMMAND]', 'Fetch failures & testcases'
|
99
|
-
|
100
|
-
require_relative 'commands/publish'
|
101
92
|
register Dri::Commands::Publish, 'publish', 'publish [SUBCOMMAND]', 'Publish report for handover'
|
102
|
-
|
103
|
-
require_relative 'commands/analyze'
|
104
93
|
register Dri::Commands::Analyze, 'analyze', 'analyze [SUBCOMMAND]', 'Analysis of test failures and issues'
|
94
|
+
register Dri::Commands::View, 'view', 'view [SUBCOMMAND]', 'View relevant items to help triage'
|
95
|
+
register Dri::Commands::Add, 'add', 'add [SUBCOMMAND]', 'Add relevant items to help triage'
|
105
96
|
end
|
106
97
|
end
|