fast_ci 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/fast_ci.gemspec +5 -3
- data/lib/fast_ci/rspec_formatter.rb +6 -223
- data/lib/fast_ci/runner_prepend.rb +8 -16
- data/lib/fast_ci/version.rb +1 -1
- data/lib/fast_ci.rb +1 -1
- metadata +37 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d1b77a32be5c6217b8638a34cb4b56e71f70264772fb4ff3bb80a950a5e5f30
|
4
|
+
data.tar.gz: e2c37846aa46613428f39f27de80a0b9396aac514231ee2b1d6818d74ed0e2be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9747a1992088ae124fdee45dac860f31e5bfdafb7bd3d53ee32b5470116db2596774d439d89684487951bc01f3cea3d68e2682fba4b738f3882e3294e045596e
|
7
|
+
data.tar.gz: 2db8c9d842cf3c3d7ab4fe4992de6153d3ba5d709d5d7690bb1cef1d25040213b69e9bd092457aa50d1945daa13dfce48bf8c7ea4946866348b92d5741dd4d69
|
data/fast_ci.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.description = "Ruby wrapper for creating FastCI integrations"
|
13
13
|
spec.homepage = "https://github.com/RubyCI/fast_ci_gem"
|
14
14
|
spec.license = "MIT"
|
15
|
-
spec.required_ruby_version = ">= 2.
|
15
|
+
spec.required_ruby_version = ">= 2.6.0"
|
16
16
|
|
17
17
|
spec.metadata["homepage_uri"] = spec.homepage
|
18
18
|
spec.metadata["source_code_uri"] = spec.homepage
|
@@ -26,10 +26,12 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.executables = ["fastci_rubycritic", "fastci_brakeman", "fastci_bundle_audit"]
|
27
27
|
spec.require_paths = ["lib"]
|
28
28
|
|
29
|
-
spec.add_dependency "console", "
|
29
|
+
spec.add_dependency "console", ">= 1.10.0"
|
30
30
|
spec.add_dependency "async-websocket", '<= 0.20.0'
|
31
|
+
spec.add_dependency "rspec-core", ">= 3.6.0"
|
32
|
+
spec.add_dependency "simplecov", ">= 0.22.0"
|
31
33
|
spec.add_dependency "rubycritic", ">= 4.1.0"
|
32
34
|
spec.add_dependency "brakeman", ">= 5.4.1"
|
33
|
-
spec.add_dependency "minitest-rails", ">=
|
35
|
+
spec.add_dependency "minitest-rails", ">= 2.2.1"
|
34
36
|
spec.add_development_dependency "pry"
|
35
37
|
end
|
@@ -4,57 +4,9 @@ module FastCI
|
|
4
4
|
class RspecFormatter
|
5
5
|
attr_reader :current_test_key
|
6
6
|
|
7
|
-
def initialize
|
8
|
-
@output =
|
9
|
-
@event_output = {}
|
7
|
+
def initialize
|
8
|
+
@output = {}
|
10
9
|
@is_failed = false
|
11
|
-
@current_path = []
|
12
|
-
@current_path_started_at = []
|
13
|
-
@max_heap_live_num = 0
|
14
|
-
@dup_stdout = STDOUT.clone
|
15
|
-
@events = []
|
16
|
-
|
17
|
-
$stdout = StringIO.new()
|
18
|
-
|
19
|
-
@log_thread = Thread.new do
|
20
|
-
loop do
|
21
|
-
sleep 10
|
22
|
-
check_heap_live_num
|
23
|
-
@should_send_events = true
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def time_now
|
29
|
-
time_frozen? ? Timecop.return { Time.now } : Time.now
|
30
|
-
end
|
31
|
-
|
32
|
-
def time_frozen?
|
33
|
-
return unless defined?(Timecop)
|
34
|
-
Timecop.frozen?
|
35
|
-
end
|
36
|
-
|
37
|
-
def rspec_runner_index
|
38
|
-
ENV["TEST_ENV_NUMBER"]
|
39
|
-
end
|
40
|
-
|
41
|
-
def send_events
|
42
|
-
@should_send_events = false
|
43
|
-
|
44
|
-
if @events.length > 0
|
45
|
-
json_events = {
|
46
|
-
build_id: FastCI.configuration.orig_build_id,
|
47
|
-
compressed_data: Base64.strict_encode64(Zlib::Deflate.deflate(JSON.fast_generate(@events), 9)),
|
48
|
-
}
|
49
|
-
|
50
|
-
FastCI.send_events(json_events)
|
51
|
-
|
52
|
-
@events = []
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
def check_heap_live_num
|
57
|
-
@max_heap_live_num = [@max_heap_live_num, GC.stat[:heap_live_slots] || GC.stat[:heap_live_num]].max
|
58
10
|
end
|
59
11
|
|
60
12
|
def passed?
|
@@ -65,100 +17,13 @@ module FastCI
|
|
65
17
|
@current_test_key = value
|
66
18
|
end
|
67
19
|
|
68
|
-
def start(start_notification)
|
69
|
-
# $stderr = $stdout
|
70
|
-
|
71
|
-
data = {
|
72
|
-
load_time: start_notification.load_time,
|
73
|
-
example_count: start_notification.count,
|
74
|
-
started_at: time_now.to_s
|
75
|
-
}
|
76
|
-
|
77
|
-
return if running_only_failed? ||
|
78
|
-
running_gem_or_engine? ||
|
79
|
-
ENV["EXTRA_SLOWER_RUN"]
|
80
|
-
|
81
|
-
msg(:start, data)
|
82
|
-
end
|
83
|
-
|
84
|
-
def close(null_notification)
|
85
|
-
# check_heap_live_num
|
86
|
-
msg(:gc_stat, GC.stat.merge(max_heap_live_num: @max_heap_live_num))
|
87
|
-
unless running_only_failed? || ENV["EXTRA_SLOWER_RUN"] || running_gem_or_engine?
|
88
|
-
msg(:close, {final_output: get_output})
|
89
|
-
end
|
90
|
-
send_events
|
91
|
-
$stdout = @dup_stdout
|
92
|
-
end
|
93
|
-
|
94
|
-
def example_group_started(group_notification)
|
95
|
-
metadata = group_notification.group.metadata
|
96
|
-
@current_path_started_at << time_now
|
97
|
-
|
98
|
-
if @current_path.size == 0
|
99
|
-
@example_failed_index = 0
|
100
|
-
file_path = metadata[:file_path].gsub("./".freeze, "".freeze)
|
101
|
-
file_path = [ENV["DIR_PREFIX"], file_path].join("/") if ENV["DIR_PREFIX"]
|
102
|
-
@current_path << file_path
|
103
|
-
end
|
104
|
-
|
105
|
-
@current_path << id(metadata)
|
106
|
-
|
107
|
-
msg(:group_started, [
|
108
|
-
path_with_file(group_notification.group),
|
109
|
-
{
|
110
|
-
line_number: metadata[:line_number],
|
111
|
-
description: metadata[:description],
|
112
|
-
}
|
113
|
-
])
|
114
|
-
end
|
115
|
-
|
116
|
-
def example_started(example_notification)
|
117
|
-
@output_before = get_output
|
118
|
-
end
|
119
|
-
|
120
|
-
def example_passed(example_notification)
|
121
|
-
metadata = example_notification.example.metadata
|
122
|
-
broadcast_example_finished(serialize_example(metadata, "passed".freeze), example_notification.example)
|
123
|
-
end
|
124
|
-
|
125
|
-
def example_failed(example_notification)
|
126
|
-
@example_failed_index += 1
|
127
|
-
metadata = example_notification.example.metadata
|
128
|
-
fully_formatted = example_notification.fully_formatted(@example_failed_index, ::RSpec::Core::Formatters::ConsoleCodes)
|
129
|
-
|
130
|
-
broadcast_example_finished(
|
131
|
-
serialize_example(metadata, "failed".freeze, fully_formatted),
|
132
|
-
example_notification.example
|
133
|
-
)
|
134
|
-
end
|
135
|
-
|
136
|
-
def example_pending(example_notification)
|
137
|
-
metadata = example_notification.example.metadata
|
138
|
-
broadcast_example_finished(
|
139
|
-
serialize_example(metadata, "pending".freeze),
|
140
|
-
example_notification.example
|
141
|
-
)
|
142
|
-
end
|
143
|
-
|
144
|
-
def example_group_finished(group_notification)
|
145
|
-
run_time = time_now - @current_path_started_at.pop
|
146
|
-
if (run_time < 0) || (run_time > 2400)
|
147
|
-
run_time = 0.525
|
148
|
-
end
|
149
|
-
msg(:group_finished, [path_with_file(group_notification.group), {run_time: run_time}])
|
150
|
-
# msg(:group_finished, [@current_path.map(&:to_s), {run_time: run_time}])
|
151
|
-
@current_path.pop
|
152
|
-
@current_path.pop if @current_path.size == 1 # Remove the file_path at the beggining
|
153
|
-
end
|
154
|
-
|
155
20
|
def example_finished(notification)
|
156
21
|
example = notification.example
|
157
22
|
metadata = example.metadata
|
158
23
|
|
159
24
|
*example_group_ids, example_id = metadata[:scoped_id].split(":")
|
160
25
|
|
161
|
-
file_output = @
|
26
|
+
file_output = @output[current_test_key] ||= {}
|
162
27
|
|
163
28
|
example_group = example_group_ids.reduce(file_output) do |output, scope_id|
|
164
29
|
output[scope_id] ||= {}
|
@@ -184,91 +49,9 @@ module FastCI
|
|
184
49
|
end
|
185
50
|
|
186
51
|
def dump_and_reset
|
187
|
-
|
188
|
-
@
|
189
|
-
|
190
|
-
end
|
191
|
-
|
192
|
-
def path_with_file(group)
|
193
|
-
file_path = group.parent_groups.last.file_path.gsub("./".freeze, "".freeze)
|
194
|
-
|
195
|
-
group.metadata[:scoped_id].split(":").unshift(file_path)
|
196
|
-
end
|
197
|
-
|
198
|
-
private
|
199
|
-
|
200
|
-
def running_gem_or_engine?
|
201
|
-
!!ENV["DIR_PREFIX"]
|
202
|
-
end
|
203
|
-
|
204
|
-
def running_only_failed?
|
205
|
-
!!ENV["RERUN_FAILED_FILES"]
|
206
|
-
end
|
207
|
-
|
208
|
-
def serialize_example(metadata, status, fully_formatted = nil)
|
209
|
-
run_time = metadata[:execution_result].run_time
|
210
|
-
if (run_time < 0) || (run_time > 2400)
|
211
|
-
run_time = 0.525
|
212
|
-
end
|
213
|
-
|
214
|
-
result = {
|
215
|
-
id: id(metadata),
|
216
|
-
status: status,
|
217
|
-
line_number: metadata[:line_number].to_s,
|
218
|
-
description: metadata[:description],
|
219
|
-
run_time: run_time,
|
220
|
-
fully_formatted: fully_formatted,
|
221
|
-
scoped_id: metadata[:scoped_id],
|
222
|
-
}.compact
|
223
|
-
|
224
|
-
result[:gem_or_engine] = true if running_gem_or_engine?
|
225
|
-
|
226
|
-
if running_only_failed?
|
227
|
-
result[:reruned] = true
|
228
|
-
elsif status == "failed" && !running_gem_or_engine?
|
229
|
-
File.write('tmp/rspec_failures', "#{@current_path.first}[#{metadata[:scoped_id]}]", mode: 'a+')
|
230
|
-
end
|
231
|
-
|
232
|
-
if status == "failed"
|
233
|
-
img_path = metadata.dig(:screenshot, :image) ||
|
234
|
-
fully_formatted&.scan(/\[Screenshot Image\]: (.*)$/).flatten.first&.strip&.chomp ||
|
235
|
-
fully_formatted&.scan(/\[Screenshot\]: (.*)$/).flatten.first&.strip&.chomp
|
236
|
-
|
237
|
-
if img_path && File.exist?(img_path)
|
238
|
-
STDOUT.puts "SCREENSHOT!"
|
239
|
-
result[:screenshots_base64] ||= []
|
240
|
-
result[:screenshots_base64] << Base64.strict_encode64(File.read(img_path))
|
241
|
-
end
|
242
|
-
end
|
243
|
-
@last_example_finished_at = time_now
|
244
|
-
# TODO annalyze this: run_time: metadata[:execution_result].run_time,
|
245
|
-
result
|
246
|
-
end
|
247
|
-
|
248
|
-
def msg(event, data)
|
249
|
-
@events << ["rspec_#{event}".upcase, [rspec_runner_index, data]]
|
250
|
-
end
|
251
|
-
|
252
|
-
def id(metadata)
|
253
|
-
metadata[:scoped_id].split(":").last || raise("No scoped id")
|
254
|
-
end
|
255
|
-
|
256
|
-
def broadcast_example_finished(data, example)
|
257
|
-
msg(:example_finished, [
|
258
|
-
path_with_file(example.example_group),
|
259
|
-
data.merge(output_inside: get_output, output_before: @output_before)
|
260
|
-
])
|
261
|
-
|
262
|
-
send_events if @should_send_events
|
263
|
-
end
|
264
|
-
|
265
|
-
def get_output
|
266
|
-
return if $stdout.pos == 0
|
267
|
-
$stdout.rewind
|
268
|
-
res = $stdout.read
|
269
|
-
$stdout.flush
|
270
|
-
$stdout.rewind
|
271
|
-
res
|
52
|
+
output = @output
|
53
|
+
@output = {}
|
54
|
+
output
|
272
55
|
end
|
273
56
|
end
|
274
57
|
end
|
@@ -6,11 +6,13 @@ module FastCI
|
|
6
6
|
module RunnerPrepend
|
7
7
|
def run_specs(example_groups)
|
8
8
|
@rspec_started_at = Time.now
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
9
|
+
if ENV['FSCI_REMOTE_TESTS'] == 'true'
|
10
|
+
json_events = {
|
11
|
+
build_id: FastCI.configuration.orig_build_id,
|
12
|
+
compressed_data: Base64.strict_encode64(Zlib::Deflate.deflate(JSON.fast_generate([['RSPEC_RUN', { started_at: @rspec_started_at, test_env_number: ENV["TEST_ENV_NUMBER"] }]]), 9)),
|
13
|
+
}
|
14
|
+
FastCI.send_events(json_events)
|
15
|
+
end
|
14
16
|
|
15
17
|
examples_count = @world.example_count(example_groups)
|
16
18
|
|
@@ -50,19 +52,9 @@ module FastCI
|
|
50
52
|
return @configuration.failure_exit_code
|
51
53
|
end
|
52
54
|
|
53
|
-
formatter = FastCI::RspecFormatter.new
|
55
|
+
formatter = FastCI::RspecFormatter.new
|
54
56
|
|
55
57
|
reporter.register_listener(formatter, :example_finished)
|
56
|
-
if ENV['FSCI_REMOTE_TESTS'] == 'true'
|
57
|
-
reporter.register_listener(formatter, :start)
|
58
|
-
reporter.register_listener(formatter, :example_group_started)
|
59
|
-
reporter.register_listener(formatter, :example_started)
|
60
|
-
reporter.register_listener(formatter, :example_passed)
|
61
|
-
reporter.register_listener(formatter, :example_failed)
|
62
|
-
reporter.register_listener(formatter, :example_pending)
|
63
|
-
reporter.register_listener(formatter, :example_group_finished)
|
64
|
-
reporter.register_listener(formatter, :close)
|
65
|
-
end
|
66
58
|
|
67
59
|
FastCI.rspec_ws.on(:deq) do |tests|
|
68
60
|
tests.each do |test|
|
data/lib/fast_ci/version.rb
CHANGED
data/lib/fast_ci.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fast_ci
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nesha Zoric
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-10-
|
11
|
+
date: 2024-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: console
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: 1.10.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
26
|
+
version: 1.10.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: async-websocket
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,6 +38,34 @@ dependencies:
|
|
38
38
|
- - "<="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.20.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec-core
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.6.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.6.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: simplecov
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.22.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.22.0
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: rubycritic
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +100,14 @@ dependencies:
|
|
72
100
|
requirements:
|
73
101
|
- - ">="
|
74
102
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
103
|
+
version: 2.2.1
|
76
104
|
type: :runtime
|
77
105
|
prerelease: false
|
78
106
|
version_requirements: !ruby/object:Gem::Requirement
|
79
107
|
requirements:
|
80
108
|
- - ">="
|
81
109
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
110
|
+
version: 2.2.1
|
83
111
|
- !ruby/object:Gem::Dependency
|
84
112
|
name: pry
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -152,7 +180,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
152
180
|
requirements:
|
153
181
|
- - ">="
|
154
182
|
- !ruby/object:Gem::Version
|
155
|
-
version: 2.
|
183
|
+
version: 2.6.0
|
156
184
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
157
185
|
requirements:
|
158
186
|
- - ">="
|