allure-report-publisher 0.5.1 → 0.5.4

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: ef51790888932877d33ebf9edc9307bc14211088fbe41ba34398e9668980f1a0
4
- data.tar.gz: 4a3fcce060bcea96aadcc9ab8e37f523148c606bb4f0ca8081798e8a6a239ac3
3
+ metadata.gz: e07e63b14a3d8101f13eb9f4f824485f0c9eab83a8cc3d2dc13beb72cb3817c4
4
+ data.tar.gz: 5d040670bafc783b72e803b0fc942714b4aa5a560070711389821461a9f485bf
5
5
  SHA512:
6
- metadata.gz: 40ccf342af3d5b90cb8b9eb9473bc63379e225c4a8e45466a9e66bc4c16476afd1573edade5101abf63d8f4a7936fd42ef87d61dfcfda950ab3da276c7425766
7
- data.tar.gz: 59f451092604006ba5b742aa679c240f37eda76b9bc034b329c1965bd52163bd2ef371e543faca7b4349ffd586fc38497c1563db532405395b1cf98c9f4822ee
6
+ metadata.gz: bbbef8d211fa162cb3dc3cb170bcc6167247938f9157e28c75f0a12c2d6296e1cc8b546e5b962855a6e6944b9e31d2538153237773a794991c47a822cde2e9bb
7
+ data.tar.gz: 5734ed15c3c4296394b34a05a86c48e06da2e6e12bcb044941c5624c6775a577019fe071bd4d55a01c07f56bce92e634044591ae0edfc13b5e9e21f5436ff8e2
@@ -23,9 +23,13 @@ module Publisher
23
23
  #
24
24
  # @return [Terminal::Table]
25
25
  def table
26
- return terminal_table([short_summary]) if summary_type == TOTAL
26
+ return terminal_table { |table| table << short_summary } if summary_type == TOTAL
27
27
 
28
- terminal_table(expanded_summary)
28
+ terminal_table do |table|
29
+ expanded_summary.each { |row| table << row }
30
+ table << :separator
31
+ table << short_summary
32
+ end
29
33
  end
30
34
 
31
35
  # Test run status emoji
@@ -44,7 +48,7 @@ module Publisher
44
48
  # @return [Array<Array>]
45
49
  def expanded_summary
46
50
  @expanded_summary ||= summary_data.map do |name, summary|
47
- [name, *summary.values, status_icon(summary[:failed], summary[:flaky])]
51
+ [name, *summary.values, status_icon(summary[:passed], summary[:failed], summary[:flaky])]
48
52
  end
49
53
  end
50
54
 
@@ -67,30 +71,31 @@ module Publisher
67
71
  sum[:failed],
68
72
  sum[:skipped],
69
73
  sum[:flaky],
70
- status_icon(sum[:failed], sum[:flaky])
74
+ status_icon(sum[:passed], sum[:failed], sum[:flaky])
71
75
  ]
72
76
  end
73
77
 
74
78
  # Status icon based on run results
75
79
  #
80
+ # @param [Integer] passed
76
81
  # @param [Integer] failed
77
82
  # @param [Integer] flaky
78
83
  # @return [String]
79
- def status_icon(failed, flaky)
80
- return flaky.zero? ? "" : "⚠️" if failed.zero?
84
+ def status_icon(passed, failed, flaky)
85
+ return "" if passed.zero? && failed.zero?
86
+ return flaky.zero? ? "✅" : "❗" if failed.zero?
81
87
 
82
88
  "❌"
83
89
  end
84
90
 
85
91
  # Summary terminal table
86
92
  #
87
- # @param [Array] rows
88
93
  # @return [Terminal::Table]
89
- def terminal_table(rows)
94
+ def terminal_table
90
95
  Terminal::Table.new do |table|
91
96
  table.title = "#{summary_type} summary"
92
97
  table.headings = ["", "passed", "failed", "skipped", "flaky", "result"]
93
- table.rows = rows
98
+ yield(table)
94
99
  end
95
100
  end
96
101
 
@@ -29,26 +29,30 @@ module Publisher
29
29
  urls_block.match?(DESCRIPTION_PATTERN)
30
30
  end
31
31
 
32
- # Get urls for PR update
32
+ # PR description with allure report urls
33
33
  #
34
- # @param [String] pr
34
+ # @param [String] pr_description
35
35
  # @return [String]
36
36
  def updated_pr_description(pr_description)
37
- return strip_separator(body) unless pr_description
38
- return "#{pr_description}\n\n#{body}" unless pr_description.match?(DESCRIPTION_PATTERN)
37
+ stripped_description = (pr_description || "").strip
38
+
39
+ return url_section(separator: false) if stripped_description == ""
40
+ return "#{pr_description}\n\n#{url_section}" unless pr_description.match?(DESCRIPTION_PATTERN)
39
41
 
40
42
  job_entries = jobs_section(pr_description)
41
- pr_description.gsub(DESCRIPTION_PATTERN, body(job_entries))
43
+ non_empty = stripped_description != pr_description.match(DESCRIPTION_PATTERN)[0]
44
+ pr_description.gsub(DESCRIPTION_PATTERN, url_section(job_entries: job_entries, separator: non_empty))
42
45
  end
43
46
 
44
- # Allure report url comment without description separator
47
+ # Comment body with allure report urls
45
48
  #
49
+ # @param [String] pr_comment
46
50
  # @return [String]
47
51
  def comment_body(pr_comment = nil)
48
- return strip_separator(body) unless pr_comment
52
+ return url_section(separator: false) unless pr_comment
49
53
 
50
54
  job_entries = jobs_section(pr_comment)
51
- strip_separator(body(job_entries))
55
+ url_section(job_entries: job_entries, separator: false)
52
56
  end
53
57
 
54
58
  attr_reader :report_url,
@@ -59,22 +63,6 @@ module Publisher
59
63
 
60
64
  private
61
65
 
62
- # Allure report url pr description
63
- #
64
- # @return [String]
65
- def body(job_entries = job_entry)
66
- @body ||= <<~BODY.strip
67
- <!-- allure -->
68
- ---
69
- #{heading}
70
-
71
- <!-- jobs -->
72
- #{job_entries}
73
- <!-- jobs -->
74
- <!-- allurestop -->
75
- BODY
76
- end
77
-
78
66
  # Url section heading
79
67
  #
80
68
  # @return [String]
@@ -110,6 +98,24 @@ module Publisher
110
98
  @job_entry_pattern ||= /<!-- #{build_name} -->\n([\s\S]+)\n<!-- #{build_name} -->/
111
99
  end
112
100
 
101
+ # Allure report url section
102
+ #
103
+ # @return [String]
104
+ def url_section(job_entries: job_entry, separator: true)
105
+ reports = <<~BODY.strip
106
+ <!-- allure -->
107
+ ---
108
+ #{heading}
109
+
110
+ <!-- jobs -->
111
+ #{job_entries}
112
+ <!-- jobs -->
113
+ <!-- allurestop -->
114
+ BODY
115
+
116
+ separator ? reports : reports.gsub("---\n", "")
117
+ end
118
+
113
119
  # Return updated jobs section
114
120
  #
115
121
  # @param [String] urls
@@ -120,14 +126,6 @@ module Publisher
120
126
 
121
127
  "#{jobs}\n#{job_entry}"
122
128
  end
123
-
124
- # Strip separator from allure results section
125
- #
126
- # @param [String] body
127
- # @return [String]
128
- def strip_separator(body)
129
- body.gsub("---\n", "")
130
- end
131
129
  end
132
130
  end
133
131
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Publisher
4
- VERSION = "0.5.1"
4
+ VERSION = "0.5.4"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: allure-report-publisher
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrejs Cunskis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-15 00:00:00.000000000 Z
11
+ date: 2022-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3