@biffo/cli 0.378.0 → 0.379.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@biffo/cli",
3
- "version": "0.378.0",
3
+ "version": "0.379.0",
4
4
  "description": "Biffo project scaffolding CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -464,10 +464,9 @@ if ! psql_admin -c 'SELECT 1' >/dev/null 2>&1; then
464
464
  say "Start one and re-run, or set BIFFO_PG_HOST / BIFFO_PG_PORT."
465
465
  exit 1
466
466
  fi
467
- if docker ps -a --format '{{.Names}}' | grep -qx "$CONTAINER"; then
468
- say "starting existing container $CONTAINER"
469
- docker start "$CONTAINER" >/dev/null
470
- else
467
+ # Create a fresh labelled container. The one `docker run` path, used both for
468
+ # a first start and for the self-heal recreate below.
469
+ create_container() {
471
470
  say "creating container $CONTAINER ($IMAGE) on port $PORT"
472
471
  # The label is what makes this container reapable by a property rather than
473
472
  # by the name it happens to carry (#1383). The name prefix still works and
@@ -480,18 +479,46 @@ if ! psql_admin -c 'SELECT 1' >/dev/null 2>&1; then
480
479
  docker run -d --name "$CONTAINER" --label biffo.ephemeral=1 \
481
480
  --label "biffo.checkout=$REPO_ROOT" \
482
481
  -e POSTGRES_PASSWORD="$PASS" -p "$PORT:5432" "$IMAGE" >/dev/null
483
- fi
482
+ }
484
483
  # Polled, not slept: a cold image pull and a warm restart differ by an order of
485
- # magnitude, and one fixed sleep is wrong for both.
486
- _waited=0
487
- until psql_admin -c 'SELECT 1' >/dev/null 2>&1; do
488
- _waited=$((_waited + 1))
489
- if [ "$_waited" -gt 90 ]; then
490
- say "Postgres did not become ready in 90s"
484
+ # magnitude, and one fixed sleep is wrong for both. Returns 1 on timeout.
485
+ wait_ready() {
486
+ _waited=0
487
+ until psql_admin -c 'SELECT 1' >/dev/null 2>&1; do
488
+ _waited=$((_waited + 1))
489
+ if [ "$_waited" -gt "${BIFFO_PG_READY_SECS:-90}" ]; then
490
+ say "Postgres did not become ready in ${BIFFO_PG_READY_SECS:-90}s"
491
+ return 1
492
+ fi
493
+ sleep 1
494
+ done
495
+ return 0
496
+ }
497
+ _existed=0
498
+ if docker ps -a --format '{{.Names}}' | grep -qx "$CONTAINER"; then
499
+ _existed=1
500
+ say "starting existing container $CONTAINER"
501
+ docker start "$CONTAINER" >/dev/null
502
+ else
503
+ create_container
504
+ fi
505
+ if ! wait_ready; then
506
+ say "logs of $CONTAINER (last 50 lines):"
507
+ docker logs --tail 50 "$CONTAINER" >&2 || true
508
+ if [ "$_existed" -eq 0 ]; then
491
509
  exit 1
492
510
  fi
493
- sleep 1
494
- done
511
+ # Self-heal, once: a container that pre-existed and will not come up is
512
+ # stale or corrupt. Remove it with its volume and recreate it the same way.
513
+ say "existing container $CONTAINER never became ready; removing and recreating it once"
514
+ docker rm -f -v "$CONTAINER" >/dev/null 2>&1 || true
515
+ create_container
516
+ if ! wait_ready; then
517
+ say "recreated container $CONTAINER also failed; logs (last 50 lines):"
518
+ docker logs --tail 50 "$CONTAINER" >&2 || true
519
+ exit 1
520
+ fi
521
+ fi
495
522
  say "Postgres ready after ${_waited}s"
496
523
  fi
497
524
 
package/scripts/verify.sh CHANGED
@@ -1543,6 +1543,7 @@ fi
1543
1543
  # sees the change before it is live.
1544
1544
  [ -f scripts/rerun-on-runner-loss.test.sh ] &&
1545
1545
  run_check rerun-on-runner-loss sh scripts/rerun-on-runner-loss.test.sh
1546
+ [ -f services/api/tests/instance/pg-test-db-self-heal.test.sh ] && run_check pg-test-db-self-heal sh services/api/tests/instance/pg-test-db-self-heal.test.sh
1546
1547
 
1547
1548
  # #2166: red/green + issue routing for shared-sync-report.yml (0.7s).
1548
1549
  [ -f scripts/shared-sync-report.test.sh ] &&