kettle-dev 2.1.0 → 2.2.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.
@@ -285,8 +285,13 @@ module Kettle
285
285
  total = workflows.size
286
286
  abort("No GitHub workflows found under .github/workflows; aborting.") if total.zero?
287
287
 
288
+ head_sha = Kettle::Dev::CIHelpers.current_head_sha
289
+ abort("Could not determine local HEAD SHA for GitHub Actions checks.") unless head_sha && !head_sha.empty?
290
+
288
291
  passed = {}
292
+ started = {}
289
293
  puts "Ensuring GitHub Actions workflows pass on #{branch} (#{owner}/#{repo}) via remote '#{gh_remote}'"
294
+ puts "Waiting for GitHub Actions runs to start for HEAD #{head_sha[0, 12]}."
290
295
  pbar = if defined?(ProgressBar)
291
296
  ProgressBar.create(title: "CI", total: total, format: "%t %b %c/%C", length: 30)
292
297
  end
@@ -300,11 +305,15 @@ module Kettle
300
305
  end
301
306
  end
302
307
  sleep((initial_sleep && initial_sleep >= 0) ? initial_sleep : 3)
308
+ start_timeout = github_start_timeout
309
+ poll_interval = github_poll_interval
310
+ start_deadline = monotonic_time + start_timeout
303
311
  idx = 0
304
312
  loop do
305
313
  wf = workflows[idx]
306
- run = Kettle::Dev::CIHelpers.latest_run(owner: owner, repo: repo, workflow_file: wf, branch: branch)
314
+ run = Kettle::Dev::CIHelpers.latest_run(owner: owner, repo: repo, workflow_file: wf, branch: branch, require_head: true, head_sha: head_sha)
307
315
  if run
316
+ started[wf] = true
308
317
  if Kettle::Dev::CIHelpers.success?(run)
309
318
  unless passed[wf]
310
319
  passed[wf] = true
@@ -317,9 +326,14 @@ module Kettle
317
326
  end
318
327
  end
319
328
  break if passed.size == total
329
+ if started.size < total && monotonic_time >= start_deadline
330
+ missing = (workflows - started.keys).join(", ")
331
+ puts
332
+ abort("Timed out after #{start_timeout}s waiting for GitHub Actions workflows to start for HEAD #{head_sha[0, 12]}: #{missing}. Confirm GitHub Actions started, then restart this tool from CI validation with: #{restart_hint}")
333
+ end
320
334
 
321
335
  idx = (idx + 1) % total
322
- sleep(1)
336
+ sleep(poll_interval)
323
337
  end
324
338
  pbar&.finish unless pbar&.finished?
325
339
  puts "\nAll GitHub workflows passing (#{passed.size}/#{total})."
@@ -327,6 +341,31 @@ module Kettle
327
341
  end
328
342
  module_function :monitor_github_internal!
329
343
 
344
+ def monotonic_time
345
+ Process.clock_gettime(Process::CLOCK_MONOTONIC)
346
+ end
347
+ module_function :monotonic_time
348
+
349
+ def github_start_timeout
350
+ seconds = begin
351
+ Integer(ENV["K_RELEASE_CI_START_TIMEOUT"])
352
+ rescue
353
+ nil
354
+ end
355
+ (seconds && seconds >= 0) ? seconds : 120
356
+ end
357
+ module_function :github_start_timeout
358
+
359
+ def github_poll_interval
360
+ seconds = begin
361
+ Float(ENV["K_RELEASE_CI_POLL_INTERVAL"])
362
+ rescue
363
+ nil
364
+ end
365
+ (seconds && seconds >= 0) ? seconds : 1
366
+ end
367
+ module_function :github_poll_interval
368
+
330
369
  def monitor_gitlab_internal!(restart_hint:)
331
370
  root = Kettle::Dev::CIHelpers.project_root
332
371
  gitlab_ci = File.exist?(File.join(root, ".gitlab-ci.yml"))