ci_logger 0.4.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/ci_logger/example_group_methods.rb +14 -0
- data/lib/ci_logger/railtie.rb +19 -5
- data/lib/ci_logger/version.rb +1 -1
- metadata +3 -3
- data/lib/ci_logger/rspec_formatter.rb +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d378e44c124952aecefaada042e51ca49bde9f126970a7ed5b8e04a9f4523a4f
|
4
|
+
data.tar.gz: cb5d471262303a7b6075979c5c4d411424fa1783742e1a2c67aea4630ed5166e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40f1589c2767df171705caa124a03afe67b793e043f9ec94a2d4dc0552029bdca4c5cbca2dafe1b9182b6b6d00afec6821a9dea1b4024c6585c04ee1a560b9da
|
7
|
+
data.tar.gz: fbe15cfa23c67256a4b8a71fb2871b7da2dc0b236d913537d2ae49a70a4b4e2738ec0eff000013c2b921d24894e28f240018986ef02ba20b007c8dab1bfd07f3
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# CiLogger
|
2
2
|
|
3
|
-
We
|
3
|
+
We perform a significant number of tests using CI on a daily basis. Whenever a test fails, we need to examine the log. However, the current log output is excessively large, making it challenging to identify the root cause of the failed test.
|
4
4
|
|
5
|
-
CiLogger
|
5
|
+
CiLogger specifically generates logs for failed tests, which proves invaluable during the investigation of test failures.
|
6
6
|
|
7
7
|
## prerequisite
|
8
8
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module CiLogger
|
2
|
+
module ExampleGroupMethods
|
3
|
+
# original from https://github.com/rspec/rspec-rails/blob/229f5f7ca9c0de0c7bca452450416d988f7cf612/lib/rspec/rails/example/system_example_group.rb#L28-L37
|
4
|
+
def passed?
|
5
|
+
return false if RSpec.current_example.exception
|
6
|
+
return true unless defined?(::RSpec::Expectations::FailureAggregator)
|
7
|
+
|
8
|
+
failure_notifier = ::RSpec::Support.failure_notifier
|
9
|
+
return true unless failure_notifier.is_a?(::RSpec::Expectations::FailureAggregator)
|
10
|
+
|
11
|
+
failure_notifier.failures.empty? && failure_notifier.other_errors.empty?
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/ci_logger/railtie.rb
CHANGED
@@ -4,16 +4,30 @@ module CiLogger
|
|
4
4
|
config.ci_logger.enabled = false
|
5
5
|
|
6
6
|
config.before_initialize do
|
7
|
-
if config.ci_logger.enabled
|
7
|
+
if Rails.application.config.ci_logger.enabled
|
8
8
|
Rails.logger = CiLogger::Logger.new(Rails.logger)
|
9
|
-
require "
|
9
|
+
require "rspec/core"
|
10
|
+
require "ci_logger/example_group_methods"
|
10
11
|
|
11
12
|
RSpec.configure do |config|
|
12
|
-
config.
|
13
|
-
|
14
|
-
config.
|
13
|
+
config.include CiLogger::ExampleGroupMethods
|
14
|
+
|
15
|
+
config.prepend_before do |example|
|
16
|
+
next unless Rails.application.config.ci_logger.enabled
|
17
|
+
|
15
18
|
Rails.logger.debug("start example at #{example.location}")
|
16
19
|
end
|
20
|
+
|
21
|
+
config.append_after do |example|
|
22
|
+
if !Rails.application.config.ci_logger.enabled
|
23
|
+
Rails.logger.sync
|
24
|
+
elsif passed?
|
25
|
+
Rails.logger.clear
|
26
|
+
else
|
27
|
+
Rails.logger.debug("finish example at #{example.location}")
|
28
|
+
Rails.logger.sync
|
29
|
+
end
|
30
|
+
end
|
17
31
|
end
|
18
32
|
end
|
19
33
|
end
|
data/lib/ci_logger/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ci_logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- willnet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -63,9 +63,9 @@ files:
|
|
63
63
|
- README.md
|
64
64
|
- Rakefile
|
65
65
|
- lib/ci_logger.rb
|
66
|
+
- lib/ci_logger/example_group_methods.rb
|
66
67
|
- lib/ci_logger/logger.rb
|
67
68
|
- lib/ci_logger/railtie.rb
|
68
|
-
- lib/ci_logger/rspec_formatter.rb
|
69
69
|
- lib/ci_logger/version.rb
|
70
70
|
- lib/tasks/ci_logger_tasks.rake
|
71
71
|
homepage: https://github.com/willnet/ci_logger
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require "rspec/core"
|
2
|
-
|
3
|
-
module CiLogger
|
4
|
-
class RspecFormatter
|
5
|
-
RSpec::Core::Formatters.register self, :example_passed, :example_pending, :example_failed
|
6
|
-
|
7
|
-
def initialize(_out)
|
8
|
-
@out = _out
|
9
|
-
end
|
10
|
-
|
11
|
-
def example_failed(notification)
|
12
|
-
if Rails.application.config.ci_logger.enabled
|
13
|
-
example = notification.example
|
14
|
-
Rails.logger.debug("finish example at #{example.location}")
|
15
|
-
Rails.logger.sync
|
16
|
-
else
|
17
|
-
Rails.logger.sync_with_original_level
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def example_passed(_notification)
|
22
|
-
if Rails.application.config.ci_logger.enabled
|
23
|
-
Rails.logger.clear
|
24
|
-
else
|
25
|
-
Rails.logger.sync_with_original_level
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
def example_pending(_notification)
|
30
|
-
if Rails.application.config.ci_logger.enabled
|
31
|
-
Rails.logger.clear
|
32
|
-
else
|
33
|
-
Rails.logger.sync_with_original_level
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|