parallel_report_portal 2.3.0 → 2.5.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: 35cc50dee2f24a1533a8ef831c0cd1977fc36c6fd9c6cdb5ccdd4a73c8022cc2
4
- data.tar.gz: fa3c3fbe565ac7e1aa5b728a6fe73f401d84c4b327eebe83a4f1af6697d6fda0
3
+ metadata.gz: dca25702756ef6361e293e078cbca0e4a7b3e58e01a172729f49a319fa43fd15
4
+ data.tar.gz: 81397b39a9131c2ef601e782da487c7ec5be55cb6a90e8ba98d00de5c95248b5
5
5
  SHA512:
6
- metadata.gz: 8b26b53f1e989cf4e2179e6361be41b783ca692d739aa7bdabaab50b9599c4e5378fa05b1fb9920bde748bdff56ef99a0afb4f4431b23329ac69b83db81ea057
7
- data.tar.gz: c0cc62184f810e2bd53119e7115e29be3c014d707f8bce610c825a466d356337a0c694d4dae6e14b87f137f136136ae1056aceec0f6a7e590b35a59dedc79961
6
+ metadata.gz: 8b1fd11d745dbba815364eadb751c9d8c15ff23fa36fd3c40490d1e2d718c125cc7d83cd7d4f8ca1540114ee86898b2fafc1405809506a92857840adc260d801
7
+ data.tar.gz: ef8ba69e9d7cf3f61f78e56b3df1e8e256541192f22c1656267268c5c97a0878bb76ddc5f0411184f12a14d89bdc4396a99aaca2b267e92620204393fb38668d
data/.gitignore CHANGED
@@ -7,6 +7,8 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ /out/
11
+ /vendor/
10
12
 
11
13
  # Appraisal lock files
12
14
  /gemfiles/*.lock
@@ -15,5 +17,6 @@ Gemfile.lock
15
17
  # rspec failure tracking
16
18
  .rspec_status
17
19
  .DS_Store
20
+ .ruby-version
18
21
 
19
22
  *.gem
@@ -0,0 +1,13 @@
1
+ module ParallelReportPortal
2
+ # Handle post launch hooks
3
+ module AfterLaunch
4
+
5
+ attr_accessor :launch_finished_block
6
+ attr_accessor :report_url
7
+
8
+ def after_launch(&block)
9
+ @launch_finished_block = block
10
+ end
11
+
12
+ end
13
+ end
@@ -1,23 +1,23 @@
1
1
  module ParallelReportPortal
2
2
  # The Configuration class holds the connection properties to communicate with
3
3
  # Report Portal and to identify the user and project for reporting.
4
- #
4
+ #
5
5
  # It attempts to load a configuration file called +report_portal.yml+ first in a
6
6
  # local directory called +config+ and if that's not found in the current directory.
7
7
  # (Report Portal actually tells you to create a files called +REPORT_PORTAL.YML+ in
8
- # uppercase -- for this reason the initializer is case insensitive with regards to
8
+ # uppercase -- for this reason the initializer is case insensitive with regards to
9
9
  # the file name)
10
- #
10
+ #
11
11
  # It will then try an apply the following environment variables, if present (these
12
12
  # can be specified in either lowercase for backwards compatibility with the official
13
13
  # gem or in uppercase for reasons of sanity)
14
- #
14
+ #
15
15
  # == Environment variables
16
- #
16
+ #
17
17
  # RP_UUID:: The UUID of the user associated with this launch
18
18
  # RP_ENDPOINT:: the URL of the Report Portal API endpoint
19
19
  # RP_PROJECT:: the Report Portal project name -- this must already exist within Report Port and this user must be a member of the project
20
- # RP_LAUNCH:: The name of this launch
20
+ # RP_LAUNCH:: The name of this launch
21
21
  # RP_DESCRIPTION:: A textual string describing this launch
22
22
  # RP_TAGS:: A set of tags to pass to Report Portal for this launch. If these are set via an environment variable, provide a comma-separated string of tags
23
23
  # RP_ATTRIBUTES:: A set of attribute tags to pass to Report Portal for this launch. If these are set via an environment variable, provide a comma-separated string of attributes
@@ -52,7 +52,6 @@ module ParallelReportPortal
52
52
  # @return [Integer] the number of seconds for the read connection to timeout
53
53
  attr_accessor :read_timeout
54
54
 
55
-
56
55
  # Create an instance of Configuration.
57
56
  #
58
57
  # The initializer will first attempt to load a configuration files called
@@ -101,6 +100,7 @@ module ParallelReportPortal
101
100
  end
102
101
  end
103
102
 
103
+
104
104
  # Simple method to obtain an attribute from this class or set default value
105
105
  # param [symbol] a symbol version of the attribute
106
106
  def fetch(key, default_value)
@@ -1,42 +1,51 @@
1
1
  require 'faraday'
2
+ require 'faraday/net_http_persistent'
3
+ require 'faraday/multipart'
2
4
  require 'tree'
3
5
 
4
6
  module ParallelReportPortal
5
7
  module Cucumber
6
8
  # Report object. This handles the management of the state hierarchy and
7
- # the issuing of the requests to the HTTP module.
9
+ # the issuing of the requests to the HTTP module.
8
10
  class Report
9
-
11
+
10
12
  attr_reader :launch_id
11
-
13
+
12
14
  Feature = Struct.new(:feature, :id)
13
-
14
- LOG_LEVELS = {
15
- error: 'ERROR',
16
- warn: 'WARN',
17
- info: 'INFO',
18
- debug: 'DEBUG',
19
- trace: 'TRACE',
20
- fatal: 'FATAL',
21
- unknown: 'UNKNOWN'
15
+
16
+ LOG_LEVELS = {
17
+ error: 'ERROR',
18
+ warn: 'WARN',
19
+ info: 'INFO',
20
+ debug: 'DEBUG',
21
+ trace: 'TRACE',
22
+ fatal: 'FATAL',
23
+ unknown: 'UNKNOWN'
22
24
  }
23
25
 
24
-
26
+
25
27
  # Create a new instance of the report
26
28
  def initialize(ast_lookup = nil)
27
29
  @feature = nil
28
- @tree = Tree::TreeNode.new( 'root' )
30
+ @tree = Tree::TreeNode.new( 'root' )
29
31
  @ast_lookup = ast_lookup
32
+ check_faraday_compatibility
33
+ end
34
+
35
+ def check_faraday_compatibility
36
+ if Gem::Version.create(Faraday::VERSION) < Gem::Version.create('2.0')
37
+ Kernel.warn("Minimum of Faraday v2 is expected for compatibility with parallel_report_portal", category: :deprecated)
38
+ end
30
39
  end
31
-
40
+
32
41
  # Issued to start a launch. It is possilbe that this method could be called
33
42
  # from multiple processes for the same launch if this is being run with
34
43
  # parallel tests enabled. A temporary launch file will be created (using
35
44
  # exclusive locking). The first time this method is called it will write the
36
45
  # launch id to the launch file, subsequent calls by other processes will read
37
46
  # this launch id and use that.
38
- #
39
- # @param start_time [Integer] the millis from the epoch
47
+ #
48
+ # @param start_time [Integer] the millis from the epoch
40
49
  # @return [String] the UUID of this launch
41
50
  def launch_started(start_time)
42
51
  ParallelReportPortal.file_open_exlock_and_block(ParallelReportPortal.launch_id_file, 'a+' ) do |file|
@@ -50,39 +59,42 @@ module ParallelReportPortal
50
59
  @launch_id
51
60
  end
52
61
  end
53
-
62
+
54
63
  # Called to finish a launch. Any open children items will be closed in the process.
55
- #
64
+ #
56
65
  # @param clock [Integer] the millis from the epoch
57
66
  def launch_finished(clock)
58
67
  @tree.postordered_each do |node|
59
- ParallelReportPortal.req_feature_finished(node.content, clock) unless node.is_root?
68
+ response = ParallelReportPortal.req_feature_finished(node.content, clock) unless node.is_root?
69
+ parse_report_link_from_response(response)
60
70
  end
61
- ParallelReportPortal.req_launch_finished(launch_id, clock)
71
+ response = ParallelReportPortal.req_launch_finished(launch_id, clock)
72
+ parse_report_link_from_response(response)
73
+ ParallelReportPortal.launch_finished_block.call if ParallelReportPortal.launch_finished_block
62
74
  end
63
-
75
+
64
76
  # Called to indicate that a feature has started.
65
- #
66
- # @param
77
+ #
78
+ # @param
67
79
  def feature_started(feature, clock)
68
80
  parent_id = hierarchy(feature, clock)
69
81
  feature = feature.feature if using_cucumber_messages?
70
82
  ParallelReportPortal.req_feature_started(launch_id, parent_id, feature, clock)
71
83
  end
72
-
84
+
73
85
  def feature_finished(clock)
74
86
  if @feature
75
87
  resp = ParallelReportPortal.req_feature_finished(@feature.id, clock)
76
88
  end
77
89
  end
78
-
90
+
79
91
  def test_case_started(event, clock)
80
92
  test_case = lookup_test_case(event.test_case)
81
93
  feature = lookup_feature(event.test_case)
82
94
  feature = current_feature(feature, clock)
83
95
  @test_case_id = ParallelReportPortal.req_test_case_started(launch_id, feature.id, test_case, clock)
84
96
  end
85
-
97
+
86
98
  def test_case_finished(event, clock)
87
99
  result = event.result
88
100
  status = result.to_sym
@@ -93,7 +105,7 @@ module ParallelReportPortal
93
105
  end
94
106
  resp = ParallelReportPortal.req_test_case_finished(@test_case_id, status, clock)
95
107
  end
96
-
108
+
97
109
  def test_step_started(event, clock)
98
110
  test_step = event.test_step
99
111
  if !hook?(test_step)
@@ -104,11 +116,11 @@ module ParallelReportPortal
104
116
  elsif (using_cucumber_messages? ? test_step : step_source).multiline_arg.data_table?
105
117
  detail << (using_cucumber_messages? ? test_step : step_source).multiline_arg.raw.reduce("\n") {|acc, row| acc << "| #{row.join(' | ')} |\n"}
106
118
  end
107
-
119
+
108
120
  ParallelReportPortal.req_log(@test_case_id, detail, status_to_level(:trace), clock)
109
121
  end
110
122
  end
111
-
123
+
112
124
  def test_step_finished(event, clock)
113
125
  test_step = event.test_step
114
126
  result = event.result
@@ -129,13 +141,13 @@ module ParallelReportPortal
129
141
  ParallelReportPortal.req_log(@test_case_id, detail, status_to_level(status), clock) if detail
130
142
 
131
143
  end
132
-
144
+
133
145
  private
134
146
 
135
147
  def using_cucumber_messages?
136
148
  @ast_lookup != nil
137
149
  end
138
-
150
+
139
151
  def hierarchy(feature, clock)
140
152
  node = nil
141
153
  path_components = if using_cucumber_messages?
@@ -144,7 +156,7 @@ module ParallelReportPortal
144
156
  feature.location.file.split(File::SEPARATOR)
145
157
  end
146
158
  ParallelReportPortal.file_open_exlock_and_block(ParallelReportPortal.hierarchy_file, 'a+b' ) do |file|
147
- @tree = Marshal.load(File.read(file)) if file.size > 0
159
+ @tree = Marshal.load(File.read(file)) if file.size > 0
148
160
  node = @tree.root
149
161
  path_components[0..-2].each do |component|
150
162
  next_node = node[component]
@@ -161,7 +173,7 @@ module ParallelReportPortal
161
173
  file.write(Marshal.dump(@tree))
162
174
  file.flush
163
175
  end
164
-
176
+
165
177
  node.content
166
178
  end
167
179
 
@@ -193,7 +205,7 @@ module ParallelReportPortal
193
205
  step.source.last
194
206
  end
195
207
  end
196
-
208
+
197
209
  def current_feature(feature, clock)
198
210
  if @feature&.feature == feature
199
211
  @feature
@@ -202,7 +214,7 @@ module ParallelReportPortal
202
214
  @feature = Feature.new(feature, feature_started(feature, clock))
203
215
  end
204
216
  end
205
-
217
+
206
218
  def hook?(test_step)
207
219
  if using_cucumber_messages?
208
220
  test_step.hook?
@@ -210,7 +222,7 @@ module ParallelReportPortal
210
222
  ! test_step.source.last.respond_to?(:keyword)
211
223
  end
212
224
  end
213
-
225
+
214
226
  def status_to_level(status)
215
227
  case status
216
228
  when :passed
@@ -223,8 +235,13 @@ module ParallelReportPortal
223
235
  LOG_LEVELS.fetch(status, LOG_LEVELS[:info])
224
236
  end
225
237
  end
226
-
227
-
238
+
239
+ def parse_report_link_from_response(response)
240
+ if response
241
+ json = JSON.parse(response.body)
242
+ ParallelReportPortal.report_url = json['link'] if json['link']
243
+ end
244
+ end
228
245
  end
229
246
  end
230
247
  end
@@ -1,3 +1,3 @@
1
1
  module ParallelReportPortal
2
- VERSION = "2.3.0"
2
+ VERSION = "2.5.0"
3
3
  end
@@ -1,3 +1,4 @@
1
+ require 'parallel_report_portal/after_launch'
1
2
  require "parallel_report_portal/clock"
2
3
  require "parallel_report_portal/configuration"
3
4
  require "parallel_report_portal/file_utils"
@@ -8,19 +9,20 @@ require 'parallel_tests'
8
9
  module ParallelReportPortal
9
10
  class Error < StandardError; end
10
11
 
12
+ extend ParallelReportPortal::AfterLaunch
11
13
  extend ParallelReportPortal::HTTP
12
14
  extend ParallelReportPortal::FileUtils
13
15
  extend ParallelReportPortal::Clock
14
16
 
15
17
  # Returns the configuration object, initializing it if necessary.
16
- #
18
+ #
17
19
  # @return [Configuration] the configuration object
18
20
  def self.configuration
19
21
  @configuration ||= Configuration.new
20
22
  end
21
23
 
22
24
  # Configures the Report Portal environment.
23
- #
25
+ #
24
26
  # @yieldparam [Configuration] config the configuration object yielded to the block
25
27
  def self.configure(&block)
26
28
  yield configuration
@@ -38,7 +38,8 @@ Gem::Specification.new do |spec|
38
38
  spec.add_development_dependency "webmock", "~> 3.12"
39
39
 
40
40
  spec.add_runtime_dependency 'cucumber', '>= 3.2'
41
- spec.add_runtime_dependency 'faraday', '~> 1.0'
41
+ spec.add_runtime_dependency 'faraday-net_http_persistent', '~> 2.1'
42
+ spec.add_runtime_dependency 'faraday-multipart', '~> 1.0', '>= 1.0.4'
42
43
  spec.add_runtime_dependency 'parallel_tests', '>= 2.29.1'
43
44
  spec.add_runtime_dependency 'rubytree', '~> 1.0'
44
45
  spec.add_runtime_dependency 'net-http-persistent', '~> 4.0'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parallel_report_portal
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nigel Brookes-Thomas
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2022-08-17 00:00:00.000000000 Z
12
+ date: 2023-03-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: appraisal
@@ -124,12 +124,29 @@ dependencies:
124
124
  - !ruby/object:Gem::Version
125
125
  version: '3.2'
126
126
  - !ruby/object:Gem::Dependency
127
- name: faraday
127
+ name: faraday-net_http_persistent
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - "~>"
131
+ - !ruby/object:Gem::Version
132
+ version: '2.1'
133
+ type: :runtime
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '2.1'
140
+ - !ruby/object:Gem::Dependency
141
+ name: faraday-multipart
128
142
  requirement: !ruby/object:Gem::Requirement
129
143
  requirements:
130
144
  - - "~>"
131
145
  - !ruby/object:Gem::Version
132
146
  version: '1.0'
147
+ - - ">="
148
+ - !ruby/object:Gem::Version
149
+ version: 1.0.4
133
150
  type: :runtime
134
151
  prerelease: false
135
152
  version_requirements: !ruby/object:Gem::Requirement
@@ -137,6 +154,9 @@ dependencies:
137
154
  - - "~>"
138
155
  - !ruby/object:Gem::Version
139
156
  version: '1.0'
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: 1.0.4
140
160
  - !ruby/object:Gem::Dependency
141
161
  name: parallel_tests
142
162
  requirement: !ruby/object:Gem::Requirement
@@ -205,6 +225,7 @@ files:
205
225
  - gemfiles/cucumber_6.0.gemfile
206
226
  - lib/parallel_report_portal.rb
207
227
  - lib/parallel_report_portal/.DS_Store
228
+ - lib/parallel_report_portal/after_launch.rb
208
229
  - lib/parallel_report_portal/clock.rb
209
230
  - lib/parallel_report_portal/configuration.rb
210
231
  - lib/parallel_report_portal/cucumber/formatter.rb
@@ -234,7 +255,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
234
255
  - !ruby/object:Gem::Version
235
256
  version: '0'
236
257
  requirements: []
237
- rubygems_version: 3.3.7
258
+ rubygems_version: 3.4.1
238
259
  signing_key:
239
260
  specification_version: 4
240
261
  summary: Run Cucumber Tests in parallel and with Cucumber 3 and 4+