ci-queue 0.43.0 → 0.45.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: 9fafefb68f5e00faba6e1c19944c0289bd0e7c5ca4d67090605fea402f2b04f3
4
- data.tar.gz: fe85dc8a004f45a54203eac3e4294e5348bca9d8920b70ad2427fed9f5f26776
3
+ metadata.gz: 539eadbd8b17fe11ab9904ec15717ac4e5c0f5259afe755c41ab6717ca695d31
4
+ data.tar.gz: 7cbb23ab1c89433ac9087b69fbfd908594779051d13658a3cd60222dc9621286
5
5
  SHA512:
6
- metadata.gz: a190ef07194b9cbb9c880de74abd9e54ede4d3e52480e26ba20c16a80720fafb66ce5933bc21df4213e7cefc9abb5f3893b75e46fb7e8327ee6e11b8a5e26de4
7
- data.tar.gz: 5b3a127d41fde0f8094878e8cfcd088eb2d1a32fc86798b98adafbf06caa19e201631899fa4aec9c0afa8d8a9174215d529dd1dfdf637e4e9122dfb93f99d741
6
+ metadata.gz: 4e42b44a3c0bb756f941bd7b4204719ad539db163c43c59dff470a78c334e7e166e71966db5ba553fd131b329b92c2febdbc705c5579872201d0fcd1d20248f6
7
+ data.tar.gz: 2e827a12d0ec96ca85bdff6f829a805b4eeb5fe4af26fd549b28f56f69649d3de6e17f7fbc60185d01b5c1ed62a77e7aea19f1a80efc50569e64899aaaa3cb2b
@@ -118,6 +118,14 @@ module CI
118
118
  end.inject(:+)
119
119
  end
120
120
 
121
+ def remaining
122
+ redis.llen(key('queue'))
123
+ end
124
+
125
+ def running
126
+ redis.zcard(key('running'))
127
+ end
128
+
121
129
  def to_a
122
130
  redis.multi do |transaction|
123
131
  transaction.lrange(key('queue'), 0, -1)
@@ -78,6 +78,14 @@ module CI
78
78
  @queue.size
79
79
  end
80
80
 
81
+ def remaining
82
+ @queue.size
83
+ end
84
+
85
+ def running
86
+ 1
87
+ end
88
+
81
89
  def poll
82
90
  while !@shutdown && config.circuit_breakers.none?(&:open?) && !max_test_failed? && test = @queue.shift
83
91
  yield index.fetch(test)
@@ -2,7 +2,7 @@
2
2
 
3
3
  module CI
4
4
  module Queue
5
- VERSION = '0.43.0'
5
+ VERSION = '0.45.0'
6
6
  DEV_SCRIPTS_ROOT = ::File.expand_path('../../../../../redis', __FILE__)
7
7
  RELEASE_SCRIPTS_ROOT = ::File.expand_path('../redis', __FILE__)
8
8
  end
@@ -86,8 +86,23 @@ module Minitest
86
86
  if queue.rescue_connection_errors { queue.exhausted? }
87
87
  puts green('All tests were ran already')
88
88
  else
89
- load_tests
90
- populate_queue
89
+ # If the job gets (automatically) retried and there are still workers running but not many tests left
90
+ # in the queue, we assume by the time the application is booted the queue is empty and it's faster to no-op.
91
+ if retry?
92
+ remaining = queue.rescue_connection_errors { queue.remaining }.to_i
93
+ running = queue.rescue_connection_errors { queue.running }.to_i
94
+
95
+ puts "#{remaining} tests left and #{running} workers running."
96
+ if remaining <= running
97
+ puts green("Queue almost empty, exiting early...")
98
+ else
99
+ load_tests
100
+ populate_queue
101
+ end
102
+ else
103
+ load_tests
104
+ populate_queue
105
+ end
91
106
  end
92
107
 
93
108
  at_exit {
@@ -107,6 +107,7 @@ module Minitest
107
107
  end
108
108
 
109
109
  module Queue
110
+ include ::CI::Queue::OutputHelpers
110
111
  attr_writer :run_command_formatter, :project_root
111
112
 
112
113
  def run_command_formatter
@@ -260,6 +261,11 @@ module Minitest
260
261
  end
261
262
  end
262
263
  queue.stop_heartbeat!
264
+ rescue Errno::EPIPE
265
+ # This happens when the heartbeat process dies
266
+ reopen_previous_step
267
+ puts red("The heartbeat process died. This worker is exiting early.")
268
+ exit!(41)
263
269
  end
264
270
  end
265
271
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ci-queue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.43.0
4
+ version: 0.45.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jean Boussier
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-01-30 00:00:00.000000000 Z
11
+ date: 2024-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler