ci_logger 0.4.0 → 0.5.0

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: de52e260b632de6a46a6a19b69e566b0549edaa2b78e839251c2b954d6fbb1d0
4
- data.tar.gz: 4c005a4e2417d12bada68fbd4165a2b0e00c6ad93df4a8516bda206c810e2d8d
3
+ metadata.gz: 4b17a0f9e369ac57c9c50d27c68fc855e92283a5902c3359f7ed5ccb5cc7693a
4
+ data.tar.gz: a2b0c16d35701e97ffc0ff6a166e33cb34ac337ccae1e71b7c53998efb2459b4
5
5
  SHA512:
6
- metadata.gz: 9048488a216c30c627a7a303891331cc8489b40467fc0fdd698b747ee2bd5911e0fa1d23a33574549bf44f36b42b979e1de2feaeb25474fd7c32c31bc58365be
7
- data.tar.gz: ff957687392a4b2438ccb736e2b7696c47dd3784fd673ac34206ae5e176b136b2251febbe273cc05414465d36ccb2cd15a4a465f427eb5c41d6a93090a9dbcfa
6
+ metadata.gz: 371545c384eef42fe36754faef537eb76166937c7ed2b7e6a80408841c449695317f436fabc3c1efcb54d4edab54df54cff33f0ac21244676f18487710e91413
7
+ data.tar.gz: 23bbc1bf2aa2907c37ccb71fc20797790272d744e6d213e114478e574ec50c3635497d0d3c0d16aeefa024216abae5a654738de836c0374c98a0af01c7104a85
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # CiLogger
2
2
 
3
- We run a large number of tests with CI every day. When a test fails, we have to investigate the log, but as it is, the log output is so large that it is difficult to investigate the cause of the failed test.
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 outputs only the log of failed tests. This is useful when investigating the cause of a failed test.
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
@@ -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 "ci_logger/rspec_formatter"
9
+ require "rspec/core"
10
+ require "ci_logger/example_group_methods"
10
11
 
11
12
  RSpec.configure do |config|
12
- config.add_formatter 'progress' if config.formatters.empty?
13
- config.add_formatter ::CiLogger::RspecFormatter
14
- config.before do |example|
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? || skipped?
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
@@ -1,3 +1,3 @@
1
1
  module CiLogger
2
- VERSION = '0.4.0'
2
+ VERSION = '0.5.0'
3
3
  end
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.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - willnet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-17 00:00:00.000000000 Z
11
+ date: 2023-05-19 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
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  - !ruby/object:Gem::Version
91
91
  version: '0'
92
92
  requirements: []
93
- rubygems_version: 3.3.3
93
+ rubygems_version: 3.4.12
94
94
  signing_key:
95
95
  specification_version: 4
96
96
  summary: Faster logger for CI
@@ -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