@nbardy/oompa 0.4.5 → 0.4.6
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.
|
@@ -376,8 +376,16 @@
|
|
|
376
376
|
wt-path (str project-root "/" wt-dir)]
|
|
377
377
|
|
|
378
378
|
(try
|
|
379
|
-
;;
|
|
380
|
-
(process/sh ["git" "worktree" "
|
|
379
|
+
;; Clean stale worktree/branch from previous failed runs before creating
|
|
380
|
+
(process/sh ["git" "worktree" "remove" wt-dir "--force"] {:dir project-root})
|
|
381
|
+
(process/sh ["git" "branch" "-D" wt-branch] {:dir project-root})
|
|
382
|
+
|
|
383
|
+
;; Setup worktree (in project root)
|
|
384
|
+
(let [wt-result (process/sh ["git" "worktree" "add" wt-dir "-b" wt-branch]
|
|
385
|
+
{:dir project-root :out :string :err :string})]
|
|
386
|
+
(when-not (zero? (:exit wt-result))
|
|
387
|
+
(throw (ex-info (str "Failed to create worktree: " (:err wt-result))
|
|
388
|
+
{:dir wt-dir :branch wt-branch}))))
|
|
381
389
|
|
|
382
390
|
;; Build context
|
|
383
391
|
(let [context (build-context)
|
|
@@ -411,8 +419,9 @@
|
|
|
411
419
|
{:status :continue})))))
|
|
412
420
|
|
|
413
421
|
(finally
|
|
414
|
-
;; Cleanup worktree (in project root)
|
|
415
|
-
(process/sh ["git" "worktree" "remove" wt-dir "--force"] {:dir project-root})
|
|
422
|
+
;; Cleanup worktree and branch (in project root)
|
|
423
|
+
(process/sh ["git" "worktree" "remove" wt-dir "--force"] {:dir project-root})
|
|
424
|
+
(process/sh ["git" "branch" "-D" wt-branch] {:dir project-root})))))
|
|
416
425
|
|
|
417
426
|
;; =============================================================================
|
|
418
427
|
;; Worker Loop
|
|
@@ -420,6 +429,7 @@
|
|
|
420
429
|
|
|
421
430
|
(def ^:private max-wait-for-tasks 60)
|
|
422
431
|
(def ^:private wait-poll-interval 5)
|
|
432
|
+
(def ^:private max-consecutive-errors 3)
|
|
423
433
|
|
|
424
434
|
(defn- wait-for-tasks!
|
|
425
435
|
"Wait up to 60s for pending/current tasks to appear. Used for backpressure
|
|
@@ -456,7 +466,8 @@
|
|
|
456
466
|
(wait-for-tasks! id))
|
|
457
467
|
|
|
458
468
|
(loop [iter 1
|
|
459
|
-
completed 0
|
|
469
|
+
completed 0
|
|
470
|
+
consec-errors 0]
|
|
460
471
|
(if (> iter iterations)
|
|
461
472
|
(do
|
|
462
473
|
(println (format "[%s] Completed %d iterations" id completed))
|
|
@@ -470,12 +481,18 @@
|
|
|
470
481
|
(assoc worker :completed iter :status :done))
|
|
471
482
|
|
|
472
483
|
:error
|
|
473
|
-
(
|
|
474
|
-
(
|
|
475
|
-
|
|
484
|
+
(let [errors (inc consec-errors)]
|
|
485
|
+
(if (>= errors max-consecutive-errors)
|
|
486
|
+
(do
|
|
487
|
+
(println (format "[%s] %d consecutive errors, stopping worker" id errors))
|
|
488
|
+
(assoc worker :completed completed :status :error))
|
|
489
|
+
(do
|
|
490
|
+
(println (format "[%s] Error at iteration %d/%d (%d/%d), continuing..."
|
|
491
|
+
id iter iterations errors max-consecutive-errors))
|
|
492
|
+
(recur (inc iter) completed errors))))
|
|
476
493
|
|
|
477
494
|
:continue
|
|
478
|
-
(recur (inc iter) (inc completed))))))))
|
|
495
|
+
(recur (inc iter) (inc completed) 0))))))))
|
|
479
496
|
|
|
480
497
|
;; =============================================================================
|
|
481
498
|
;; Multi-Worker Execution
|