ruby_ci 0.1.5 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ruby_ci/extract_definitions.rb +44 -0
- data/lib/ruby_ci/rspec_formatter.rb +57 -0
- data/lib/ruby_ci/runner_prepend.rb +80 -0
- data/lib/ruby_ci/version.rb +1 -1
- data/ruby_ci.gemspec +1 -0
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f3dc7f160430dc31d9e71e91fa440390233ed36d0101ca70b49d5745257d93a
|
4
|
+
data.tar.gz: 00eca946cfc469f4999a77eb8ba39be8c0354cb91dbad727a1df1e7333dc54b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 98bb7204929e650fe2b6866e4475a592f611380752472503bfae719b18de1757d9693ce4c2805a720a3084115ba7ad4fa354354630346fca5725b7c3ebcd1e4c
|
7
|
+
data.tar.gz: 03dd498f0362f994ce65c077a4341c5892fe57ab9f0992a08377761504c772a8d3ac9cf5ae17c84ac3cf9cd11b8ae7ca9b4d968e59e2884de6182031f438ae88
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyCI
|
4
|
+
class ExtractDescriptions
|
5
|
+
def call(example_group, count: false)
|
6
|
+
data = {}
|
7
|
+
|
8
|
+
data[scoped_id(example_group)] = {
|
9
|
+
description: description(example_group),
|
10
|
+
line_number: line_number(example_group),
|
11
|
+
}
|
12
|
+
|
13
|
+
if count
|
14
|
+
data[:test_count] ||= 0
|
15
|
+
data[:test_count] += RSpec.world.example_count([example_group])
|
16
|
+
end
|
17
|
+
|
18
|
+
example_group.examples.each do |ex|
|
19
|
+
data[scoped_id(example_group)][scoped_id(ex)] = {
|
20
|
+
line_number: line_number(ex),
|
21
|
+
description: description(ex),
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
example_group.children.each do |child|
|
26
|
+
data[scoped_id(example_group)].merge! call(child)
|
27
|
+
end
|
28
|
+
|
29
|
+
data
|
30
|
+
end
|
31
|
+
|
32
|
+
def scoped_id(example_group)
|
33
|
+
example_group.metadata[:scoped_id].split(":").last
|
34
|
+
end
|
35
|
+
|
36
|
+
def line_number(example_group)
|
37
|
+
example_group.metadata[:line_number]
|
38
|
+
end
|
39
|
+
|
40
|
+
def description(example_group)
|
41
|
+
example_group.metadata[:description]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyCI
|
4
|
+
class RspecFormatter
|
5
|
+
attr_reader :current_test_key
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@output = {}
|
9
|
+
@is_failed = false
|
10
|
+
end
|
11
|
+
|
12
|
+
def passed?
|
13
|
+
!@is_failed
|
14
|
+
end
|
15
|
+
|
16
|
+
def current_test_key=(value)
|
17
|
+
@current_test_key = value
|
18
|
+
end
|
19
|
+
|
20
|
+
def example_finished(notification)
|
21
|
+
example = notification.example
|
22
|
+
metadata = example.metadata
|
23
|
+
|
24
|
+
*example_group_ids, example_id = metadata[:scoped_id].split(":")
|
25
|
+
|
26
|
+
file_output = @output[current_test_key] ||= {}
|
27
|
+
|
28
|
+
example_group = example_group_ids.reduce(file_output) do |output, scope_id|
|
29
|
+
output[scope_id] ||= {}
|
30
|
+
output[scope_id]
|
31
|
+
end
|
32
|
+
|
33
|
+
example_group[example_id] = {
|
34
|
+
run_time: example.execution_result.run_time,
|
35
|
+
status: example.execution_result.status
|
36
|
+
}
|
37
|
+
|
38
|
+
if example.execution_result.status == :failed
|
39
|
+
@is_failed = true
|
40
|
+
example_group[example_id][:fully_formatted] =
|
41
|
+
notification.fully_formatted(0, ::RSpec::Core::Formatters::ConsoleCodes)
|
42
|
+
elsif metadata[:retry_attempts] && metadata[:retry_attempts] > 0
|
43
|
+
example_group[example_id][:retry_attempts] = metadata[:retry_attempts]
|
44
|
+
example_group[example_id][:fully_formatted] =
|
45
|
+
example.set_exception metadata[:retry_exceptions].first.to_s
|
46
|
+
end
|
47
|
+
|
48
|
+
example_group[example_id]
|
49
|
+
end
|
50
|
+
|
51
|
+
def dump_and_reset
|
52
|
+
output = @output
|
53
|
+
@output = {}
|
54
|
+
output
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require_relative "rspec_formatter"
|
3
|
+
require_relative "extract_definitions"
|
4
|
+
|
5
|
+
module RubyCI
|
6
|
+
module RunnerPrepend
|
7
|
+
def run_specs(example_groups)
|
8
|
+
examples_count = @world.example_count(example_groups)
|
9
|
+
|
10
|
+
example_groups = example_groups.reduce({}) do |acc, ex_group|
|
11
|
+
if acc[ex_group.file_path]
|
12
|
+
acc[ex_group.file_path] << ex_group
|
13
|
+
else
|
14
|
+
acc[ex_group.file_path] = [ex_group]
|
15
|
+
end
|
16
|
+
acc
|
17
|
+
end
|
18
|
+
|
19
|
+
RubyCI.configure { |c| c.run_key = "rspec" }
|
20
|
+
|
21
|
+
RubyCI.ws.on(:enq_request) do
|
22
|
+
example_groups.reduce({}) do |example_group_descriptions, (file, example_groups)|
|
23
|
+
example_groups.each do |example_group|
|
24
|
+
data = RubyCI::ExtractDescriptions.new.call(example_group, count: true)
|
25
|
+
|
26
|
+
next if data[:test_count] == 0
|
27
|
+
|
28
|
+
if example_group_descriptions[file]
|
29
|
+
example_group_descriptions[file].merge!(data) do |k, v1, v2|
|
30
|
+
v1 + v2
|
31
|
+
end
|
32
|
+
else
|
33
|
+
example_group_descriptions[file] = data
|
34
|
+
end
|
35
|
+
end
|
36
|
+
example_group_descriptions
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
examples_passed = @configuration.reporter.report(examples_count) do |reporter|
|
41
|
+
@configuration.with_suite_hooks do
|
42
|
+
if examples_count == 0 && @configuration.fail_if_no_examples
|
43
|
+
return @configuration.failure_exit_code
|
44
|
+
end
|
45
|
+
|
46
|
+
formatter = RubyCI::RspecFormatter.new
|
47
|
+
|
48
|
+
reporter.register_listener(formatter, :example_finished)
|
49
|
+
|
50
|
+
RubyCI.ws.on(:deq) do |tests|
|
51
|
+
tests.each do |test|
|
52
|
+
file, scoped_id = test.split(":", 2)
|
53
|
+
Thread.current[:rubyci_scoped_ids] = scoped_id
|
54
|
+
example_groups[file].each do |file_group|
|
55
|
+
formatter.current_test_key = test
|
56
|
+
|
57
|
+
file_group.run(reporter)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
formatter.dump_and_reset
|
62
|
+
end
|
63
|
+
|
64
|
+
RubyCI.await
|
65
|
+
|
66
|
+
formatter.passed?
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
exit_code(examples_passed)
|
71
|
+
end
|
72
|
+
|
73
|
+
def exit_code(examples_passed=false)
|
74
|
+
return @configuration.error_exit_code || @configuration.failure_exit_code if @world.non_example_failure
|
75
|
+
return @configuration.failure_exit_code unless examples_passed
|
76
|
+
|
77
|
+
0
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
data/lib/ruby_ci/version.rb
CHANGED
data/ruby_ci.gemspec
CHANGED
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
28
28
|
spec.require_paths = ["lib"]
|
29
29
|
|
30
|
+
spec.add_dependency "console", "~> 1.15.0"
|
30
31
|
spec.add_dependency "async-websocket", '<= 0.20.0'
|
31
32
|
spec.add_development_dependency "pry"
|
32
33
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_ci
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ale ∴
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: console
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.15.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.15.0
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: async-websocket
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -60,6 +74,9 @@ files:
|
|
60
74
|
- lib/ruby_ci.rb
|
61
75
|
- lib/ruby_ci/configuration.rb
|
62
76
|
- lib/ruby_ci/exceptions.rb
|
77
|
+
- lib/ruby_ci/extract_definitions.rb
|
78
|
+
- lib/ruby_ci/rspec_formatter.rb
|
79
|
+
- lib/ruby_ci/runner_prepend.rb
|
63
80
|
- lib/ruby_ci/version.rb
|
64
81
|
- ruby_ci.gemspec
|
65
82
|
homepage: https://github.com/RubyCI/ruby_ci_gem
|