dri 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 879c4292254a2a17a0ebcd8e2c0a3f8bbc6e654a69c153ad66423c71eb750fc4
4
- data.tar.gz: 51f8e1acec1894ce4a6ab264ef690cf063259f46512d743609bf2f5a6529132f
3
+ metadata.gz: cb71a1d13a00cb33c436608e3c34e40a4202505bad341d31d5d85803c36495d4
4
+ data.tar.gz: 73648bafa41eac28824435b62a41ead17494c144bbd99c6af52062e616379f2a
5
5
  SHA512:
6
- metadata.gz: ad020b17eb8d05322800332e59b5d286dcb8712df055dab50be7f234df2864a5ba719f900d61b0ba25308a1ea130fa2b586b7f01215beec90eafb614cc8c6da1
7
- data.tar.gz: c0ef20575dcc1f9fa3312df5970b79a8b6fa11b8401a1a80d30561c8a764c7bcd140d4e649c619fbce1be6b9f71c943fb51aa5a48c20b18c5f480af4a821bc07
6
+ metadata.gz: 6c2d592d0906e3764ec1ab2fe298a42a1798be1d58dd216261ed2a88227cfe007a97a175ae199f5ee4f4db16f7efe2dd6f99521e8febc740e191b61c0f2ef8cc
7
+ data.tar.gz: 1106b7fc11be59d38c72f471f8a5148eb4e724a81665b4382185da5c22a4e554fc7e1b1cc274a980b9ceeb6071f7fa5da0397e3657655132a6d21f2a31cf9712
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dri (0.4.0)
4
+ dri (0.5.0)
5
5
  gitlab (~> 4.18)
6
6
  httparty (~> 0.20.0)
7
7
  json (~> 2.6.1)
@@ -13,8 +13,9 @@ module Dri
13
13
  SORT_BY_OPTIONS = {
14
14
  title: 0,
15
15
  triaged: 1,
16
- author: 2,
17
- url: 3
16
+ environment: 2,
17
+ author: 3,
18
+ url: 4
18
19
  }.freeze
19
20
 
20
21
  def initialize(options)
@@ -25,14 +26,16 @@ module Dri
25
26
  def execute(input: $stdin, output: $stdout) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
26
27
  verify_config_exists
27
28
 
29
+ urgent_environments = %w[canary canary.staging]
30
+
28
31
  title = add_color('Title', :bright_yellow)
29
32
  triaged = add_color('Triaged?', :bright_yellow)
33
+ environment = add_color('Environment', :bright_yellow)
30
34
  author = add_color('Author', :bright_yellow)
31
35
  url = add_color('URL', :bright_yellow)
32
36
 
33
37
  failures = []
34
- urgent = []
35
- labels = [title, triaged, author, url]
38
+ labels = [title, triaged, environment, author, url]
36
39
  triaged_counter = 0
37
40
 
38
41
  logger.info "Fetching today's failures..."
@@ -50,6 +53,12 @@ module Dri
50
53
  author = failure.to_h.dig('author', 'username')
51
54
  url = failure.web_url
52
55
  triaged = add_color('x', :red)
56
+ envs = failure.labels.select { |l| l.include?('found:') }.map do |l|
57
+ env = l.split(':').last.gsub('.gitlab.com', '')
58
+
59
+ env == 'gitlab.com' ? 'production' : env
60
+ end
61
+ urgent = urgent_environments.all? { |env| envs.include?(env) }
53
62
 
54
63
  emoji_awards = api_client.fetch_awarded_emojis(failure.iid).find do |e|
55
64
  e.name == emoji && e.to_h.dig('user', 'username') == username
@@ -61,32 +70,27 @@ module Dri
61
70
  end
62
71
 
63
72
  if @options[:urgent]
64
- labels = failure.labels
65
-
66
- labels.each do |label|
67
- if label.include?('found:canary.gitlab.com' && 'found:canary.staging.gitlab.com')
68
- urgent << [title, triaged, author, url]
69
- end
70
- end
73
+ failures << [title, triaged, envs.first, author, url] if urgent
74
+ else
75
+ failures << [title, triaged, envs.first, author, url]
71
76
  end
72
-
73
- failures << [title, triaged, author, url]
74
-
75
- failures.sort_by! { |e| e[SORT_BY_OPTIONS[@options[:sort_by].to_sym]] } if @options[:sort_by]
76
77
  end
77
- end
78
78
 
79
- if @options[:urgent]
80
- print_table(labels, urgent, alignments: [:left, :center, :center, :left])
81
- output.puts(<<~MSG)
82
- Found: #{urgent.size} urgent failures, occurring in both canary.gitlab.com and canary.staging.gitlab.com.
83
- MSG
84
- else
85
- print_table(labels, failures, alignments: [:left, :center, :center, :left])
86
- output.puts(<<~MSG)
87
- Found: #{failures.size} failures, of these #{triaged_counter} have been triaged with a #{emoji}.
88
- MSG
79
+ failures.sort_by! { |failure| failure[SORT_BY_OPTIONS[@options[:sort_by]&.to_sym || :environment]] }
89
80
  end
81
+
82
+ msg = if @options[:urgent]
83
+ <<~MSG
84
+ Found: #{failures.size} urgent failures, occurring in both canary.gitlab.com and canary.staging.gitlab.com.
85
+ MSG
86
+ else
87
+ <<~MSG
88
+ Found: #{failures.size} failures, of these #{triaged_counter} have been triaged with a #{emoji}.
89
+ MSG
90
+ end
91
+
92
+ print_table(labels, failures, alignments: [:left, :center, :center, :left])
93
+ output.puts(msg)
90
94
  end
91
95
  end
92
96
  end
data/lib/dri/report.rb CHANGED
@@ -95,7 +95,7 @@ module Dri
95
95
  end
96
96
 
97
97
  unless pipeline_link.empty?
98
- pipeline_link_sanitized = pipeline_link.join.strip.chop
98
+ pipeline_link_sanitized = pipeline_link.join.strip
99
99
  pipeline_markdown = "[#{pipeline_markdown}](#{pipeline_link_sanitized})"
100
100
  end
101
101
 
data/lib/dri/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dri
4
- VERSION = "0.5.0"
4
+ VERSION = "0.5.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dri
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitLab Quality
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-09 00:00:00.000000000 Z
11
+ date: 2022-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gitlab
@@ -337,7 +337,6 @@ files:
337
337
  - lib/dri/gitlab/issues.rb
338
338
  - lib/dri/refinements/truncate.rb
339
339
  - lib/dri/report.rb
340
- - lib/dri/templates/incidents/.gitkeep
341
340
  - lib/dri/utils/feature_flag_consts.rb
342
341
  - lib/dri/utils/markdown_lists.rb
343
342
  - lib/dri/utils/table.rb
@@ -1 +0,0 @@
1
- #