knapsack_pro 7.13.0 → 7.14.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: ddf5678a555f4e33ac61a02ba0f05b916a5e65dd8dca2b5a06e7d2bea74da028
4
- data.tar.gz: aaa74b69c3753b8f70aa8deff5528413db49c53b731ce65db571d5d768c0d4f0
3
+ metadata.gz: 113e9ca31d058ab9623d6a0bb278768ad0a864db8bb8776440d00ceb2a648b37
4
+ data.tar.gz: '084be6d88bf072c8ece112b3de2a6707b240816e993f039701cd68e7920f7988'
5
5
  SHA512:
6
- metadata.gz: dbc287b2088b1fb96a76e9ca59d3e37c40e426644b21c0b85fd373737847b0966f56b70309b5ba2afa32c26279807ea858d99e09ab9e9feb38ed0f1819320dcd
7
- data.tar.gz: fc31eb5aa8f02cb4a77221d04d5260e607a8af70e3174b89c0d578c67f2616c4bee76a098d7f405942a0bcf678399b9d270b42e50d1e89902233f1e7203ea8f1
6
+ metadata.gz: 97015f7b3db931f3a9f68e7ef59aecb99f0befa5202b148d5aa56736d256048c842c00babc265c47c583534f2a0dafc488c49b748b4b3084f93a2d42f6013d84
7
+ data.tar.gz: 62fd8be74b14f402840ea4b9b6866a9ac008daa09d279e2cee21bd3f513d8f746f635c770c83e65db36139aa6e9ebb362301794e6aad70a9d59796dd86167d90
data/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ### 7.14.0
4
+
5
+ * Improve debugging for hanging CI nodes: show hanging spec files in the RSpec output and a command to reproduce the current batch of tests.
6
+
7
+ https://github.com/KnapsackPro/knapsack_pro-ruby/pull/287
8
+
9
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v7.13.1...v7.14.0
10
+
11
+ ### 7.13.1
12
+
13
+ * Fix handling signals for non-RSpec test runners
14
+
15
+ https://github.com/KnapsackPro/knapsack_pro-ruby/pull/286
16
+
17
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v7.13.0...v7.13.1
18
+
3
19
  ### 7.13.0
4
20
 
5
21
  * Add `KNAPSACK_PRO_FALLBACK_MODE_ERROR_EXIT_CODE` to specify a custom exit code whenever Knapsack Pro fails because Fallback Mode cannot be used
@@ -59,12 +59,15 @@ module KnapsackPro
59
59
  Signal.trap(signal) {
60
60
  puts "#{signal} signal has been received. Terminating Knapsack Pro..."
61
61
  @@terminate_process = true
62
- RSpec.world.wants_to_quit = true
62
+ post_trap_signals
63
63
  log_threads
64
64
  }
65
65
  end
66
66
  end
67
67
 
68
+ def post_trap_signals
69
+ end
70
+
68
71
  def log_threads
69
72
  threads = Thread.list
70
73
 
@@ -74,6 +77,8 @@ module KnapsackPro
74
77
  puts 'Use the following backtrace(s) to find the line of code that got stuck if the CI node hung and terminated your tests.'
75
78
  puts 'How to read the backtrace: https://knapsackpro.com/perma/ruby/backtrace-debugging'
76
79
 
80
+ log_current_tests(threads)
81
+
77
82
  threads.each do |thread|
78
83
  puts
79
84
  if thread == Thread.main
@@ -92,6 +97,10 @@ module KnapsackPro
92
97
 
93
98
  $stdout.flush
94
99
  end
100
+
101
+ def log_current_tests(threads)
102
+ # implement in a child class if you need to log more info
103
+ end
95
104
  end
96
105
  end
97
106
  end
@@ -117,6 +117,31 @@ module KnapsackPro
117
117
 
118
118
  private
119
119
 
120
+ def post_trap_signals
121
+ RSpec.world.wants_to_quit = true
122
+
123
+ log_current_batch_rspec_command
124
+ end
125
+
126
+ def log_current_tests(threads)
127
+ threads.each do |thread|
128
+ next unless thread.backtrace
129
+
130
+ spec_file_lines = thread.backtrace.select { |line| line.include?('_spec.rb') }
131
+ next if spec_file_lines.empty?
132
+
133
+ puts
134
+ if thread == Thread.main
135
+ puts "Running specs in the main thread:"
136
+ else
137
+ puts "Non-main thread inspect: #{thread.inspect}"
138
+ puts "Running specs in non-main thread:"
139
+ end
140
+ puts spec_file_lines.join("\n")
141
+ puts
142
+ end
143
+ end
144
+
120
145
  def pre_run_setup
121
146
  ENV['KNAPSACK_PRO_QUEUE_RECORDING_ENABLED'] = 'true'
122
147
  ENV['KNAPSACK_PRO_QUEUE_ID'] = KnapsackPro::Config::EnvGenerator.set_queue_id
@@ -161,6 +186,21 @@ module KnapsackPro
161
186
  test_file_paths
162
187
  end
163
188
 
189
+ def log_current_batch_rspec_command
190
+ test_file_paths = @queue.current_batch&.test_file_paths
191
+ return unless test_file_paths
192
+
193
+ puts
194
+ puts '=' * 80
195
+
196
+ order_option = @adapter_class.order_option(@cli_args)
197
+ printable_args = @rspec_pure.args_with_seed_option_added_when_viable(order_option, @rspec_runner.knapsack__seed, @cli_args)
198
+ messages = @rspec_pure.rspec_command(printable_args, test_file_paths, :batch_finished)
199
+ messages.each do |message|
200
+ puts message
201
+ end
202
+ end
203
+
164
204
  def log_rspec_batch_command(test_file_paths)
165
205
  order_option = @adapter_class.order_option(@cli_args)
166
206
  printable_args = @rspec_pure.args_with_seed_option_added_when_viable(order_option, @rspec_runner.knapsack__seed, @cli_args)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module KnapsackPro
4
- VERSION = '7.13.0'
4
+ VERSION = '7.14.0'
5
5
  end
@@ -1403,12 +1403,16 @@ describe "#{KnapsackPro::Runners::Queue::RSpecRunner} - Integration tests", :cle
1403
1403
  OUTPUT
1404
1404
  )
1405
1405
 
1406
+ expect(actual.stdout).to include('To retry the last batch of tests fetched from the Queue API, please run the following command on your machine:')
1407
+ expect(actual.stdout).to include('bundle exec rspec --format documentation --default-path spec_integration "spec_integration/b_spec.rb" "spec_integration/c_spec.rb"')
1406
1408
 
1407
1409
  expect(actual.stdout).to include('Use the following backtrace(s) to find the line of code that got stuck if the CI node hung and terminated your tests.')
1410
+ expect(actual.stdout).to include('Running specs in the main thread:')
1411
+ expect(actual.stdout).to include('Running specs in non-main thread:')
1408
1412
  expect(actual.stdout).to include('Main thread backtrace:')
1409
- expect(actual.stdout).to match(/spec_integration\/b_spec\.rb:7:in .*kill/)
1413
+ expect(actual.stdout.scan(/spec_integration\/b_spec\.rb:7:in .*kill/).size).to eq 2
1410
1414
  expect(actual.stdout).to include('Non-main thread backtrace:')
1411
- expect(actual.stdout).to match(/spec_integration\/a_spec\.rb:6:in .*sleep/)
1415
+ expect(actual.stdout.scan(/spec_integration\/a_spec\.rb:6:in .*sleep/).size).to eq 2
1412
1416
 
1413
1417
 
1414
1418
  expect(actual.exit_code).to eq 1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knapsack_pro
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.13.0
4
+ version: 7.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ArturT
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-11 00:00:00.000000000 Z
11
+ date: 2025-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -433,7 +433,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
433
433
  - !ruby/object:Gem::Version
434
434
  version: '0'
435
435
  requirements: []
436
- rubygems_version: 3.5.16
436
+ rubygems_version: 3.5.11
437
437
  signing_key:
438
438
  specification_version: 4
439
439
  summary: Knapsack Pro splits tests across parallel CI nodes and ensures each parallel