selective-ruby-core 0.2.1-x86_64-linux → 0.2.3-x86_64-linux
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 403cd32ad399923812bcd6250cb8770654a18fb2816022c1fb772ca830e356bf
|
4
|
+
data.tar.gz: 591dd02dd211846f885995349d5005aae50495dc15e90ef5ea1f874899acb838
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9186c4fcb131d940bb6c31481f3dd5a851245c530628b33950bc1c7e1020154605378e5ff39b3f8530a49a03d220368a3a06ea2b9dd7124eec9684ab9f95115
|
7
|
+
data.tar.gz: 41a8c629e830f3b775adc1334bcc49fbd728a3f0cc4de932cdeb77c526d4061dc1f35e82ae4196779b4a081da91f947ca10f6d0e39ac0ccf2b2f232101bd1651
|
@@ -8,18 +8,20 @@ module Selective
|
|
8
8
|
class Controller
|
9
9
|
include Helper
|
10
10
|
@@selective_suppress_reporting = false
|
11
|
+
@@report_at_finish = {}
|
11
12
|
|
12
13
|
REQUIRED_CONFIGURATION = {
|
13
14
|
"host" => "SELECTIVE_HOST",
|
14
15
|
"api_key" => "SELECTIVE_API_KEY",
|
15
16
|
"platform" => "SELECTIVE_PLATFORM",
|
16
17
|
"run_id" => "SELECTIVE_RUN_ID",
|
18
|
+
"run_attempt" => "SELECTIVE_RUN_ATTEMPT",
|
17
19
|
"branch" => "SELECTIVE_BRANCH"
|
18
20
|
}.freeze
|
19
21
|
|
20
|
-
def initialize(
|
22
|
+
def initialize(runner_class, runner_args, debug: false, log: false)
|
21
23
|
@debug = debug
|
22
|
-
@runner =
|
24
|
+
@runner = runner_class.new(runner_args, method(:test_case_callback))
|
23
25
|
@retries = 0
|
24
26
|
@runner_id = safe_filename(get_runner_id)
|
25
27
|
@logger = init_logger(log)
|
@@ -32,7 +34,7 @@ module Selective
|
|
32
34
|
handle_termination_signals(transport_pid)
|
33
35
|
wait_for_connectivity
|
34
36
|
run_main_loop
|
35
|
-
rescue
|
37
|
+
rescue ConnectionLostError
|
36
38
|
retry!
|
37
39
|
rescue => e
|
38
40
|
with_error_handling { raise e }
|
@@ -56,12 +58,16 @@ module Selective
|
|
56
58
|
@@selective_suppress_reporting
|
57
59
|
end
|
58
60
|
|
61
|
+
def self.report_at_finish
|
62
|
+
@@report_at_finish
|
63
|
+
end
|
64
|
+
|
59
65
|
private
|
60
66
|
|
61
67
|
attr_reader :runner, :pipe, :transport_pid, :retries, :logger, :runner_id, :diff
|
62
68
|
|
63
69
|
def get_runner_id
|
64
|
-
runner_id = build_env
|
70
|
+
runner_id = build_env["runner_id"]
|
65
71
|
return generate_runner_id if runner_id.nil? || runner_id.empty?
|
66
72
|
|
67
73
|
runner_id
|
@@ -89,10 +95,10 @@ module Selective
|
|
89
95
|
def retry!
|
90
96
|
@retries += 1
|
91
97
|
|
92
|
-
with_error_handling { raise "Too many retries" } if retries >
|
98
|
+
with_error_handling { raise "Too many retries" } if retries > 10
|
93
99
|
|
94
|
-
puts("Retrying in #{retries} seconds...")
|
95
|
-
sleep(retries)
|
100
|
+
puts("Retrying in #{retries} seconds...") if debug?
|
101
|
+
sleep(retries > 4 ? 4 : retries)
|
96
102
|
kill_transport
|
97
103
|
|
98
104
|
pipe.reset!
|
@@ -108,30 +114,30 @@ module Selective
|
|
108
114
|
end
|
109
115
|
|
110
116
|
def transport_url(reconnect: false)
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
117
|
+
base_transport_url_params[:reconnect] = true if reconnect
|
118
|
+
query_string = URI.encode_www_form(base_transport_url_params)
|
119
|
+
"#{build_env["host"]}/transport/websocket?#{query_string}"
|
120
|
+
end
|
121
|
+
|
122
|
+
def base_transport_url_params
|
123
|
+
@base_transport_url_params ||= begin
|
124
|
+
api_key = build_env["api_key"]
|
125
|
+
run_id = build_env["run_id"]
|
126
|
+
run_attempt = build_env["run_attempt"]
|
127
|
+
|
128
|
+
metadata = build_env.reject { |k,v| %w(host runner_id api_key run_id run_attempt).include?(k) }
|
129
|
+
|
130
|
+
{
|
131
|
+
"api_key" => api_key,
|
119
132
|
"run_id" => run_id,
|
120
133
|
"run_attempt" => run_attempt,
|
121
|
-
"api_key" => api_key,
|
122
134
|
"runner_id" => runner_id,
|
123
135
|
"language" => "ruby",
|
124
136
|
"core_version" => Selective::Ruby::Core::VERSION,
|
125
137
|
"framework" => runner.framework,
|
126
138
|
"framework_version" => runner.framework_version,
|
127
139
|
"framework_wrapper_version" => runner.wrapper_version,
|
128
|
-
}.merge(metadata:
|
129
|
-
|
130
|
-
prams[:reconnect] = true if reconnect
|
131
|
-
|
132
|
-
query_string = URI.encode_www_form(params)
|
133
|
-
|
134
|
-
"#{host}/transport/websocket?#{query_string}"
|
140
|
+
}.merge(metadata: metadata.to_json)
|
135
141
|
end
|
136
142
|
end
|
137
143
|
|
@@ -224,7 +230,7 @@ module Selective
|
|
224
230
|
|
225
231
|
sleep(1)
|
226
232
|
end
|
227
|
-
rescue
|
233
|
+
rescue ConnectionLostError, IOError
|
228
234
|
# If the pipe is close, move straight to killing
|
229
235
|
# it forcefully.
|
230
236
|
end
|
@@ -267,11 +273,14 @@ module Selective
|
|
267
273
|
end
|
268
274
|
|
269
275
|
def handle_run_test_cases(data)
|
270
|
-
runner.run_test_cases(data[:test_case_ids]
|
276
|
+
runner.run_test_cases(data[:test_case_ids])
|
271
277
|
end
|
272
278
|
|
279
|
+
# Todo: Rename this command to match the method name
|
280
|
+
# on the runner wrapper. We should do something similar
|
281
|
+
# to normalize handle_print_notice and handle_print_message
|
273
282
|
def handle_remove_failed_test_case_result(data)
|
274
|
-
runner.
|
283
|
+
runner.remove_test_case_result(data[:test_case_id])
|
275
284
|
end
|
276
285
|
|
277
286
|
def handle_print_message(data)
|
@@ -281,7 +290,13 @@ module Selective
|
|
281
290
|
def handle_close(data)
|
282
291
|
exit_status = data[:exit_status]
|
283
292
|
self.class.restore_reporting!
|
284
|
-
|
293
|
+
|
294
|
+
with_error_handling do
|
295
|
+
Selective::Ruby::Core::Controller.report_at_finish[:connection_retries] = @retries
|
296
|
+
write({type: "report_at_finish", data: Selective::Ruby::Core::Controller.report_at_finish})
|
297
|
+
|
298
|
+
runner.finish unless exit_status.is_a?(Integer)
|
299
|
+
end
|
285
300
|
|
286
301
|
kill_transport
|
287
302
|
pipe.delete_pipes
|
@@ -9,7 +9,7 @@ module Selective
|
|
9
9
|
FILE_CORRELATION_COLLECTOR_PATH = File.join(ROOT_GEM_PATH, "lib", "bin", "file_correlation_collector.sh")
|
10
10
|
|
11
11
|
def initialize(diff, num_commits, target_branch)
|
12
|
-
@diff = diff
|
12
|
+
@diff = diff.reject {|f| f =~ /^spec\// }
|
13
13
|
@num_commits = num_commits
|
14
14
|
@target_branch = target_branch
|
15
15
|
end
|
@@ -2,8 +2,6 @@ module Selective
|
|
2
2
|
module Ruby
|
3
3
|
module Core
|
4
4
|
class NamedPipe
|
5
|
-
class PipeClosedError < StandardError; end
|
6
|
-
|
7
5
|
attr_reader :read_pipe_path, :write_pipe_path
|
8
6
|
|
9
7
|
def initialize(read_pipe_path, write_pipe_path, skip_reset: false)
|
@@ -44,7 +42,7 @@ module Selective
|
|
44
42
|
write_pipe.write("\n")
|
45
43
|
write_pipe.flush
|
46
44
|
rescue Errno::EPIPE
|
47
|
-
raise
|
45
|
+
raise ConnectionLostError
|
48
46
|
end
|
49
47
|
end
|
50
48
|
|
@@ -54,7 +52,7 @@ module Selective
|
|
54
52
|
message = read_pipe.gets.chomp
|
55
53
|
rescue NoMethodError => e
|
56
54
|
if e.name == :chomp
|
57
|
-
raise
|
55
|
+
raise ConnectionLostError
|
58
56
|
else
|
59
57
|
raise e
|
60
58
|
end
|
data/lib/selective-ruby-core.rb
CHANGED
@@ -14,6 +14,7 @@ module Selective
|
|
14
14
|
module Ruby
|
15
15
|
module Core
|
16
16
|
class Error < StandardError; end
|
17
|
+
class ConnectionLostError < StandardError; end
|
17
18
|
|
18
19
|
ROOT_GEM_PATH = Gem.loaded_specs["selective-ruby-core"].full_gem_path
|
19
20
|
|
@@ -44,7 +45,7 @@ module Selective
|
|
44
45
|
attr_reader :debug, :log, :runner_name, :args, :command
|
45
46
|
|
46
47
|
def run
|
47
|
-
Selective::Ruby::Core::Controller.new(
|
48
|
+
Selective::Ruby::Core::Controller.new(runner_class, args, debug: debug, log: log).send(command)
|
48
49
|
end
|
49
50
|
|
50
51
|
def parse_args(args)
|
@@ -56,8 +57,8 @@ module Selective
|
|
56
57
|
end
|
57
58
|
end
|
58
59
|
|
59
|
-
def
|
60
|
-
Selective::Ruby::Core.runner_for(runner_name)
|
60
|
+
def runner_class
|
61
|
+
Selective::Ruby::Core.runner_for(runner_name)
|
61
62
|
end
|
62
63
|
|
63
64
|
def require_runner
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: selective-ruby-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: x86_64-linux
|
6
6
|
authors:
|
7
7
|
- Benjamin Wood
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2024-
|
12
|
+
date: 2024-02-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: zeitwerk
|