allure-report-publisher 0.6.1 → 0.8.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: f96ef4e9997f8e97d580f212e0617f497ed7c864a2ef974792ef44966406a519
4
- data.tar.gz: 01c87b5f3652e346252a55738406ab77d1c24c333751949fa7c43f79a8a5e88c
3
+ metadata.gz: 9231271e7296dcc0921871769aff6442e2a6eb1bb919574b72cb8753be897b4c
4
+ data.tar.gz: ebf30bece57cd457150bc9002b731fce743914f5ab9a11c6457d8e50151b1d2b
5
5
  SHA512:
6
- metadata.gz: cc75d1e5f85618b19b41f19dad6991c11f4e84dff8185d670f3dc69561f668bfddc056d53229995df42c2759bb5454a3de09b3685b1739418f762cc78f9fb074
7
- data.tar.gz: 1ea619bdabf0e0a5a90731aa79abcf216479046ba663ac381615b82a663026ef2694c73312f8fcc7d855f5ca6bed0ecb6d75e010929555a32dc07d43a1da1742
6
+ metadata.gz: 1cd52b5982eb6a5023b7a000a426fefc207aaf9934c84c1364dc51f3f6079058381fd55672c98cc150622702f83300da25c7a369410488cc2b809a1938778d8d
7
+ data.tar.gz: d924adb83f5739a791b16d66bdbe580bb0c6712d7d502f14e115a55ebac621884e14a1a97ac46369be4c1de1eabaecc64288e5d0256bc735cef4594b7e41f35c
data/README.md CHANGED
@@ -47,8 +47,10 @@ Options:
47
47
  --results-glob=VALUE # Allure results files glob. Required: true
48
48
  --bucket=VALUE # Bucket name. Required: true
49
49
  --prefix=VALUE # Optional prefix for report path. Required: false
50
- --update-pr=VALUE # Add report url to PR via comment or description update. Required: false: (comment/description)
50
+ --update-pr=VALUE # Add report url to PR via comment or description update. Required: false: (comment/description/actions)
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
@@ -107,8 +109,10 @@ Following CI providers are supported:
107
109
 
108
110
  It is possible to update pull requests with urls to published reports and execution summary.
109
111
 
110
- - `--update-pr=(comment|description)`: post report urls in pr description or as a comment
111
- - `--summary=(behaviors/suites/packages/total)`: add execution summary table
112
+ - `--update-pr=(comment|description|actions)`: post report urls in pr description, as a comment or step summary for github actions
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
 
@@ -22,7 +22,7 @@ module Publisher
22
22
  option :update_pr,
23
23
  type: :string,
24
24
  desc: "Add report url to PR via comment or description update. Required: false",
25
- values: %w[comment description]
25
+ values: %w[comment description actions]
26
26
  option :summary,
27
27
  type: :string,
28
28
  desc: "Additionally add summary table to PR comment or description. Required: false",
@@ -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,
@@ -69,7 +77,7 @@ module Publisher
69
77
  return unless args[:update_pr] && uploader.pr?
70
78
 
71
79
  log("Adding reports urls")
72
- Spinner.spin("updating", exit_on_error: false) { uploader.add_url_to_pr }
80
+ Spinner.spin("updating", exit_on_error: false) { uploader.add_result_summary }
73
81
  end
74
82
 
75
83
  private
@@ -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,9 +91,9 @@ 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
- entry << "<!-- #{build_name} -->"
96
+ entry << "<!-- #{build_name} -->\n"
95
97
 
96
98
  entry.join("\n")
97
99
  end
@@ -101,7 +103,7 @@ module Publisher
101
103
  #
102
104
  # @return [RegExp]
103
105
  def job_entry_pattern
104
- @job_entry_pattern ||= /<!-- #{build_name} -->\n([\s\S]+)\n<!-- #{build_name} -->/
106
+ @job_entry_pattern ||= /<!-- #{build_name} -->\n([\s\S]+)\n<!-- #{build_name} -->\n/
105
107
  end
106
108
 
107
109
  # Allure report url section
@@ -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:
@@ -47,7 +53,7 @@ module Publisher
47
53
  # Add report url to pull request description
48
54
  #
49
55
  # @return [void]
50
- def add_report_url
56
+ def add_result_summary
51
57
  raise("Not a pull request, skipped!") unless pr?
52
58
  return add_comment if comment?
53
59
 
@@ -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
@@ -58,6 +58,8 @@ module Publisher
58
58
  #
59
59
  # @return [void]
60
60
  def update_pr_description
61
+ return File.write(step_summary_file, url_section_builder.comment_body) if actions?
62
+
61
63
  client.update_pull_request(repository, pr_id, body: url_section_builder.updated_pr_description(pr_description))
62
64
  end
63
65
 
@@ -137,6 +139,26 @@ module Publisher
137
139
 
138
140
  "[#{short_sha}](#{server_url}/#{repository}/pull/#{pr_id}/commits/#{sha})"
139
141
  end
142
+
143
+ # Use actions summary for results
144
+ #
145
+ # @return [Boolean]
146
+ def actions?
147
+ update_pr == "actions"
148
+ end
149
+
150
+ # Github actions summary file
151
+ #
152
+ # @return [String]
153
+ def step_summary_file
154
+ @step_summary_file ||= begin
155
+ summary_file = ENV["GITHUB_STEP_SUMMARY"]
156
+ raise("Environment variable GITHUB_STEP_SUMMARY is empty!") unless summary_file
157
+ raise("Step summary file '#{summary_file}' does not exist!") unless File.exist?(summary_file)
158
+
159
+ summary_file
160
+ end
161
+ end
140
162
  end
141
163
  end
142
164
  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
@@ -45,7 +47,7 @@ module Publisher
45
47
  def execute
46
48
  generate_report
47
49
  upload
48
- add_url_to_pr
50
+ add_result_summary
49
51
  end
50
52
 
51
53
  # Generate allure report
@@ -68,10 +70,10 @@ module Publisher
68
70
  # Add allure report url to pull request description
69
71
  #
70
72
  # @return [void]
71
- def add_url_to_pr
73
+ def add_result_summary
72
74
  return unless update_pr && ci_provider
73
75
 
74
- ci_provider.add_report_url
76
+ ci_provider.add_result_summary
75
77
  end
76
78
 
77
79
  # Uploaded report urls
@@ -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.1"
4
+ VERSION = "0.8.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.1
4
+ version: 0.8.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-26 00:00:00.000000000 Z
11
+ date: 2022-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 1.93.1
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: 1.114.0
22
+ version: 1.115.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: 1.93.1
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: 1.114.0
32
+ version: 1.115.0
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: dry-cli
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -50,6 +50,20 @@ dependencies:
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
52
  version: '0.8'
53
+ - !ruby/object:Gem::Dependency
54
+ name: faraday-retry
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - "~>"
58
+ - !ruby/object:Gem::Version
59
+ version: '1.0'
60
+ type: :runtime
61
+ prerelease: false
62
+ version_requirements: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: '1.0'
53
67
  - !ruby/object:Gem::Dependency
54
68
  name: gitlab
55
69
  requirement: !ruby/object:Gem::Requirement
@@ -182,28 +196,28 @@ dependencies:
182
196
  requirements:
183
197
  - - "~>"
184
198
  - !ruby/object:Gem::Version
185
- version: 2.17.0
199
+ version: 2.18.0
186
200
  type: :development
187
201
  prerelease: false
188
202
  version_requirements: !ruby/object:Gem::Requirement
189
203
  requirements:
190
204
  - - "~>"
191
205
  - !ruby/object:Gem::Version
192
- version: 2.17.0
206
+ version: 2.18.0
193
207
  - !ruby/object:Gem::Dependency
194
208
  name: climate_control
195
209
  requirement: !ruby/object:Gem::Requirement
196
210
  requirements:
197
211
  - - "~>"
198
212
  - !ruby/object:Gem::Version
199
- version: 1.0.1
213
+ version: 1.1.0
200
214
  type: :development
201
215
  prerelease: false
202
216
  version_requirements: !ruby/object:Gem::Requirement
203
217
  requirements:
204
218
  - - "~>"
205
219
  - !ruby/object:Gem::Version
206
- version: 1.0.1
220
+ version: 1.1.0
207
221
  - !ruby/object:Gem::Dependency
208
222
  name: pry-byebug
209
223
  requirement: !ruby/object:Gem::Requirement
@@ -336,14 +350,14 @@ dependencies:
336
350
  requirements:
337
351
  - - "~>"
338
352
  - !ruby/object:Gem::Version
339
- version: 0.44.3
353
+ version: 0.45.0
340
354
  type: :development
341
355
  prerelease: false
342
356
  version_requirements: !ruby/object:Gem::Requirement
343
357
  requirements:
344
358
  - - "~>"
345
359
  - !ruby/object:Gem::Version
346
- version: 0.44.3
360
+ version: 0.45.0
347
361
  description: Upload allure reports to different file storage providers
348
362
  email:
349
363
  - andrejs.cunskis@gmail.com