allure-report-publisher 0.6.2 → 0.7.0

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: e668a0aee13c1d2edab3fee43da526050512d0566f6635116a8ab3ac36478040
4
- data.tar.gz: 724e24dbdc7eb7a1c481c548347eed2c5e07de5f50b1e094d24a25daf37e31df
3
+ metadata.gz: 3d33ea0e4d124c07ae275376e075ab14d3bcfedc7b5d71fdd23b78882e436c09
4
+ data.tar.gz: 94d3d70c631aeb9b79aa71fbd18cc920f95cfbe29320c12166d81d1de913cc7a
5
5
  SHA512:
6
- metadata.gz: fbef301794bb94eaeb405fc8e671a474c4f71076fcebb10ad7ed913d758e08d650ee0589093e1f2c4b96efb733f342b2f4564c1c5e2b73227b00df81ca8773af
7
- data.tar.gz: ab5c493d8b61e7e04db967b397511610747091b5f7b3aa1554a7ef9eeb0bbd01554f6c527961e1dd834bfbfe1794100113b3feea97d6c9ea1905dff055a0b6c0
6
+ metadata.gz: e4ba711128088e03fdf2a0f77e9890d33b6eee5e5e1671b613203e2700fdbd715e690ddf4964bcc82762f144560e83333af7e46f22d82c6c96b408f931a33830
7
+ data.tar.gz: 2b263c7e7e48d244f30df4efec6358599f31f79f832888a6083b7d3c2dbdaa40458f0216e13142ac9004f20be3efc58c9d2b9f87f57a500da662791ef68151a9
data/README.md CHANGED
@@ -49,6 +49,8 @@ Options:
49
49
  --prefix=VALUE # Optional prefix for report path. Required: false
50
50
  --update-pr=VALUE # Add report url to PR via comment or description update. Required: false: (comment/description)
51
51
  --summary=VALUE # Additionally add summary table to PR comment or description. Required: false: (behaviors/suites/packages/total)
52
+ --summary-table-type=VALUE # Summary table type. Required: false: (ascii/markdown), default: :ascii
53
+ --[no-]collapse-summary # Create summary as a collapsable section, default: false
52
54
  --[no-]copy-latest # Keep copy of latest report at base prefix path, default: false
53
55
  --[no-]color # Force color output
54
56
  --[no-]ignore-missing-results # Ignore missing allure results, default: false
@@ -108,7 +110,9 @@ Following CI providers are supported:
108
110
  It is possible to update pull requests with urls to published reports and execution summary.
109
111
 
110
112
  - `--update-pr=(comment|description)`: post report urls in pr description or as a comment
111
- - `--summary=(behaviors/suites/packages/total)`: add execution summary table
113
+ - `--summary=(behaviors|suites|packages|total)`: add execution summary table
114
+ - `--summary-table-type=(ascii|markdown)`: use markdown or ascii table formatting
115
+ - `--[no-]collapse-summary`: add summary in collapsable section
112
116
 
113
117
  Example:
114
118
 
@@ -32,6 +32,14 @@ module Publisher
32
32
  Publisher::Helpers::Summary::PACKAGES,
33
33
  Publisher::Helpers::Summary::TOTAL
34
34
  ]
35
+ option :summary_table_type,
36
+ type: :string,
37
+ desc: "Summary table type. Required: false",
38
+ default: Publisher::Helpers::Summary::ASCII,
39
+ values: [
40
+ Publisher::Helpers::Summary::ASCII,
41
+ Publisher::Helpers::Summary::MARKDOWN
42
+ ]
35
43
  option :collapse_summary,
36
44
  type: :boolean,
37
45
  default: false,
@@ -88,7 +96,8 @@ module Publisher
88
96
  :prefix,
89
97
  :copy_latest,
90
98
  :update_pr,
91
- :collapse_summary
99
+ :collapse_summary,
100
+ :summary_table_type
92
101
  )
93
102
  )
94
103
  end
@@ -9,27 +9,37 @@ module Publisher
9
9
  PACKAGES = "packages".freeze
10
10
  SUITES = "suites".freeze
11
11
  TOTAL = "total".freeze
12
+ MARKDOWN = :markdown
13
+ ASCII = :ascii
12
14
 
13
15
  # Summary table generator
14
16
  #
15
17
  # @param [String] report_path
16
18
  # @param [String] summary_type
17
- def initialize(report_path, summary_type)
19
+ # @param [String] markdown
20
+ def initialize(report_path, summary_type, table_type = ASCII)
18
21
  @report_path = report_path
19
22
  @summary_type = summary_type || TOTAL
23
+ @table_type = table_type
20
24
  end
21
25
 
22
26
  # Summary table
23
27
  #
24
- # @return [Terminal::Table]
28
+ # @return [String]
25
29
  def table
26
- return terminal_table { |table| table << short_summary } if summary_type == TOTAL
27
-
28
- terminal_table do |table|
29
- expanded_summary.each { |row| table << row }
30
- table << :separator
31
- table << short_summary
32
- end
30
+ summary = if summary_type == TOTAL
31
+ terminal_table { |table| table << short_summary }
32
+ else
33
+ terminal_table do |table|
34
+ expanded_summary.each { |row| table << row }
35
+ table << :separator
36
+ table << short_summary
37
+ end
38
+ end
39
+
40
+ return summary.to_s if markdown?
41
+
42
+ "```markdown\n#{summary}\n```"
33
43
  end
34
44
 
35
45
  # Test run status emoji
@@ -41,28 +51,36 @@ module Publisher
41
51
 
42
52
  private
43
53
 
44
- attr_reader :report_path, :summary_type
54
+ attr_reader :report_path, :summary_type, :table_type
45
55
 
46
56
  # Expanded summary table
47
57
  #
48
58
  # @return [Array<Array>]
49
59
  def expanded_summary
50
60
  @expanded_summary ||= summary_data.map do |name, summary|
51
- [name, *summary.values, status_icon(summary[:passed], summary[:failed], summary[:flaky])]
61
+ [
62
+ name,
63
+ *summary.values,
64
+ summary[:passed] + summary[:failed] + summary[:skipped],
65
+ status_icon(summary[:passed], summary[:failed], summary[:flaky])
66
+ ]
52
67
  end
53
68
  end
54
69
 
55
70
  # Short summary table
56
71
  #
57
72
  # @return [Array<String>]
58
- def short_summary
73
+ def short_summary # rubocop:disable Metrics/MethodLength
59
74
  return @short_summary if defined?(@short_summary)
60
75
 
61
- sum = summary_data.values.each_with_object({ passed: 0, failed: 0, skipped: 0, flaky: 0 }) do |entry, hsh|
76
+ sum = summary_data.values.each_with_object({
77
+ passed: 0, failed: 0, skipped: 0, flaky: 0, total: 0
78
+ }) do |entry, hsh|
62
79
  hsh[:passed] += entry[:passed]
63
80
  hsh[:failed] += entry[:failed]
64
81
  hsh[:skipped] += entry[:skipped]
65
82
  hsh[:flaky] += entry[:flaky]
83
+ hsh[:total] += (entry[:passed] + entry[:failed] + entry[:skipped])
66
84
  end
67
85
 
68
86
  @short_summary = [
@@ -71,6 +89,7 @@ module Publisher
71
89
  sum[:failed],
72
90
  sum[:skipped],
73
91
  sum[:flaky],
92
+ sum[:total],
74
93
  status_icon(sum[:passed], sum[:failed], sum[:flaky])
75
94
  ]
76
95
  end
@@ -93,8 +112,9 @@ module Publisher
93
112
  # @return [Terminal::Table]
94
113
  def terminal_table
95
114
  Terminal::Table.new do |table|
96
- table.title = "#{summary_type} summary"
97
- table.headings = ["", "passed", "failed", "skipped", "flaky", "result"]
115
+ table.title = "#{summary_type} summary" unless markdown?
116
+ table.style = { border: table_type }
117
+ table.headings = ["", "passed", "failed", "skipped", "flaky", "total", "result"]
98
118
  yield(table)
99
119
  end
100
120
  end
@@ -133,6 +153,13 @@ module Publisher
133
153
 
134
154
  summary
135
155
  end
156
+
157
+ # Render markdown border tables
158
+ #
159
+ # @return [Boolean]
160
+ def markdown?
161
+ table_type == MARKDOWN
162
+ end
136
163
  end
137
164
  end
138
165
  end
@@ -20,6 +20,7 @@ module Publisher
20
20
  @build_name = args[:build_name]
21
21
  @sha_url = args[:sha_url]
22
22
  @summary_type = args[:summary_type]
23
+ @summary_table_type = args[:summary_table_type]
23
24
  @collapse_summary = args[:collapse_summary]
24
25
  end
25
26
 
@@ -62,6 +63,7 @@ module Publisher
62
63
  :build_name,
63
64
  :sha_url,
64
65
  :summary_type,
66
+ :summary_table_type,
65
67
  :collapse_summary
66
68
 
67
69
  private
@@ -77,7 +79,7 @@ module Publisher
77
79
  #
78
80
  # @return [Helpers::Summary]
79
81
  def summary
80
- @summary ||= Helpers::Summary.new(report_path, summary_type)
82
+ @summary ||= Helpers::Summary.new(report_path, summary_type, summary_table_type)
81
83
  end
82
84
 
83
85
  # Single job report URL entry
@@ -89,7 +91,7 @@ module Publisher
89
91
  entry << "**#{build_name}**: #{summary.status} [test report](#{report_url}) for #{sha_url}"
90
92
  entry << "<details>" if collapse_summary
91
93
  entry << "<summary>expand test summary</summary>\n" if collapse_summary
92
- entry << "```markdown\n#{summary.table}\n```" if summary_type
94
+ entry << summary.table if summary_type
93
95
  entry << "</details>" if collapse_summary
94
96
  entry << "<!-- #{build_name} -->\n"
95
97
 
@@ -17,14 +17,20 @@ module Publisher
17
17
 
18
18
  # CI provider base
19
19
  #
20
- # @param [String] report_url
21
- # @param [Boolean] update_pr
22
- def initialize(report_url:, report_path:, update_pr:, summary_type:, collapse_summary:)
23
- @report_url = report_url
24
- @report_path = report_path
25
- @update_pr = update_pr
26
- @summary_type = summary_type
27
- @collapse_summary = collapse_summary
20
+ # @param [Hash] args
21
+ # @option args [String] :report_url
22
+ # @option args [String] :report_path
23
+ # @option args [Boolean] :update_pr
24
+ # @option args [String] :summary_type
25
+ # @option args [Boolean] :collapse_summay
26
+ # @option args [Symbol] :summary_table_type
27
+ def initialize(**args)
28
+ @report_url = args[:report_url]
29
+ @report_path = args[:report_path]
30
+ @update_pr = args[:update_pr]
31
+ @summary_type = args[:summary_type]
32
+ @summary_table_type = args[:summary_table_type]
33
+ @collapse_summary = args[:collapse_summary]
28
34
  end
29
35
 
30
36
  # :nocov:
@@ -69,7 +75,8 @@ module Publisher
69
75
  :report_path,
70
76
  :update_pr,
71
77
  :summary_type,
72
- :collapse_summary
78
+ :collapse_summary,
79
+ :summary_table_type
73
80
 
74
81
  # Current pull request description
75
82
  #
@@ -131,6 +138,7 @@ module Publisher
131
138
  build_name: build_name,
132
139
  sha_url: sha_url,
133
140
  summary_type: summary_type,
141
+ summary_table_type: summary_table_type,
134
142
  collapse_summary: collapse_summary
135
143
  )
136
144
  end
@@ -27,6 +27,7 @@ module Publisher
27
27
  # @option args [String] :prefix
28
28
  # @option args [Boolean] :update_pr
29
29
  # @option args [String] :summary_type
30
+ # @option args [Symbol] :summary_table_type
30
31
  # @option args [Boolean] :collapse_summary
31
32
  # @option args [String] :copy_latest
32
33
  def initialize(**args)
@@ -35,6 +36,7 @@ module Publisher
35
36
  @prefix = args[:prefix]
36
37
  @update_pr = args[:update_pr]
37
38
  @summary_type = args[:summary_type]
39
+ @summary_table_type = args[:summary_table_type]
38
40
  @copy_latest = (Providers.provider && args[:copy_latest]) # copy latest for ci only
39
41
  @collapse_summary = args[:collapse_summary]
40
42
  end
@@ -99,7 +101,8 @@ module Publisher
99
101
  :update_pr,
100
102
  :copy_latest,
101
103
  :summary_type,
102
- :collapse_summary
104
+ :collapse_summary,
105
+ :summary_table_type
103
106
 
104
107
  def_delegators :report_generator, :results_path, :report_path
105
108
 
@@ -200,6 +203,7 @@ module Publisher
200
203
  report_path: report_path,
201
204
  update_pr: update_pr,
202
205
  summary_type: summary_type,
206
+ summary_table_type: summary_table_type,
203
207
  collapse_summary: collapse_summary
204
208
  )
205
209
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Publisher
4
- VERSION = "0.6.2"
4
+ VERSION = "0.7.0"
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.6.2
4
+ version: 0.7.0
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-27 00:00:00.000000000 Z
11
+ date: 2022-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3