dri 0.1.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -1
- data/.gitlab-ci.yml +32 -13
- data/.rubocop.yml +53 -0
- data/.ruby-version +1 -0
- data/.tool-versions +1 -0
- data/Gemfile +2 -3
- data/Gemfile.lock +69 -17
- data/README.md +33 -2
- data/Rakefile +3 -1
- data/bin/console +1 -0
- data/dri.gemspec +25 -22
- data/exe/dri +3 -3
- data/lib/dri/api_client.rb +51 -10
- data/lib/dri/cli.rb +14 -2
- data/lib/dri/command.rb +8 -6
- data/lib/dri/commands/fetch/failures.rb +38 -29
- data/lib/dri/commands/fetch/featureflags.rb +95 -0
- data/lib/dri/commands/fetch/quarantines.rb +53 -0
- data/lib/dri/commands/fetch/testcases.rb +16 -10
- data/lib/dri/commands/fetch/triaged.rb +11 -15
- data/lib/dri/commands/fetch.rb +38 -2
- data/lib/dri/commands/incidents.rb +59 -0
- data/lib/dri/commands/init.rb +7 -5
- data/lib/dri/commands/profile.rb +14 -5
- data/lib/dri/commands/publish/report.rb +36 -10
- data/lib/dri/commands/publish.rb +4 -5
- data/lib/dri/commands/rm/emoji.rb +5 -5
- data/lib/dri/commands/rm/profile.rb +2 -2
- data/lib/dri/commands/rm.rb +0 -1
- data/lib/dri/refinements/truncate.rb +15 -0
- data/lib/dri/report.rb +72 -43
- data/lib/dri/templates/incidents/.gitkeep +1 -0
- data/lib/dri/utils/markdown_lists.rb +7 -9
- data/lib/dri/utils/table.rb +20 -0
- data/lib/dri/version.rb +3 -1
- data/lib/dri.rb +2 -0
- metadata +69 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ebb53c09c3a4e7f7c6daa06acd9e8fb1be1c5aef4fffb97db6e84029aafe481e
|
4
|
+
data.tar.gz: f7cb0fc63042a33766c02a787cb10af4188839fb9f96d9aa650f5addc279cac9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01f7bbef2920e466cde321720d210541cbb60b377240ae28a74e6fdd66bd89f70a5b4aba5e69d622466d5379ed6e59adce3933844d08171449496b9638dfe1f6
|
7
|
+
data.tar.gz: c263146aa4a230cab0b8cdebc7c2a6b1d278baa3cf63b5d356fa7c8ee3143472c0e69ec3eaa7006317f74249c66167f4e03a72dfccab0f2d52ea5fde4e1d972f
|
data/.gitignore
CHANGED
data/.gitlab-ci.yml
CHANGED
@@ -1,28 +1,47 @@
|
|
1
|
-
|
1
|
+
.job_base:
|
2
|
+
image: ruby:2.7
|
3
|
+
variables:
|
4
|
+
BUNDLE_PATH: vendor/bundle
|
5
|
+
BUNDLE_SUPPRESS_INSTALL_USING_MESSAGES: "true"
|
6
|
+
before_script:
|
7
|
+
- gem install bundler -v 2.3.9 --no-document
|
8
|
+
- bundle install
|
9
|
+
cache:
|
10
|
+
key:
|
11
|
+
files:
|
12
|
+
- dri.gemspec
|
13
|
+
- Gemfile.lock
|
14
|
+
paths:
|
15
|
+
- vendor/bundle
|
16
|
+
rules:
|
17
|
+
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
|
18
|
+
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
19
|
+
|
20
|
+
include:
|
21
|
+
- project: gitlab-org/quality/pipeline-common
|
22
|
+
ref: 0.3.4
|
23
|
+
file:
|
24
|
+
- /ci/gem-release.yml
|
2
25
|
|
3
26
|
stages:
|
4
27
|
- build
|
5
28
|
- test
|
6
29
|
- deploy
|
7
30
|
|
8
|
-
before_script:
|
9
|
-
- gem install bundler:2.2.22
|
10
|
-
- bundle install
|
11
|
-
|
12
31
|
build_gem:
|
13
32
|
stage: build
|
33
|
+
extends: .job_base
|
14
34
|
script:
|
15
35
|
- gem build
|
16
36
|
|
17
|
-
|
37
|
+
rubocop:
|
18
38
|
stage: test
|
39
|
+
extends: .job_base
|
19
40
|
script:
|
20
|
-
- bundle exec
|
41
|
+
- bundle exec rubocop --color
|
21
42
|
|
22
|
-
|
23
|
-
stage:
|
43
|
+
rspec:
|
44
|
+
stage: test
|
45
|
+
extends: .job_base
|
24
46
|
script:
|
25
|
-
-
|
26
|
-
rules:
|
27
|
-
- if: '$CI_COMMIT_TAG'
|
28
|
-
when: always
|
47
|
+
- bundle exec rspec --color
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
inherit_gem:
|
2
|
+
gitlab-styles:
|
3
|
+
- rubocop-all.yml
|
4
|
+
- rubocop-gemspec.yml
|
5
|
+
- rubocop-lint.yml
|
6
|
+
- rubocop-naming.yml
|
7
|
+
- rubocop-performance.yml
|
8
|
+
- rubocop-rspec.yml
|
9
|
+
- rubocop-security.yml
|
10
|
+
- rubocop-style.yml
|
11
|
+
|
12
|
+
AllCops:
|
13
|
+
TargetRubyVersion: 2.7
|
14
|
+
|
15
|
+
RSpec/MultipleMemoizedHelpers:
|
16
|
+
Max: 25
|
17
|
+
AllowSubject: true
|
18
|
+
|
19
|
+
CodeReuse/ActiveRecord:
|
20
|
+
Exclude:
|
21
|
+
- spec/**/*.rb
|
22
|
+
|
23
|
+
Metrics/AbcSize:
|
24
|
+
Enabled: true
|
25
|
+
Max: 30
|
26
|
+
|
27
|
+
Metrics/BlockLength:
|
28
|
+
Enabled: true
|
29
|
+
Exclude:
|
30
|
+
- spec/**/*.rb
|
31
|
+
- dri.gemspec
|
32
|
+
|
33
|
+
Metrics/MethodLength:
|
34
|
+
Enabled: true
|
35
|
+
Max: 30
|
36
|
+
|
37
|
+
Layout/BeginEndAlignment:
|
38
|
+
Enabled: true
|
39
|
+
|
40
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
41
|
+
Enabled: true
|
42
|
+
|
43
|
+
Layout/SpaceAroundMethodCallOperator:
|
44
|
+
Enabled: true
|
45
|
+
|
46
|
+
Lint/HashCompareByIdentity:
|
47
|
+
Enabled: true
|
48
|
+
|
49
|
+
Lint/RedundantSafeNavigation:
|
50
|
+
Enabled: true
|
51
|
+
|
52
|
+
Style/ClassEqualityComparison:
|
53
|
+
Enabled: true
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.7.5
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 3.0.2
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dri (0.1.
|
4
|
+
dri (0.1.3)
|
5
5
|
httparty (~> 0.20.0)
|
6
6
|
json (~> 2.6.1)
|
7
7
|
markdown-tables (~> 1.1.1)
|
@@ -19,39 +19,88 @@ PATH
|
|
19
19
|
GEM
|
20
20
|
remote: https://rubygems.org/
|
21
21
|
specs:
|
22
|
+
activesupport (7.0.2.3)
|
23
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
24
|
+
i18n (>= 1.6, < 2)
|
25
|
+
minitest (>= 5.1)
|
26
|
+
tzinfo (~> 2.0)
|
22
27
|
addressable (2.8.0)
|
23
28
|
public_suffix (>= 2.0.2, < 5.0)
|
29
|
+
ast (2.4.2)
|
30
|
+
concurrent-ruby (1.1.10)
|
24
31
|
crack (0.4.5)
|
25
32
|
rexml
|
26
33
|
diff-lcs (1.5.0)
|
34
|
+
gitlab-styles (7.0.0)
|
35
|
+
rubocop (~> 0.91, >= 0.91.1)
|
36
|
+
rubocop-gitlab-security (~> 0.1.1)
|
37
|
+
rubocop-graphql (~> 0.10)
|
38
|
+
rubocop-performance (~> 1.9.2)
|
39
|
+
rubocop-rails (~> 2.9)
|
40
|
+
rubocop-rspec (~> 1.44)
|
27
41
|
hashdiff (1.0.1)
|
28
42
|
httparty (0.20.0)
|
29
43
|
mime-types (~> 3.0)
|
30
44
|
multi_xml (>= 0.5.2)
|
45
|
+
i18n (1.10.0)
|
46
|
+
concurrent-ruby (~> 1.0)
|
31
47
|
json (2.6.1)
|
32
48
|
markdown-tables (1.1.1)
|
33
49
|
mime-types (3.4.1)
|
34
50
|
mime-types-data (~> 3.2015)
|
35
51
|
mime-types-data (3.2022.0105)
|
52
|
+
minitest (5.15.0)
|
36
53
|
multi_xml (0.6.0)
|
54
|
+
parallel (1.22.1)
|
55
|
+
parser (3.1.1.0)
|
56
|
+
ast (~> 2.4.1)
|
37
57
|
pastel (0.8.0)
|
38
58
|
tty-color (~> 0.5)
|
39
59
|
public_suffix (4.0.6)
|
40
|
-
|
60
|
+
rack (2.2.3)
|
61
|
+
rainbow (3.1.1)
|
62
|
+
rake (13.0.6)
|
63
|
+
regexp_parser (2.2.1)
|
41
64
|
rexml (3.2.5)
|
42
|
-
rspec (3.
|
43
|
-
rspec-core (~> 3.
|
44
|
-
rspec-expectations (~> 3.
|
45
|
-
rspec-mocks (~> 3.
|
46
|
-
rspec-core (3.
|
47
|
-
rspec-support (~> 3.
|
48
|
-
rspec-expectations (3.
|
65
|
+
rspec (3.10.0)
|
66
|
+
rspec-core (~> 3.10.0)
|
67
|
+
rspec-expectations (~> 3.10.0)
|
68
|
+
rspec-mocks (~> 3.10.0)
|
69
|
+
rspec-core (3.10.2)
|
70
|
+
rspec-support (~> 3.10.0)
|
71
|
+
rspec-expectations (3.10.2)
|
49
72
|
diff-lcs (>= 1.2.0, < 2.0)
|
50
|
-
rspec-support (~> 3.
|
51
|
-
rspec-mocks (3.
|
73
|
+
rspec-support (~> 3.10.0)
|
74
|
+
rspec-mocks (3.10.3)
|
52
75
|
diff-lcs (>= 1.2.0, < 2.0)
|
53
|
-
rspec-support (~> 3.
|
54
|
-
rspec-support (3.
|
76
|
+
rspec-support (~> 3.10.0)
|
77
|
+
rspec-support (3.10.3)
|
78
|
+
rubocop (0.93.1)
|
79
|
+
parallel (~> 1.10)
|
80
|
+
parser (>= 2.7.1.5)
|
81
|
+
rainbow (>= 2.2.2, < 4.0)
|
82
|
+
regexp_parser (>= 1.8)
|
83
|
+
rexml
|
84
|
+
rubocop-ast (>= 0.6.0)
|
85
|
+
ruby-progressbar (~> 1.7)
|
86
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
87
|
+
rubocop-ast (1.16.0)
|
88
|
+
parser (>= 3.1.1.0)
|
89
|
+
rubocop-gitlab-security (0.1.1)
|
90
|
+
rubocop (>= 0.51)
|
91
|
+
rubocop-graphql (0.14.2)
|
92
|
+
rubocop (>= 0.87, < 2)
|
93
|
+
rubocop-performance (1.9.2)
|
94
|
+
rubocop (>= 0.90.0, < 2.0)
|
95
|
+
rubocop-ast (>= 0.4.0)
|
96
|
+
rubocop-rails (2.9.1)
|
97
|
+
activesupport (>= 4.2.0)
|
98
|
+
rack (>= 1.1)
|
99
|
+
rubocop (>= 0.90.0, < 2.0)
|
100
|
+
rubocop-rspec (1.44.1)
|
101
|
+
rubocop (~> 0.87)
|
102
|
+
rubocop-ast (>= 0.7.1)
|
103
|
+
ruby-progressbar (1.11.0)
|
55
104
|
strings (0.2.1)
|
56
105
|
strings-ansi (~> 0.2)
|
57
106
|
unicode-display_width (>= 1.5, < 3.0)
|
@@ -85,7 +134,9 @@ GEM
|
|
85
134
|
pastel (~> 0.8)
|
86
135
|
strings (~> 0.2.0)
|
87
136
|
tty-screen (~> 0.8)
|
88
|
-
|
137
|
+
tzinfo (2.0.4)
|
138
|
+
concurrent-ruby (~> 1.0)
|
139
|
+
unicode-display_width (1.8.0)
|
89
140
|
unicode_utils (1.4.0)
|
90
141
|
webmock (3.14.0)
|
91
142
|
addressable (>= 2.8.0)
|
@@ -98,10 +149,11 @@ PLATFORMS
|
|
98
149
|
|
99
150
|
DEPENDENCIES
|
100
151
|
dri!
|
101
|
-
|
102
|
-
|
152
|
+
gitlab-styles (~> 7.0.0)
|
153
|
+
rake
|
154
|
+
rspec (~> 3.10.0)
|
103
155
|
timecop (~> 0.9.1)
|
104
156
|
webmock (~> 3.5)
|
105
157
|
|
106
158
|
BUNDLED WITH
|
107
|
-
2.
|
159
|
+
2.3.9
|
data/README.md
CHANGED
@@ -56,13 +56,17 @@ $ dri profile
|
|
56
56
|
- failures
|
57
57
|
- testcases
|
58
58
|
- triaged
|
59
|
+
- quarantines
|
60
|
+
- dequarantines
|
61
|
+
- featureflags
|
59
62
|
- [4. publish](#4-publish)
|
60
63
|
- report
|
61
64
|
- [5. rm](#5-rm)
|
62
65
|
- emoji
|
63
66
|
- profile
|
64
67
|
- reports
|
65
|
-
- [6.
|
68
|
+
- [6. incidents](#6-incidents)
|
69
|
+
- [7. version](#7-version)
|
66
70
|
|
67
71
|
#### 1. init
|
68
72
|
|
@@ -107,6 +111,25 @@ $ dri fetch triaged
|
|
107
111
|
|
108
112
|
Fetches triaged failures which use the triage emoji specified in `dri profile`.
|
109
113
|
|
114
|
+
```shell
|
115
|
+
$ dri fetch quarantines
|
116
|
+
```
|
117
|
+
|
118
|
+
Fetches open quarantine Merge Requests to be reviewed
|
119
|
+
|
120
|
+
```shell
|
121
|
+
$ dri fetch dequarantines
|
122
|
+
```
|
123
|
+
|
124
|
+
Fetches open dequarantine Merge Requests to be reviewed
|
125
|
+
|
126
|
+
```shell
|
127
|
+
$ dri fetch featureflags
|
128
|
+
```
|
129
|
+
|
130
|
+
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.
|
131
|
+
Results are organized by environment (production, staging, staging ref and preprod).
|
132
|
+
|
110
133
|
#### 4. publish
|
111
134
|
|
112
135
|
```shell
|
@@ -159,7 +182,15 @@ $ dri rm profile
|
|
159
182
|
|
160
183
|
Removes the profile currently in use.
|
161
184
|
|
162
|
-
#### 6.
|
185
|
+
#### 6. incidents
|
186
|
+
|
187
|
+
```shell
|
188
|
+
$ dri incidents
|
189
|
+
```
|
190
|
+
|
191
|
+
Have a quick look at currently active/mitigated incidents on GitLab services.
|
192
|
+
|
193
|
+
#### 7. version
|
163
194
|
|
164
195
|
```shell
|
165
196
|
$ dri version
|
data/Rakefile
CHANGED
data/bin/console
CHANGED
data/dri.gemspec
CHANGED
@@ -1,41 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'lib/dri/version'
|
2
4
|
|
3
5
|
Gem::Specification.new do |spec|
|
4
|
-
spec.name =
|
5
|
-
spec.license =
|
6
|
+
spec.name = 'dri'
|
7
|
+
spec.license = 'MIT'
|
6
8
|
spec.version = Dri::VERSION
|
7
|
-
spec.authors = [
|
8
|
-
spec.email = [
|
9
|
+
spec.authors = ['GitLab Quality']
|
10
|
+
spec.email = ['quality+dri@gitlab.com']
|
9
11
|
|
10
|
-
spec.summary =
|
12
|
+
spec.summary = 'CLI app to help triage GitLab QA pipelines'
|
11
13
|
spec.homepage = 'https://gitlab.com/gitlab-org/quality/dri'
|
12
|
-
spec.required_ruby_version = Gem::Requirement.new(
|
14
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.7.0')
|
13
15
|
|
14
16
|
# Specify which files should be added to the gem when it is released.
|
15
17
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
16
|
-
spec.files
|
18
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
17
19
|
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
20
|
end
|
19
|
-
spec.bindir =
|
21
|
+
spec.bindir = 'exe'
|
20
22
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
21
|
-
spec.require_paths = [
|
23
|
+
spec.require_paths = ['lib']
|
22
24
|
|
23
|
-
spec.add_dependency
|
24
|
-
spec.add_dependency
|
25
|
-
spec.add_dependency
|
26
|
-
spec.add_dependency
|
27
|
-
spec.add_dependency
|
25
|
+
spec.add_dependency 'httparty', '~> 0.20.0'
|
26
|
+
spec.add_dependency 'json', '~> 2.6.1'
|
27
|
+
spec.add_dependency 'markdown-tables', '~> 1.1.1'
|
28
|
+
spec.add_dependency 'pastel', '~> 0.8.0'
|
29
|
+
spec.add_dependency 'thor', '~> 1.0.1'
|
28
30
|
spec.add_dependency 'tty-box', '~> 0.7.0'
|
31
|
+
spec.add_dependency 'tty-config', '~> 0.4.0'
|
32
|
+
spec.add_dependency 'tty-editor', '~> 0.6'
|
33
|
+
spec.add_dependency 'tty-font', '~> 0.5'
|
29
34
|
spec.add_dependency 'tty-logger', '~> 0.6.0'
|
30
|
-
spec.add_dependency
|
31
|
-
spec.add_dependency
|
32
|
-
spec.add_dependency
|
33
|
-
spec.add_dependency "markdown-tables", "~> 1.1.1"
|
34
|
-
spec.add_dependency 'json', '~> 2.6.1'
|
35
|
-
spec.add_dependency 'httparty', '~> 0.20.0'
|
35
|
+
spec.add_dependency 'tty-prompt', '~> 0.23.1'
|
36
|
+
spec.add_dependency 'tty-spinner', '~> 0.9'
|
37
|
+
spec.add_dependency 'tty-table', '~> 0.12.0'
|
36
38
|
|
37
|
-
spec.add_development_dependency
|
39
|
+
spec.add_development_dependency 'gitlab-styles', '~> 7.0.0'
|
40
|
+
spec.add_development_dependency 'rake'
|
38
41
|
spec.add_development_dependency 'rspec', '~> 3.10.0'
|
39
|
-
spec.add_development_dependency 'webmock', '~> 3.5'
|
40
42
|
spec.add_development_dependency "timecop", "~> 0.9.1"
|
43
|
+
spec.add_development_dependency 'webmock', '~> 3.5'
|
41
44
|
end
|
data/exe/dri
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
lib_path = File.expand_path('../lib', __dir__)
|
5
|
-
|
5
|
+
$LOAD_PATH.unshift(lib_path) unless $LOAD_PATH.include?(lib_path)
|
6
6
|
require 'dri/cli'
|
7
7
|
|
8
8
|
Signal.trap('INT') do
|
@@ -12,7 +12,7 @@ end
|
|
12
12
|
|
13
13
|
begin
|
14
14
|
Dri::CLI.start
|
15
|
-
rescue Dri::CLI::Error =>
|
16
|
-
puts "ERROR: #{
|
15
|
+
rescue Dri::CLI::Error => e
|
16
|
+
puts "ERROR: #{e.message}"
|
17
17
|
exit 1
|
18
18
|
end
|
data/lib/dri/api_client.rb
CHANGED
@@ -3,14 +3,16 @@
|
|
3
3
|
require "httparty"
|
4
4
|
require "json"
|
5
5
|
require "tty-config"
|
6
|
+
require 'cgi'
|
6
7
|
|
7
8
|
module Dri
|
8
|
-
class ApiClient
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
class ApiClient # rubocop:disable Metrics/ClassLength
|
10
|
+
API_URL = 'https://gitlab.com/api/v4'
|
11
|
+
TESTCASES_PROJECT_ID = '11229385'
|
12
|
+
TRIAGE_PROJECT_ID = '15291320'
|
13
|
+
GITLAB_PROJECT_ID = '278964'
|
14
|
+
FEATURE_FLAG_LOG_PROJECT_ID = '15208716'
|
15
|
+
INFRA_TEAM_PROD_PROJECT_ID = '7444821'
|
14
16
|
|
15
17
|
def initialize(config)
|
16
18
|
profile = config.read
|
@@ -50,6 +52,26 @@ module Dri
|
|
50
52
|
fetch_json(url.join)
|
51
53
|
end
|
52
54
|
|
55
|
+
# Fetch MRs
|
56
|
+
#
|
57
|
+
# @see https://docs.gitlab.com/ee/api/merge_requests.html for all passable options
|
58
|
+
#
|
59
|
+
# @param [Hash<String>] options
|
60
|
+
# @option options [String] state
|
61
|
+
# @option options [String] order_by
|
62
|
+
# @option options [String] sort
|
63
|
+
# @option options [String] milestone
|
64
|
+
# @option options [String] labels
|
65
|
+
def fetch_mrs(project_id:, **options)
|
66
|
+
uri = URI(API_URL)
|
67
|
+
uri.query = HTTParty::HashConversions.to_params(options)
|
68
|
+
|
69
|
+
# CGI.escape('gitlab-org/gitlab') => 'gitlab-org%2Fgitlab'
|
70
|
+
uri.path = File.join(uri.path, 'projects', CGI.escape(project_id), 'merge_requests')
|
71
|
+
|
72
|
+
fetch_json(uri.to_s)
|
73
|
+
end
|
74
|
+
|
53
75
|
def fetch_current_triage_issue
|
54
76
|
url = ["#{API_URL}/projects/"]
|
55
77
|
url << "#{TRIAGE_PROJECT_ID}/issues?state=opened"
|
@@ -71,6 +93,7 @@ module Dri
|
|
71
93
|
url << "&order_by=updated_at&state=#{state}"
|
72
94
|
url << "&scope=all"
|
73
95
|
url << "&created_after=#{date}"
|
96
|
+
url << "&per_page=100"
|
74
97
|
|
75
98
|
fetch_json(url.join)
|
76
99
|
end
|
@@ -87,6 +110,25 @@ module Dri
|
|
87
110
|
delete_json(url)
|
88
111
|
end
|
89
112
|
|
113
|
+
def fetch_feature_flag_logs(date:, page:)
|
114
|
+
url = ["#{API_URL}/projects/"]
|
115
|
+
url << "#{FEATURE_FLAG_LOG_PROJECT_ID}/issues"
|
116
|
+
url << "?created_after=#{date}"
|
117
|
+
url << "&per_page=100"
|
118
|
+
url << "&page=#{page}"
|
119
|
+
|
120
|
+
fetch_json(url.join)
|
121
|
+
end
|
122
|
+
|
123
|
+
def incidents
|
124
|
+
url = ["#{API_URL}/projects/"]
|
125
|
+
url << "#{INFRA_TEAM_PROD_PROJECT_ID}/issues"
|
126
|
+
url << "?order_by=updated_at&state=opened"
|
127
|
+
url << "&labels=incident"
|
128
|
+
|
129
|
+
fetch_json(url.join)
|
130
|
+
end
|
131
|
+
|
90
132
|
private
|
91
133
|
|
92
134
|
def post_json(url, body)
|
@@ -97,7 +139,7 @@ module Dri
|
|
97
139
|
}
|
98
140
|
}
|
99
141
|
|
100
|
-
response =
|
142
|
+
response = HTTParty.post(url, options)
|
101
143
|
handle_response(response)
|
102
144
|
end
|
103
145
|
|
@@ -107,12 +149,11 @@ module Dri
|
|
107
149
|
end
|
108
150
|
|
109
151
|
def handle_response(response)
|
110
|
-
#puts response.to_json
|
111
152
|
response
|
112
153
|
end
|
113
154
|
|
114
155
|
def fetch_json(url)
|
115
|
-
response =
|
156
|
+
response = HTTParty.get(url, headers: header)
|
116
157
|
|
117
158
|
if response.code != 200
|
118
159
|
puts "Response error code \"#{response.code}\" - Unable to sync with GitLab"
|
@@ -122,4 +163,4 @@ module Dri
|
|
122
163
|
handle_response(JSON.parse(response.body))
|
123
164
|
end
|
124
165
|
end
|
125
|
-
end
|
166
|
+
end
|
data/lib/dri/cli.rb
CHANGED
@@ -25,14 +25,26 @@ module Dri
|
|
25
25
|
end
|
26
26
|
|
27
27
|
class_option :no_color, type: :boolean, default: false,
|
28
|
-
|
28
|
+
desc: "Disable colorization in output"
|
29
29
|
|
30
30
|
desc 'version', 'dri version'
|
31
31
|
def version
|
32
32
|
require_relative 'version'
|
33
33
|
puts "v#{Dri::VERSION}"
|
34
34
|
end
|
35
|
-
map %w
|
35
|
+
map %w[--version -v] => :version
|
36
|
+
|
37
|
+
desc 'incidents', 'View current incidents'
|
38
|
+
method_option :help, aliases: '-h', type: :boolean,
|
39
|
+
desc: 'Display usage information'
|
40
|
+
def incidents(*)
|
41
|
+
if options[:help]
|
42
|
+
invoke :help, ['incidents']
|
43
|
+
else
|
44
|
+
require_relative 'commands/incidents'
|
45
|
+
Dri::Commands::Incidents.new(options).execute
|
46
|
+
end
|
47
|
+
end
|
36
48
|
|
37
49
|
require_relative 'commands/rm'
|
38
50
|
register Dri::Commands::Rm, 'rm', 'rm [SUBCOMMAND]', 'Remove triage-related items'
|
data/lib/dri/command.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require_relative 'command'
|
3
4
|
require_relative 'api_client'
|
4
5
|
|
6
|
+
require 'dri/refinements/truncate'
|
7
|
+
|
5
8
|
require "tty-config"
|
6
9
|
require "pastel"
|
7
10
|
require 'forwardable'
|
@@ -11,7 +14,6 @@ module Dri
|
|
11
14
|
extend Forwardable
|
12
15
|
|
13
16
|
def_delegators :command, :run
|
14
|
-
attr_reader :config, :emoji, :token, :username, :timezone, :profile
|
15
17
|
|
16
18
|
def pastel(**options)
|
17
19
|
Pastel.new(**options)
|
@@ -54,10 +56,10 @@ module Dri
|
|
54
56
|
end
|
55
57
|
|
56
58
|
def verify_config_exists
|
57
|
-
if
|
58
|
-
|
59
|
-
|
60
|
-
|
59
|
+
return if config.exist?
|
60
|
+
|
61
|
+
logger.error "Oops, could not find a configuration. Try using #{add_color('dri init', :yellow)} first."
|
62
|
+
exit 1
|
61
63
|
end
|
62
64
|
|
63
65
|
def add_color(str, *color)
|
@@ -121,7 +123,7 @@ module Dri
|
|
121
123
|
# @api public
|
122
124
|
def prompt(**options)
|
123
125
|
require 'tty-prompt'
|
124
|
-
TTY::Prompt.new(options)
|
126
|
+
TTY::Prompt.new(options.merge(interrupt: :exit))
|
125
127
|
end
|
126
128
|
end
|
127
129
|
end
|