dri 0.11.0 → 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.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.gitlab/changelog_config.yml +13 -0
  3. data/.gitlab/merge_request_templates/Default.md +27 -0
  4. data/.gitlab/merge_request_templates/Release.md +8 -23
  5. data/.gitlab-ci.yml +6 -4
  6. data/.ruby-version +1 -1
  7. data/.tool-versions +1 -1
  8. data/CODE_OF_CONDUCT.md +74 -0
  9. data/Gemfile.lock +21 -2
  10. data/README.md +88 -98
  11. data/dri.gemspec +4 -0
  12. data/exe/dri +2 -1
  13. data/lefthook.yml +24 -0
  14. data/lib/dri/api_client.rb +18 -23
  15. data/lib/dri/cli.rb +0 -15
  16. data/lib/dri/command.rb +17 -51
  17. data/lib/dri/commands/add/fast_quarantine.rb +0 -2
  18. data/lib/dri/commands/add.rb +0 -1
  19. data/lib/dri/commands/analyze/stack_traces.rb +0 -3
  20. data/lib/dri/commands/analyze.rb +0 -1
  21. data/lib/dri/commands/faq.rb +0 -1
  22. data/lib/dri/commands/fetch/failures.rb +25 -25
  23. data/lib/dri/commands/fetch/{featureflags.rb → feature_flags.rb} +0 -5
  24. data/lib/dri/commands/fetch/pipelines.rb +0 -4
  25. data/lib/dri/commands/fetch/runbooks.rb +0 -2
  26. data/lib/dri/commands/fetch/testcases.rb +0 -2
  27. data/lib/dri/commands/fetch/triaged.rb +1 -5
  28. data/lib/dri/commands/fetch.rb +0 -6
  29. data/lib/dri/commands/incidents.rb +1 -5
  30. data/lib/dri/commands/init.rb +0 -2
  31. data/lib/dri/commands/profile.rb +0 -2
  32. data/lib/dri/commands/publish/report.rb +23 -23
  33. data/lib/dri/commands/publish.rb +0 -1
  34. data/lib/dri/commands/rm/emoji.rb +0 -2
  35. data/lib/dri/commands/rm/profile.rb +0 -1
  36. data/lib/dri/commands/rm/reports.rb +0 -1
  37. data/lib/dri/commands/rm.rb +0 -3
  38. data/lib/dri/commands/view/fast_quarantine.rb +0 -2
  39. data/lib/dri/commands/view.rb +0 -1
  40. data/lib/dri/feature_flag_report.rb +0 -2
  41. data/lib/dri/refinements/gitlab.rb +22 -0
  42. data/lib/dri/refinements/string.rb +19 -0
  43. data/lib/dri/report.rb +1 -3
  44. data/lib/dri/support/configuration.rb +62 -0
  45. data/lib/dri/utils/helpers.rb +15 -0
  46. data/lib/dri/version.rb +1 -1
  47. data/lib/dri.rb +8 -1
  48. metadata +72 -10
  49. data/lib/dri/gitlab/issues.rb +0 -19
  50. data/lib/dri/refinements/truncate.rb +0 -15
@@ -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"
@@ -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, state: "opened", order_by: "updated_at")
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 [String] start_date
164
- # @param [String] end_date
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
- project_ids = [GITLAB_PROJECT_ID, CUSTOMERSDOT_PROJECT_ID]
169
- failures = []
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: start_date_iso,
178
- end_date: end_date_iso,
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 [String] start_date
190
- # @param [String] end_date
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
@@ -368,12 +363,12 @@ module Dri
368
363
  # @return [Gitlab::Client]
369
364
  def gitlab
370
365
  if @ops_instance
371
- @ops_client ||= Gitlab.client(
366
+ @ops_client ||= ::Gitlab.client(
372
367
  endpoint: OPS_API_URL,
373
368
  private_token: ops_token
374
369
  )
375
370
  else
376
- @gitlab_client ||= Gitlab.client(
371
+ @gitlab_client ||= ::Gitlab.client(
377
372
  endpoint: API_URL,
378
373
  private_token: token
379
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,19 +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'
105
-
106
- require_relative 'commands/view'
107
94
  register Dri::Commands::View, 'view', 'view [SUBCOMMAND]', 'View relevant items to help triage'
108
-
109
- require_relative 'commands/add'
110
95
  register Dri::Commands::Add, 'add', 'add [SUBCOMMAND]', 'Add relevant items to help triage'
111
96
  end
112
97
  end
data/lib/dri/command.rb CHANGED
@@ -1,19 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'api_client'
4
- require_relative 'gitlab/issues'
5
-
6
- require 'dri/refinements/truncate'
7
-
8
- require "tty-config"
9
3
  require "pastel"
10
4
  require 'forwardable'
11
5
 
12
6
  module Dri
13
7
  class Command
8
+ include Utils::Helpers
14
9
  extend Forwardable
15
10
 
16
11
  def_delegators :command, :run
12
+ def_delegators :configuration,
13
+ :profile,
14
+ :config,
15
+ :emoji,
16
+ :username,
17
+ :token,
18
+ :ops_token,
19
+ :timezone,
20
+ :tz,
21
+ :handover_report_path
17
22
 
18
23
  def initialize(*options)
19
24
  @options = options
@@ -23,50 +28,10 @@ module Dri
23
28
  Pastel.new(**options)
24
29
  end
25
30
 
26
- # Main configuration
27
- def config
28
- @config ||= begin
29
- config = TTY::Config.new
30
- config.filename = ".dri_profile"
31
- config.extname = ".yml"
32
- config.append_path Dir.home
33
- config.append_path Dir.pwd
34
- config
35
- end
36
- end
37
-
38
31
  def api_client(ops: false)
39
32
  ApiClient.new(config, ops)
40
33
  end
41
34
 
42
- def profile
43
- @profile ||= config.read
44
- end
45
-
46
- def emoji
47
- @emoji ||= profile["settings"]["emoji"]
48
- end
49
-
50
- def username
51
- @username ||= profile["settings"]["user"]
52
- end
53
-
54
- def token
55
- @token ||= profile["settings"]["token"]
56
- end
57
-
58
- def ops_token
59
- @ops_token ||= profile["settings"]["ops_token"]
60
- end
61
-
62
- def timezone
63
- @timezone ||= profile["settings"]["timezone"]
64
- end
65
-
66
- def handover_report_path
67
- @handover_report_path ||= profile["settings"]["handover_report_path"]
68
- end
69
-
70
35
  def verify_config_exists
71
36
  return if config.exist?
72
37
 
@@ -92,11 +57,6 @@ module Dri
92
57
  )
93
58
  end
94
59
 
95
- def logger
96
- require 'tty-logger'
97
- TTY::Logger.new
98
- end
99
-
100
60
  def spinner
101
61
  require 'tty-spinner'
102
62
  TTY::Spinner.new("[:spinner] ⏳", format: :classic)
@@ -141,5 +101,11 @@ module Dri
141
101
  require 'tty-prompt'
142
102
  TTY::Prompt.new(**options.merge(interrupt: :exit))
143
103
  end
104
+
105
+ private
106
+
107
+ def configuration
108
+ @configuration ||= Support::Configuration.new
109
+ end
144
110
  end
145
111
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../../command'
4
-
5
3
  module Dri
6
4
  module Commands
7
5
  class Add
@@ -38,7 +38,6 @@ module Dri
38
38
  return
39
39
  end
40
40
 
41
- require_relative 'add/fast_quarantine'
42
41
  Dri::Commands::Add::FastQuarantine.new(options).execute
43
42
  end
44
43
  end
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../../command'
4
- require_relative '../../utils/table'
5
- require_relative '../../utils/constants'
6
3
  require 'amatch'
7
4
  require 'fileutils'
8
5
 
@@ -12,7 +12,6 @@ module Dri
12
12
  def stacktraces(*)
13
13
  return invoke :help, %w[stacktraces] if options[:help]
14
14
 
15
- require_relative 'analyze/stack_traces'
16
15
  Dri::Commands::Analyze::StackTraces.new(options).execute
17
16
  end
18
17
  end
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../command'
4
3
  require 'tty-prompt'
5
4
  require 'launchy'
6
5
 
@@ -2,11 +2,6 @@
2
2
 
3
3
  require "influxdb-client"
4
4
 
5
- require_relative '../../command'
6
- require_relative '../../utils/table'
7
- require_relative '../../utils/constants'
8
- require_relative '../../support/influxdb_tools'
9
-
10
5
  module Dri
11
6
  module Commands
12
7
  class Fetch
@@ -14,13 +9,11 @@ module Dri
14
9
  include Dri::Utils::Table
15
10
  include Dri::Utils::Constants::Triage::Labels
16
11
  include Dri::Support::InfluxdbTools
17
- using Refinements
12
+ using Refinements::String
18
13
 
19
14
  def initialize(options)
20
15
  @options = options
21
- @start_date = @options[:start_date] ? Date.parse(@options[:start_date]) : Date.today - 1
22
- @end_date = @options[:end_date] ? Date.parse(@options[:end_date]) : Date.today
23
- @cutoff_time = @options[:cutoff] ? Time.parse(options[:cutoff]).utc : nil
16
+ @cutoff_time = @options[:cutoff] ? Time.parse(options[:cutoff]) : nil
24
17
  end
25
18
 
26
19
  def execute(_input: $stdin, output: $stdout) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
@@ -37,31 +30,18 @@ module Dri
37
30
  updated_at: updated_at }
38
31
  triaged_counter = 0
39
32
 
40
- if @cutoff_time
41
- @start_date = Time.new(
42
- @start_date.year,
43
- @start_date.month,
44
- @start_date.day,
45
- @cutoff_time.hour,
46
- @cutoff_time.min, 0,
47
- "+00:00"
48
- )
49
- end
50
-
51
- logger.info "Fetching failures from #{@start_date} (UTC) to #{@end_date} (UTC)..."
33
+ logger.info "Fetching failures from '#{start_date}' to '#{end_date}'..."
52
34
 
53
35
  spinner.run do # rubocop:disable Metrics/BlockLength
54
- failures = api_client.fetch_all_new_failures(start_date: @start_date, end_date: @end_date, state: 'opened')
36
+ failures = api_client.fetch_all_new_failures(start_date: start_date, end_date: end_date, state: 'opened')
55
37
 
56
38
  if failures.empty?
57
- logger.info "Life is great, there are no new failures between #{@start_date} and #{@end_date}!"
39
+ logger.info "Life is great, there are no new failures between #{start_date} and #{end_date}!"
58
40
  exit 0
59
41
  end
60
42
 
61
43
  blocker_set = Set.new
62
44
 
63
- blocker_set = Set.new
64
-
65
45
  if query_api
66
46
  begin
67
47
  blockers = query_api.query(query: query_reliables_smokes)
@@ -129,6 +109,26 @@ module Dri
129
109
 
130
110
  private
131
111
 
112
+ def start_date
113
+ return @start_date if @start_date
114
+
115
+ parsed_start_date = @options[:start_date] ? Date.parse(@options[:start_date]) : tz.now
116
+ @start_date = date_with_time(parsed_start_date, @cutoff_time&.hour, @cutoff_time&.min, 0,
117
+ @options[:start_date] ? "+00:00" : tz.canonical_zone)
118
+ end
119
+
120
+ def end_date
121
+ return @end_date if @end_date
122
+
123
+ parsed_end_date = @options[:end_date] ? Date.parse(@options[:end_date]) : tz.now
124
+ @end_date = date_with_time(parsed_end_date, 23, 59, 59,
125
+ @options[:end_date] ? "+00:00" : tz.canonical_zone)
126
+ end
127
+
128
+ def date_with_time(date, hour, min, seconds, tz_identifier)
129
+ Time.new(date.year, date.month, date.day, hour || 0, min || 0, seconds || 0, tz_identifier)
130
+ end
131
+
132
132
  def blocker?(title, set)
133
133
  title_part = title.split('|').last
134
134
  return true if title_part&.strip && set.include?(title_part.strip)
@@ -1,10 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../../command'
4
- require_relative '../../utils/table'
5
- require_relative '../../utils/constants'
6
- require_relative '../../feature_flag_report'
7
-
8
3
  module Dri
9
4
  module Commands
10
5
  class Fetch
@@ -1,9 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'date'
4
- require_relative '../../command'
5
- require_relative '../../utils/table'
6
- require_relative '../../utils/constants'
7
4
 
8
5
  module Dri
9
6
  module Commands
@@ -11,7 +8,6 @@ module Dri
11
8
  class Pipelines < Dri::Command # rubocop:disable Metrics/ClassLength
12
9
  include Dri::Utils::Table
13
10
  include Dri::Utils::Constants
14
- using Refinements
15
11
 
16
12
  NUM_OF_TESTS_LIVE_ENV = 1000
17
13
  NOT_FOUND = "Not found"
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../../command'
4
- require_relative '../../utils/constants'
5
3
  require 'tty-markdown'
6
4
  require 'tty-prompt'
7
5
  require 'base64'
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../../command'
4
-
5
3
  require 'pastel'
6
4
 
7
5
  module Dri
@@ -1,16 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../../command'
4
- require_relative '../../utils/table'
5
- require_relative '../../utils/constants'
6
-
7
3
  module Dri
8
4
  module Commands
9
5
  class Fetch
10
6
  class Triaged < Dri::Command
11
7
  include Dri::Utils::Table
12
8
  include Dri::Utils::Constants::Triage::Labels
13
- using Refinements
9
+ using Refinements::String
14
10
 
15
11
  def initialize(options)
16
12
  @options = options
@@ -14,7 +14,6 @@ module Dri
14
14
  if options[:help]
15
15
  invoke :help, ['featureflags']
16
16
  else
17
- require_relative 'fetch/featureflags'
18
17
  Dri::Commands::Fetch::FeatureFlags.new(options).execute
19
18
  end
20
19
  end
@@ -26,7 +25,6 @@ module Dri
26
25
  if options[:help]
27
26
  invoke :help, ['triaged']
28
27
  else
29
- require_relative 'fetch/triaged'
30
28
  Dri::Commands::Fetch::Triaged.new(options).execute
31
29
  end
32
30
  end
@@ -40,7 +38,6 @@ module Dri
40
38
  if options[:help]
41
39
  invoke :help, ['testcases']
42
40
  else
43
- require_relative 'fetch/testcases'
44
41
  Dri::Commands::Fetch::Testcases.new(options).execute
45
42
  end
46
43
  end
@@ -61,7 +58,6 @@ module Dri
61
58
  if options[:help]
62
59
  invoke :help, ['failures']
63
60
  else
64
- require_relative 'fetch/failures'
65
61
  Dri::Commands::Fetch::Failures.new(options).execute
66
62
  end
67
63
  end
@@ -74,7 +70,6 @@ module Dri
74
70
  def pipelines(*)
75
71
  return invoke :help, %w[pipelines] if options[:help]
76
72
 
77
- require_relative 'fetch/pipelines'
78
73
  Dri::Commands::Fetch::Pipelines.new(options).execute
79
74
  end
80
75
 
@@ -85,7 +80,6 @@ module Dri
85
80
  def runbooks(*args)
86
81
  return invoke :help, %w[runbooks] if options[:help]
87
82
 
88
- require_relative 'fetch/runbooks'
89
83
  Dri::Commands::Fetch::Runbooks.new(options).execute(folder: args.first)
90
84
  end
91
85
  end
@@ -1,15 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../command'
4
- require_relative '../utils/table'
5
- require_relative '../utils/constants'
6
-
7
3
  module Dri
8
4
  module Commands
9
5
  class Incidents < Dri::Command
10
6
  include Dri::Utils::Table
11
7
  include Dri::Utils::Constants::Triage::Labels
12
- using Refinements
8
+ using Refinements::String
13
9
 
14
10
  def initialize(options)
15
11
  @options = options
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../command'
4
-
5
3
  require "tty-font"
6
4
 
7
5
  module Dri
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../command'
4
-
5
3
  require 'tty-box'
6
4
 
7
5
  module Dri
@@ -1,14 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../../command'
4
- require_relative '../../utils/markdown_lists'
5
- require_relative '../../utils/constants'
6
- require_relative '../../report'
7
- require_relative '../../feature_flag_report'
8
-
9
3
  require 'markdown-tables'
10
4
  require 'fileutils'
11
5
  require 'uri'
6
+ require 'date'
12
7
 
13
8
  module Dri
14
9
  module Commands
@@ -161,41 +156,34 @@ module Dri
161
156
  logger.info 'Downloading the report... '
162
157
 
163
158
  spinner.start
164
-
165
- FileUtils.mkdir_p(handover_report_path)
166
- report_path = "#{handover_report_path.chomp('/')}/report-#{@date}-#{@time}.md"
167
-
168
- File.open(report_path, 'a') do |out_file|
169
- out_file.puts note
170
- end
171
-
159
+ report_md = File.join(handover_report_path, "report-#{@date}-#{@time}.md")
160
+ File.write(report_md, note)
172
161
  spinner.stop
173
162
 
174
163
  output.puts "Done! ✅\n"
175
- logger.success "Report is ready at: #{report_path}"
164
+ logger.success "Report is ready at: #{report_md}"
176
165
  exit 0
177
166
  end
178
167
 
179
168
  # sends note to the weekly triage report
180
169
  issues = api_client.fetch_current_triage_issue
181
- current_issue_iid = issues.first.iid
170
+ current_issue_iid = issues.iid
182
171
 
183
172
  note_action = 'posted'
184
173
  posted_note = nil
185
174
  if @options[:update]
186
- report_file = File.read("handover_reports/.tmp/report-#{@date}.json")
187
- report_json = JSON.parse(report_file) if report_file
175
+ unless File.exist?(report_json_file)
176
+ return logger.warn("Update action requires initial publish to be executed first!")
177
+ end
178
+
179
+ report_json = JSON.parse(File.read(report_json_file))
188
180
  posted_note = api_client.update_triage_report_note(
189
181
  iid: current_issue_iid, note_id: report_json['id'], body: note
190
182
  )
191
183
  note_action = 'updated'
192
184
  else
193
185
  posted_note = api_client.post_triage_report_note(iid: current_issue_iid, body: note)
194
-
195
- FileUtils.mkdir_p("#{Dir.pwd}/handover_reports/.tmp")
196
- report_path = "handover_reports/.tmp/report-#{@date}.json"
197
-
198
- File.write(report_path, posted_note.to_h.to_json)
186
+ File.write(report_json_file, posted_note.to_h.to_json)
199
187
  end
200
188
 
201
189
  output.puts "Done! ✅\n"
@@ -206,6 +194,18 @@ module Dri
206
194
 
207
195
  private
208
196
 
197
+ def report_json_file
198
+ @report_json ||= File.join(handover_tmp_dir, "report-#{@date}.json")
199
+ end
200
+
201
+ def handover_tmp_dir
202
+ @handover_tmp_dir ||= File.join(handover_report_path, ".tmp").tap { |dir| FileUtils.mkdir_p(dir) }
203
+ end
204
+
205
+ def handover_report_path
206
+ @handover_report_path ||= super.tap { |dir| FileUtils.mkdir_p(dir) }
207
+ end
208
+
209
209
  def format_feature_flag_changes(env, changes, labels, format_type)
210
210
  unless format_type == :table || format_type == :list
211
211
  raise ArgumentError, 'format_type must be one of type :table or :list'
@@ -23,7 +23,6 @@ module Dri
23
23
  if options[:help]
24
24
  invoke :help, ['report']
25
25
  else
26
- require_relative 'publish/report'
27
26
  Dri::Commands::Publish::Report.new(options).execute
28
27
  end
29
28
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../../command'
4
-
5
3
  module Dri
6
4
  module Commands
7
5
  class Rm
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../../command'
4
3
  require 'fileutils'
5
4
 
6
5
  module Dri
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative '../../command'
4
3
  require 'fileutils'
5
4
 
6
5
  module Dri