ci_logger 0.3.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b5960f9d4a46fcde15ed4f1610f0e49332a7caf07246ead282ff6eb19412a70f
4
- data.tar.gz: 188ac22306f6258fc87e0a6a6684d471903be78c326d178b6b7f81bafa472671
3
+ metadata.gz: 4b17a0f9e369ac57c9c50d27c68fc855e92283a5902c3359f7ed5ccb5cc7693a
4
+ data.tar.gz: a2b0c16d35701e97ffc0ff6a166e33cb34ac337ccae1e71b7c53998efb2459b4
5
5
  SHA512:
6
- metadata.gz: 62a463925ae11ff7c483ba81e60e39979e26426dece3219b1b455c31302ec93d0e1d36a58317b2155bc7587b3803f5e6c07ab5b27facfc15d1878098dd3d92c2
7
- data.tar.gz: 83bc95acf6c4936809ab77233e98e9e801d1c4a8f26a3bad60dbc6c142878281694ffb140a091ab64a04ba46da643af7736b554e6b452fdafd3851c06bfe2671
6
+ metadata.gz: 371545c384eef42fe36754faef537eb76166937c7ed2b7e6a80408841c449695317f436fabc3c1efcb54d4edab54df54cff33f0ac21244676f18487710e91413
7
+ data.tar.gz: 23bbc1bf2aa2907c37ccb71fc20797790272d744e6d213e114478e574ec50c3635497d0d3c0d16aeefa024216abae5a654738de836c0374c98a0af01c7104a85
data/README.md CHANGED
@@ -1,13 +1,13 @@
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
 
9
9
  - rspec
10
- - rails(>= 5.2)
10
+ - rails(>= 6.0)
11
11
 
12
12
  If you want minitest integration, send Pull Request!
13
13
 
@@ -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.3.1'
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.3.1
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: 2022-12-06 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
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 5.2.0
19
+ version: 6.0.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: 5.2.0
26
+ version: 6.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec-core
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -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
@@ -83,14 +83,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
83
83
  requirements:
84
84
  - - ">="
85
85
  - !ruby/object:Gem::Version
86
- version: '0'
86
+ version: 2.7.0
87
87
  required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  requirements:
89
89
  - - ">="
90
90
  - !ruby/object:Gem::Version
91
91
  version: '0'
92
92
  requirements: []
93
- rubygems_version: 3.3.26
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