allure-ruby-commons 2.27.0 → 2.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bfc6a336acd109d4c450d5ca1130a0063a90fdbb40899eae417b971787727e4a
4
- data.tar.gz: 0db6791b629a3a6a6dc2ecac0f794a213faff0ec908cb19815f12aba0a2db3ae
3
+ metadata.gz: c492299cc403fb00313d8cb071712676292a6ca937c4e63dd69898345878d7c3
4
+ data.tar.gz: 7a883ae369f1aad7ece45aa735b911b12c4e0fd3c6a7c4beff289b1e25ad0da2
5
5
  SHA512:
6
- metadata.gz: 457f0e99b1d265c4e8a57fd9d29449a336a9bac407871847ecd198fc28cca49b74b6575b4c37c90a4c3dda7570ea727a3ac47dd62593532b7300c23ff7a0405d
7
- data.tar.gz: 60c6d25d2e1bc3db6a820f3443791c9edd6ff5baecf4be205240c1a72b39d7fe0f3884ab9d44991481609ed0c475c85112c65957931f830cb1e8fe7b9a0d3c0d
6
+ metadata.gz: 61912849ff65168de97d84edb8d00a024164e5b9e9caa33c366144ba93854d19ab89203a123711d10f0524b3ff0a4004e10bbc7f7f615f74393306c9bf40c8da
7
+ data.tar.gz: f44bbb71e3bb02a18e20729e7df33c64340df4e2bbe7c46430dd852003d51794a7ba6f37d376685e3275eb8125af5256e32b728270aa894ac9fe4aaed61df45a
@@ -2,6 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "require_all"
5
+ require "digest"
5
6
  require "securerandom"
6
7
 
7
8
  require_rel "allure_ruby_commons/**/*rb"
@@ -161,6 +162,27 @@ module Allure
161
162
  lifecycle.add_attachment(name: name, source: source, type: type, test_case: test_case)
162
163
  end
163
164
 
165
+ # Add run-level attachment not bound to a test or fixture
166
+ # @param [String] name Attachment name
167
+ # @param [File, String] source File or string to save as attachment
168
+ # @param [String] type attachment type defined in {ContentType} or any other valid mime type
169
+ # @return [void]
170
+ def add_global_attachment(name:, source:, type:)
171
+ lifecycle.add_global_attachment(name: name, source: source, type: type)
172
+ end
173
+
174
+ # Add run-level error not bound to a test or fixture
175
+ # @param [Hash] details
176
+ # @option details [Boolean] :known
177
+ # @option details [Boolean] :muted
178
+ # @option details [Boolean] :flaky
179
+ # @option details [String] :message
180
+ # @option details [String] :trace
181
+ # @return [void]
182
+ def add_global_error(**details)
183
+ lifecycle.add_global_error(**details)
184
+ end
185
+
164
186
  # Manually create environment.properties file
165
187
  # if this method is called before test run started and
166
188
  # option clean_results_directory is enabled, the file will be deleted
@@ -20,7 +20,7 @@ module Allure
20
20
 
21
21
  attr_reader :config
22
22
 
23
- def_delegators :file_writer, :write_attachment
23
+ def_delegators :file_writer, :write_attachment, :write_globals
24
24
 
25
25
  # Start test result container
26
26
  # @param [Allure::TestResultContainer] test_result_container
@@ -220,6 +220,35 @@ module Allure
220
220
  write_attachment(source, attachment)
221
221
  end
222
222
 
223
+ # Add run-level attachment
224
+ # @param [String] name Attachment name
225
+ # @param [File, String] source File or string to save as attachment
226
+ # @param [String] type attachment type defined in {Allure::ContentType} or any other valid mime type
227
+ # @return [void]
228
+ def add_global_attachment(name:, source:, type:)
229
+ attachment = ResultUtils.prepare_global_attachment(name, type, timestamp: ResultUtils.timestamp)
230
+ return logger.error { "Can't add global attachment, unrecognized mime type: #{type}" } unless attachment
231
+
232
+ logger.debug { "Adding global attachment '#{name}'" }
233
+ write_attachment(source, attachment)
234
+ write_globals(Globals.new(attachments: [attachment]))
235
+ end
236
+
237
+ # Add run-level error
238
+ # @param [Hash] details
239
+ # @option details [Boolean] :known
240
+ # @option details [Boolean] :muted
241
+ # @option details [Boolean] :flaky
242
+ # @option details [String] :message
243
+ # @option details [String] :trace
244
+ # @return [void]
245
+ def add_global_error(**details)
246
+ error = ResultUtils.prepare_global_error(timestamp: ResultUtils.timestamp, **details)
247
+
248
+ logger.debug { "Adding global error '#{error.message}'" }
249
+ write_globals(Globals.new(errors: [error]))
250
+ end
251
+
223
252
  # Add environment.properties file
224
253
  #
225
254
  # @param [Hash, Proc] env
@@ -31,7 +31,7 @@ module Allure
31
31
  #
32
32
  # @return [String]
33
33
  def environment
34
- return(@environment) if defined?(@environment)
34
+ return @environment if defined?(@environment)
35
35
 
36
36
  @environment ||= ENV["ALLURE_ENVIRONMENT"]
37
37
  end
@@ -11,6 +11,8 @@ module Allure
11
11
  TEST_RESULT_CONTAINER_SUFFIX = "-container.json"
12
12
  # @return [String] attachment file suffix
13
13
  ATTACHMENT_FILE_SUFFIX = "-attachment"
14
+ # @return [String] globals chunk suffix
15
+ GLOBALS_SUFFIX = "-globals.json"
14
16
  # @return [String] environment info file
15
17
  ENVIRONMENT_FILE = "environment.properties"
16
18
  # @return [String] categories definition json
@@ -45,6 +47,13 @@ module Allure
45
47
  source.is_a?(File) ? copy(source.path, attachment.source) : write(attachment.source, source)
46
48
  end
47
49
 
50
+ # Write allure globals chunk
51
+ # @param [Allure::Globals] globals
52
+ # @return [void]
53
+ def write_globals(globals)
54
+ write("#{SecureRandom.uuid}#{GLOBALS_SUFFIX}", dump_json(globals))
55
+ end
56
+
48
57
  # Write allure report environment info
49
58
  # @param [Hash<Symbol, String>] environment
50
59
  # @return [void]
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Allure
4
+ # Allure model global attachment object
5
+ class GlobalAttachment < Attachment
6
+ # @param [Number] timestamp
7
+ # @param [Hash] options
8
+ # @option options [String] :name attachment name
9
+ # @option options [String] :type attachment type, {Allure::ContentType}
10
+ # @option options [String] :source attachment file name
11
+ def initialize(timestamp:, **options)
12
+ super(**options)
13
+
14
+ @timestamp = timestamp
15
+ end
16
+
17
+ attr_accessor :timestamp
18
+ end
19
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "status_details"
4
+
5
+ module Allure
6
+ # Allure model global error object
7
+ class GlobalError < StatusDetails
8
+ # @param [Number] timestamp
9
+ # @param [Hash] options
10
+ # @option options [Boolean] :known
11
+ # @option options [Boolean] :muted
12
+ # @option options [Boolean] :flaky
13
+ # @option options [String] :message
14
+ # @option options [String] :trace
15
+ def initialize(timestamp:, **options)
16
+ super(**options)
17
+
18
+ @timestamp = timestamp
19
+ end
20
+
21
+ attr_accessor :timestamp
22
+ end
23
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Allure
4
+ # Allure model run-level globals chunk
5
+ class Globals < JSONable
6
+ # @param [Array<Allure::GlobalAttachment>] attachments
7
+ # @param [Array<Allure::GlobalError>] errors
8
+ def initialize(attachments: [], errors: [])
9
+ super()
10
+
11
+ @attachments = attachments
12
+ @errors = errors
13
+ end
14
+
15
+ attr_accessor :attachments, :errors
16
+ end
17
+ end
@@ -9,6 +9,7 @@ module Allure
9
9
  # @param [Hash] options
10
10
  # @option options [String] :name
11
11
  # @option options [String] :full_name
12
+ # @option options [Array<String>] :title_path
12
13
  # @option options [String] :description
13
14
  # @option options [String] :description_html
14
15
  # @option options [String] :status ('broken')
@@ -26,6 +27,7 @@ module Allure
26
27
  @uuid = uuid
27
28
  @history_id = history_id
28
29
  @full_name = options[:full_name] || "Unnamed"
30
+ @title_path = options[:title_path]
29
31
  @labels = options[:labels] || []
30
32
  @links = options[:links] || []
31
33
  @parameters << Parameter.new("environment", environment) if environment
@@ -33,6 +35,7 @@ module Allure
33
35
 
34
36
  attr_accessor :uuid,
35
37
  :full_name,
38
+ :title_path,
36
39
  :labels,
37
40
  :links
38
41
 
@@ -172,6 +172,35 @@ module Allure
172
172
  Attachment.new(name: name, source: file_name, type: type)
173
173
  end
174
174
 
175
+ # Allure global attachment object
176
+ # @param [String] name
177
+ # @param [String] type
178
+ # @param [Number] timestamp
179
+ # @return [Allure::GlobalAttachment]
180
+ def prepare_global_attachment(name, type, timestamp: self.timestamp)
181
+ attachment = prepare_attachment(name, type) || return
182
+
183
+ GlobalAttachment.new(
184
+ name: attachment.name,
185
+ source: attachment.source,
186
+ type: attachment.type,
187
+ timestamp: timestamp
188
+ )
189
+ end
190
+
191
+ # Allure global error object
192
+ # @param [Number] timestamp
193
+ # @param [Hash] options
194
+ # @option options [Boolean] :known
195
+ # @option options [Boolean] :muted
196
+ # @option options [Boolean] :flaky
197
+ # @option options [String] :message
198
+ # @option options [String] :trace
199
+ # @return [Allure::GlobalError]
200
+ def prepare_global_error(timestamp: self.timestamp, **options)
201
+ GlobalError.new(timestamp: timestamp, **options)
202
+ end
203
+
175
204
  private
176
205
 
177
206
  # Check if value is full url
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: allure-ruby-commons
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.27.0
4
+ version: 2.29.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrejs Cunskis
@@ -55,14 +55,14 @@ dependencies:
55
55
  requirements:
56
56
  - - "~>"
57
57
  - !ruby/object:Gem::Version
58
- version: '3.12'
58
+ version: '3.13'
59
59
  type: :runtime
60
60
  prerelease: false
61
61
  version_requirements: !ruby/object:Gem::Requirement
62
62
  requirements:
63
63
  - - "~>"
64
64
  - !ruby/object:Gem::Version
65
- version: '3.12'
65
+ version: '3.13'
66
66
  description: Utilities allowing to implement allure result generation by other test
67
67
  frameworks
68
68
  email: andrejs.cunskis@gmail.com
@@ -82,6 +82,9 @@ files:
82
82
  - lib/allure_ruby_commons/model/content_type.rb
83
83
  - lib/allure_ruby_commons/model/executable_item.rb
84
84
  - lib/allure_ruby_commons/model/fixture_result.rb
85
+ - lib/allure_ruby_commons/model/global_attachment.rb
86
+ - lib/allure_ruby_commons/model/global_error.rb
87
+ - lib/allure_ruby_commons/model/globals.rb
85
88
  - lib/allure_ruby_commons/model/label.rb
86
89
  - lib/allure_ruby_commons/model/link.rb
87
90
  - lib/allure_ruby_commons/model/parameter.rb
@@ -118,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
121
  - !ruby/object:Gem::Version
119
122
  version: '0'
120
123
  requirements: []
121
- rubygems_version: 3.6.7
124
+ rubygems_version: 3.6.9
122
125
  specification_version: 4
123
126
  summary: Common library for allure results generation
124
127
  test_files: []