From 62d5f283adb94830b3287ab6b5173c9720d380de Mon Sep 17 00:00:00 2001 From: Ian Ker-Seymer Date: Wed, 1 Apr 2026 23:26:14 -0400 Subject: [PATCH] Exit 0 when queue is exhausted after lazy-load boot In lazy-load mode, the queue.exhausted? check runs before the app boots. Slow workers can finish booting after the queue has been fully drained by faster workers -- at that point Minitest.run [] finds nothing to run and returns false, causing the worker to exit 1. Add a second exhausted? check immediately before Minitest.run []. If the queue is already drained at that point, print the existing "All tests were ran already" message and exit 0 instead of propagating a false failure to Buildkite. Bump version to 0.86.0. --- ruby/Gemfile.lock | 2 +- ruby/lib/ci/queue/version.rb | 2 +- ruby/lib/minitest/queue/runner.rb | 9 +++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ruby/Gemfile.lock b/ruby/Gemfile.lock index 3493d939..b7883774 100644 --- a/ruby/Gemfile.lock +++ b/ruby/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - ci-queue (0.85.0) + ci-queue (0.86.0) logger GEM diff --git a/ruby/lib/ci/queue/version.rb b/ruby/lib/ci/queue/version.rb index c95adaa7..90519e6b 100644 --- a/ruby/lib/ci/queue/version.rb +++ b/ruby/lib/ci/queue/version.rb @@ -2,7 +2,7 @@ module CI module Queue - VERSION = '0.85.0' + VERSION = '0.86.0' DEV_SCRIPTS_ROOT = ::File.expand_path('../../../../../redis', __FILE__) RELEASE_SCRIPTS_ROOT = ::File.expand_path('../redis', __FILE__) end diff --git a/ruby/lib/minitest/queue/runner.rb b/ruby/lib/minitest/queue/runner.rb index 8be7551d..5f924ecd 100644 --- a/ruby/lib/minitest/queue/runner.rb +++ b/ruby/lib/minitest/queue/runner.rb @@ -118,6 +118,15 @@ def run_command # minitest/autorun's at_exit hook, which may not be registered since # test files haven't been loaded yet. exit! prevents double-execution # if minitest/autorun was loaded by the leader during streaming. + # + # Re-check exhausted? after booting: slow workers may arrive after the queue + # has been fully drained by faster workers. In that case exit cleanly (0) + # rather than letting Minitest return false for a 0-test run. + if queue.rescue_connection_errors { queue.exhausted? } + puts green('All tests were ran already') + verify_reporters!(reporters) + exit!(0) + end passed = Minitest.run [] verify_reporters!(reporters) exit!(passed ? 0 : 1)