allure-report-publisher 0.6.2 → 0.9.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: b0a64abc1ab6e6b41c84bd3fe5e82717dbd9555ae07ee4b4c0005576350e2ac7
4
+ data.tar.gz: a2a3c74d43c3373c1de06605b12284acd02681dea799287626559f25e5615e04
5
5
  SHA512:
6
- metadata.gz: fbef301794bb94eaeb405fc8e671a474c4f71076fcebb10ad7ed913d758e08d650ee0589093e1f2c4b96efb733f342b2f4564c1c5e2b73227b00df81ca8773af
7
- data.tar.gz: ab5c493d8b61e7e04db967b397511610747091b5f7b3aa1554a7ef9eeb0bbd01554f6c527961e1dd834bfbfe1794100113b3feea97d6c9ea1905dff055a0b6c0
6
+ metadata.gz: e7023c3956e20966b559ecb3fae381ebec6db11c593c0d66c015cf6e325cf71e541ab06d6d3fccc9331efce8186108fd49215c09bd445858f73ea250f4e29df9
7
+ data.tar.gz: 8812c955cf5c886f02b8825914ff27dc2c4638f44ad663d821f4ee6dbee8599ca4acd4258968845662d101f88c496339332943fa205d984325b3ec8e96fba0f7
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
 
@@ -144,6 +148,10 @@ Following environment variables can override default CI values:
144
148
 
145
149
  - `ALLURE_JOB_NAME`: overrides default `GITHUB_JOB` value which is used as name for report url section
146
150
 
151
+ ### allure-publish-action
152
+
153
+ [allure-publish-action](https://github.com/marketplace/actions/allure-publish-action) can be used to easily run report publishing from any github actions job.
154
+
147
155
  ## Gitlab CI
148
156
 
149
157
  Additional configuration is done via environment variables
@@ -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,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:
@@ -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.2"
4
+ VERSION = "0.9.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.9.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-07-16 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,26 @@ 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'
60
+ - - "<"
61
+ - !ruby/object:Gem::Version
62
+ version: '3'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '1'
70
+ - - "<"
71
+ - !ruby/object:Gem::Version
72
+ version: '3'
53
73
  - !ruby/object:Gem::Dependency
54
74
  name: gitlab
55
75
  requirement: !ruby/object:Gem::Requirement
@@ -96,16 +116,22 @@ dependencies:
96
116
  name: octokit
97
117
  requirement: !ruby/object:Gem::Requirement
98
118
  requirements:
99
- - - "~>"
119
+ - - ">="
100
120
  - !ruby/object:Gem::Version
101
121
  version: '4.21'
122
+ - - "<"
123
+ - !ruby/object:Gem::Version
124
+ version: '6.0'
102
125
  type: :runtime
103
126
  prerelease: false
104
127
  version_requirements: !ruby/object:Gem::Requirement
105
128
  requirements:
106
- - - "~>"
129
+ - - ">="
107
130
  - !ruby/object:Gem::Version
108
131
  version: '4.21'
132
+ - - "<"
133
+ - !ruby/object:Gem::Version
134
+ version: '6.0'
109
135
  - !ruby/object:Gem::Dependency
110
136
  name: parallel
111
137
  requirement: !ruby/object:Gem::Requirement
@@ -182,28 +208,28 @@ dependencies:
182
208
  requirements:
183
209
  - - "~>"
184
210
  - !ruby/object:Gem::Version
185
- version: 2.17.0
211
+ version: 2.18.0
186
212
  type: :development
187
213
  prerelease: false
188
214
  version_requirements: !ruby/object:Gem::Requirement
189
215
  requirements:
190
216
  - - "~>"
191
217
  - !ruby/object:Gem::Version
192
- version: 2.17.0
218
+ version: 2.18.0
193
219
  - !ruby/object:Gem::Dependency
194
220
  name: climate_control
195
221
  requirement: !ruby/object:Gem::Requirement
196
222
  requirements:
197
223
  - - "~>"
198
224
  - !ruby/object:Gem::Version
199
- version: 1.0.1
225
+ version: 1.1.0
200
226
  type: :development
201
227
  prerelease: false
202
228
  version_requirements: !ruby/object:Gem::Requirement
203
229
  requirements:
204
230
  - - "~>"
205
231
  - !ruby/object:Gem::Version
206
- version: 1.0.1
232
+ version: 1.1.0
207
233
  - !ruby/object:Gem::Dependency
208
234
  name: pry-byebug
209
235
  requirement: !ruby/object:Gem::Requirement
@@ -336,14 +362,14 @@ dependencies:
336
362
  requirements:
337
363
  - - "~>"
338
364
  - !ruby/object:Gem::Version
339
- version: 0.44.3
365
+ version: 0.45.0
340
366
  type: :development
341
367
  prerelease: false
342
368
  version_requirements: !ruby/object:Gem::Requirement
343
369
  requirements:
344
370
  - - "~>"
345
371
  - !ruby/object:Gem::Version
346
- version: 0.44.3
372
+ version: 0.45.0
347
373
  description: Upload allure reports to different file storage providers
348
374
  email:
349
375
  - andrejs.cunskis@gmail.com