@calltelemetry/fmix 2.4.3 → 2.4.4
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/bin/fmix +186 -21
- package/package.json +3 -3
package/bin/fmix
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
# ./fmix cache explain --worktree <path> --cache-base <N.N.N-stable>
|
|
12
12
|
# ./fmix cache verify [--key <16-hex-template-key>]
|
|
13
13
|
# # seed publish is explicit clean-stable-only maintenance; cache explain is read-only
|
|
14
|
+
# ./fmix ensure
|
|
14
15
|
# ./fmix doctor
|
|
15
16
|
# ./fmix status
|
|
16
17
|
# ./fmix timing [--limit N] [--worktree <path>]
|
|
@@ -23,7 +24,7 @@ set -uo pipefail
|
|
|
23
24
|
# ---------------------------------------------------------------------------
|
|
24
25
|
# Constants & config
|
|
25
26
|
# ---------------------------------------------------------------------------
|
|
26
|
-
FMIX_VERSION="2.4.
|
|
27
|
+
FMIX_VERSION="2.4.4"
|
|
27
28
|
FMIX_HOME="${FMIX_HOME:-${HOME}/.ct-fmix}"
|
|
28
29
|
FMIX_OS="$(uname -s)"
|
|
29
30
|
FMIX_ARCH="$(uname -m)"
|
|
@@ -104,6 +105,10 @@ DB_USER="${FMIX_DB_USER:-calltelemetry}"
|
|
|
104
105
|
DB_PASSWORD="${FMIX_DB_PASSWORD:-calltelemetry_dev_password}"
|
|
105
106
|
NATS_HOST="${FMIX_NATS_HOST:-localhost}"
|
|
106
107
|
NATS_PORT="${FMIX_NATS_PORT:-4222}"
|
|
108
|
+
FMIX_INFRA_PROJECT="${FMIX_INFRA_PROJECT:-ct-infra}"
|
|
109
|
+
FMIX_INFRA_SCHEMA="1"
|
|
110
|
+
FMIX_ENSURE="${FMIX_ENSURE:-1}"
|
|
111
|
+
FMIX_ENSURE_TIMEOUT="${FMIX_ENSURE_TIMEOUT:-90}"
|
|
107
112
|
|
|
108
113
|
# Fixed dev constant SECRET_KEY_BASE (64 hex chars — only used in test env)
|
|
109
114
|
SECRET_KEY_BASE="${FMIX_SECRET_KEY_BASE:-dev0000000000000000000000000000000000000000000000000000000000000001}"
|
|
@@ -4085,22 +4090,7 @@ fmix_preflight() {
|
|
|
4085
4090
|
esac
|
|
4086
4091
|
done
|
|
4087
4092
|
|
|
4088
|
-
|
|
4089
|
-
if ! nc -z "$DB_HOST" "$DB_PORT" 2>/dev/null; then
|
|
4090
|
-
fmix_error "Postgres not reachable at $DB_HOST:$DB_PORT."
|
|
4091
|
-
fmix_error "Run: ./infra.sh up (from the monorepo root)"
|
|
4092
|
-
fail=1
|
|
4093
|
-
fi
|
|
4094
|
-
|
|
4095
|
-
# NATS TCP check (warn only — tests stub NATS)
|
|
4096
|
-
if ! nc -z "$NATS_HOST" "$NATS_PORT" 2>/dev/null; then
|
|
4097
|
-
fmix_warn "NATS not reachable at $NATS_HOST:$NATS_PORT."
|
|
4098
|
-
fmix_warn "Run: ./infra.sh up — some tests may fail without NATS."
|
|
4099
|
-
fi
|
|
4100
|
-
|
|
4101
|
-
# psql availability check
|
|
4102
|
-
if ! fmix_control_psql 5 -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d postgres -c "SELECT 1" >/dev/null 2>&1; then
|
|
4103
|
-
fmix_error "Cannot connect to postgres as user '$DB_USER'. Check DB credentials or run './infra.sh up'."
|
|
4093
|
+
if ! fmix_ensure_infra; then
|
|
4104
4094
|
fail=1
|
|
4105
4095
|
fi
|
|
4106
4096
|
|
|
@@ -9088,6 +9078,176 @@ cmd_task() {
|
|
|
9088
9078
|
return "$task_rc"
|
|
9089
9079
|
}
|
|
9090
9080
|
|
|
9081
|
+
# ---------------------------------------------------------------------------
|
|
9082
|
+
# Shared postgres + NATS (one host-wide ct-infra plane)
|
|
9083
|
+
# ---------------------------------------------------------------------------
|
|
9084
|
+
|
|
9085
|
+
fmix_infra_postgres_ready() {
|
|
9086
|
+
nc -z "$DB_HOST" "$DB_PORT" 2>/dev/null \
|
|
9087
|
+
&& fmix_control_psql 5 -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d postgres -c "SELECT 1" >/dev/null 2>&1
|
|
9088
|
+
}
|
|
9089
|
+
|
|
9090
|
+
fmix_infra_nats_ready() {
|
|
9091
|
+
nc -z "$NATS_HOST" "$NATS_PORT" 2>/dev/null
|
|
9092
|
+
}
|
|
9093
|
+
|
|
9094
|
+
fmix_infra_ready() {
|
|
9095
|
+
fmix_infra_postgres_ready && fmix_infra_nats_ready
|
|
9096
|
+
}
|
|
9097
|
+
|
|
9098
|
+
fmix_docker_usable() {
|
|
9099
|
+
command -v docker >/dev/null 2>&1 && docker info >/dev/null 2>&1
|
|
9100
|
+
}
|
|
9101
|
+
|
|
9102
|
+
fmix_infra_host_is_local() {
|
|
9103
|
+
case "$DB_HOST" in
|
|
9104
|
+
localhost|127.0.0.1|::1) return 0 ;;
|
|
9105
|
+
*) return 1 ;;
|
|
9106
|
+
esac
|
|
9107
|
+
}
|
|
9108
|
+
|
|
9109
|
+
fmix_write_ensure_compose() {
|
|
9110
|
+
local dir="$FMIX_HOME/infra"
|
|
9111
|
+
mkdir -p "$dir" || return 1
|
|
9112
|
+
cat >"$dir/nats.conf" <<'NATS'
|
|
9113
|
+
max_payload: 5242880
|
|
9114
|
+
jetstream {
|
|
9115
|
+
store_dir: "/data/jetstream"
|
|
9116
|
+
max_memory_store: 1G
|
|
9117
|
+
max_file_store: 10G
|
|
9118
|
+
}
|
|
9119
|
+
http_port: 8222
|
|
9120
|
+
debug: false
|
|
9121
|
+
trace: false
|
|
9122
|
+
max_connections: 500
|
|
9123
|
+
NATS
|
|
9124
|
+
cat >"$dir/compose-ensure.yml" <<YAML
|
|
9125
|
+
# Written by fmix ensure (schema ${FMIX_INFRA_SCHEMA}). Postgres + NATS only.
|
|
9126
|
+
# Project name ${FMIX_INFRA_PROJECT} matches ai-workspace ./infra.sh so one stack is reused.
|
|
9127
|
+
services:
|
|
9128
|
+
postgres:
|
|
9129
|
+
hostname: postgres
|
|
9130
|
+
image: calltelemetry/postgres:14
|
|
9131
|
+
restart: unless-stopped
|
|
9132
|
+
command:
|
|
9133
|
+
- postgres
|
|
9134
|
+
- -c
|
|
9135
|
+
- max_connections=600
|
|
9136
|
+
- -c
|
|
9137
|
+
- shared_buffers=512MB
|
|
9138
|
+
- -c
|
|
9139
|
+
- work_mem=16MB
|
|
9140
|
+
environment:
|
|
9141
|
+
POSTGRES_USER: ${DB_USER}
|
|
9142
|
+
POSTGRES_PASSWORD: ${DB_PASSWORD}
|
|
9143
|
+
POSTGRES_DB: calltelemetry_dev
|
|
9144
|
+
ports:
|
|
9145
|
+
- "${DB_PORT}:5432"
|
|
9146
|
+
volumes:
|
|
9147
|
+
- ct-pgdata:/var/lib/postgresql/data
|
|
9148
|
+
healthcheck:
|
|
9149
|
+
test: ["CMD-SHELL", "pg_isready -U ${DB_USER} -d calltelemetry_dev"]
|
|
9150
|
+
interval: 5s
|
|
9151
|
+
timeout: 5s
|
|
9152
|
+
retries: 12
|
|
9153
|
+
start_period: 20s
|
|
9154
|
+
nats:
|
|
9155
|
+
hostname: nats
|
|
9156
|
+
image: nats:2.11
|
|
9157
|
+
restart: unless-stopped
|
|
9158
|
+
command: ["-c", "/etc/nats/nats.conf"]
|
|
9159
|
+
ports:
|
|
9160
|
+
- "${NATS_PORT}:4222"
|
|
9161
|
+
- "8222:8222"
|
|
9162
|
+
volumes:
|
|
9163
|
+
- ${dir}/nats.conf:/etc/nats/nats.conf:ro
|
|
9164
|
+
- ct-natsdata:/data
|
|
9165
|
+
volumes:
|
|
9166
|
+
ct-pgdata:
|
|
9167
|
+
ct-natsdata:
|
|
9168
|
+
YAML
|
|
9169
|
+
}
|
|
9170
|
+
|
|
9171
|
+
fmix_start_existing_ct_infra() {
|
|
9172
|
+
local name started=0
|
|
9173
|
+
for name in "${FMIX_INFRA_PROJECT}-postgres-1" "${FMIX_INFRA_PROJECT}-nats-1"; do
|
|
9174
|
+
if docker inspect "$name" >/dev/null 2>&1; then
|
|
9175
|
+
docker start "$name" >/dev/null 2>&1 || true
|
|
9176
|
+
started=1
|
|
9177
|
+
fi
|
|
9178
|
+
done
|
|
9179
|
+
[[ "$started" == "1" ]]
|
|
9180
|
+
}
|
|
9181
|
+
|
|
9182
|
+
fmix_compose_up_ensure() {
|
|
9183
|
+
fmix_write_ensure_compose || return 1
|
|
9184
|
+
docker compose -p "$FMIX_INFRA_PROJECT" -f "$FMIX_HOME/infra/compose-ensure.yml" up -d postgres nats
|
|
9185
|
+
}
|
|
9186
|
+
|
|
9187
|
+
fmix_wait_infra() {
|
|
9188
|
+
local now deadline
|
|
9189
|
+
now="$(fmix_epoch)"
|
|
9190
|
+
deadline=$(( now + FMIX_ENSURE_TIMEOUT ))
|
|
9191
|
+
while (( $(fmix_epoch) < deadline )); do
|
|
9192
|
+
if fmix_infra_ready; then
|
|
9193
|
+
return 0
|
|
9194
|
+
fi
|
|
9195
|
+
sleep 1
|
|
9196
|
+
done
|
|
9197
|
+
return 1
|
|
9198
|
+
}
|
|
9199
|
+
|
|
9200
|
+
fmix_ensure_infra() {
|
|
9201
|
+
if fmix_infra_ready; then
|
|
9202
|
+
echo " [OK] infra ready postgres $DB_HOST:$DB_PORT nats $NATS_HOST:$NATS_PORT"
|
|
9203
|
+
return 0
|
|
9204
|
+
fi
|
|
9205
|
+
|
|
9206
|
+
if [[ "$FMIX_ENSURE" != "1" ]]; then
|
|
9207
|
+
fmix_error "Postgres/NATS not ready at $DB_HOST:$DB_PORT / $NATS_HOST:$NATS_PORT (FMIX_ENSURE=0)."
|
|
9208
|
+
return 1
|
|
9209
|
+
fi
|
|
9210
|
+
|
|
9211
|
+
if ! fmix_infra_host_is_local; then
|
|
9212
|
+
fmix_error "Postgres $DB_HOST:$DB_PORT is not reachable. Remote FMIX_DB_HOST is operator-owned; fmix will not start Docker."
|
|
9213
|
+
return 1
|
|
9214
|
+
fi
|
|
9215
|
+
|
|
9216
|
+
if nc -z "$DB_HOST" "$DB_PORT" 2>/dev/null && ! fmix_infra_postgres_ready; then
|
|
9217
|
+
fmix_error "Port $DB_PORT is occupied but not postgres user '$DB_USER'. Refusing to start a second database."
|
|
9218
|
+
return 1
|
|
9219
|
+
fi
|
|
9220
|
+
|
|
9221
|
+
if ! fmix_docker_usable; then
|
|
9222
|
+
fmix_error "Shared postgres/NATS is down and Docker is not usable. Start OrbStack/Docker, then retry: fmix ensure"
|
|
9223
|
+
return 1
|
|
9224
|
+
fi
|
|
9225
|
+
|
|
9226
|
+
echo " starting shared $FMIX_INFRA_PROJECT (postgres + nats)..."
|
|
9227
|
+
fmix_start_existing_ct_infra || true
|
|
9228
|
+
if fmix_wait_infra; then
|
|
9229
|
+
echo " [OK] infra ready postgres $DB_HOST:$DB_PORT nats $NATS_HOST:$NATS_PORT"
|
|
9230
|
+
return 0
|
|
9231
|
+
fi
|
|
9232
|
+
if ! fmix_compose_up_ensure; then
|
|
9233
|
+
fmix_error "docker compose could not start $FMIX_INFRA_PROJECT postgres/nats"
|
|
9234
|
+
return 1
|
|
9235
|
+
fi
|
|
9236
|
+
if ! fmix_wait_infra; then
|
|
9237
|
+
fmix_error "Shared infra did not become ready within ${FMIX_ENSURE_TIMEOUT}s at $DB_HOST:$DB_PORT / $NATS_HOST:$NATS_PORT"
|
|
9238
|
+
return 1
|
|
9239
|
+
fi
|
|
9240
|
+
echo " [OK] infra ready postgres $DB_HOST:$DB_PORT nats $NATS_HOST:$NATS_PORT"
|
|
9241
|
+
return 0
|
|
9242
|
+
}
|
|
9243
|
+
|
|
9244
|
+
cmd_ensure() {
|
|
9245
|
+
echo "=== fmix ensure ==="
|
|
9246
|
+
echo " target: postgres $DB_HOST:$DB_PORT user=$DB_USER ; nats $NATS_HOST:$NATS_PORT"
|
|
9247
|
+
echo " project: $FMIX_INFRA_PROJECT (one host-wide plane; not a per-branch stack)"
|
|
9248
|
+
fmix_ensure_infra
|
|
9249
|
+
}
|
|
9250
|
+
|
|
9091
9251
|
# ---------------------------------------------------------------------------
|
|
9092
9252
|
# cmd: fmix doctor
|
|
9093
9253
|
# ---------------------------------------------------------------------------
|
|
@@ -9186,7 +9346,7 @@ cmd_doctor() {
|
|
|
9186
9346
|
if nc -z "$DB_HOST" "$DB_PORT" 2>/dev/null; then
|
|
9187
9347
|
echo " [OK] postgres TCP $DB_HOST:$DB_PORT"
|
|
9188
9348
|
else
|
|
9189
|
-
echo " [FAIL] postgres not reachable at $DB_HOST:$DB_PORT — run:
|
|
9349
|
+
echo " [FAIL] postgres not reachable at $DB_HOST:$DB_PORT — run: fmix ensure"
|
|
9190
9350
|
fail=1
|
|
9191
9351
|
fi
|
|
9192
9352
|
|
|
@@ -9217,7 +9377,7 @@ cmd_doctor() {
|
|
|
9217
9377
|
if nc -z "$NATS_HOST" "$NATS_PORT" 2>/dev/null; then
|
|
9218
9378
|
echo " [OK] NATS TCP $NATS_HOST:$NATS_PORT"
|
|
9219
9379
|
else
|
|
9220
|
-
echo " [WARN] NATS not reachable at $NATS_HOST:$NATS_PORT — run:
|
|
9380
|
+
echo " [WARN] NATS not reachable at $NATS_HOST:$NATS_PORT — run: fmix ensure (some tests may fail)"
|
|
9221
9381
|
fi
|
|
9222
9382
|
|
|
9223
9383
|
# Headless Chromium for ChromicPDF-backed reporting suites (API-1184).
|
|
@@ -14234,7 +14394,7 @@ PY
|
|
|
14234
14394
|
st_fail "postgres reachable but auth failed for user=$DB_USER — check FMIX_DB_PASSWORD"
|
|
14235
14395
|
fi
|
|
14236
14396
|
else
|
|
14237
|
-
st_skip "postgres $DB_HOST:$DB_PORT not reachable — OK in bare container or without
|
|
14397
|
+
st_skip "postgres $DB_HOST:$DB_PORT not reachable — OK in bare container or without fmix ensure"
|
|
14238
14398
|
fi
|
|
14239
14399
|
|
|
14240
14400
|
# 8. asdf toolchain (skip in bare container)
|
|
@@ -14509,6 +14669,7 @@ Usage:
|
|
|
14509
14669
|
./fmix seed publish --worktree <path> [--session <id>] --cache-base <N.N.N-stable>
|
|
14510
14670
|
./fmix cache explain --worktree <path> --cache-base <N.N.N-stable>
|
|
14511
14671
|
./fmix cache verify [--key <16-hex-template-key>]
|
|
14672
|
+
./fmix ensure # start or reuse shared postgres + NATS (ct-infra)
|
|
14512
14673
|
./fmix doctor
|
|
14513
14674
|
./fmix status
|
|
14514
14675
|
./fmix timing [--limit N] [--worktree <path>] # phase timings + session fragmentation
|
|
@@ -14573,6 +14734,9 @@ Environment overrides:
|
|
|
14573
14734
|
FMIX_DOPPLER_CONFIG Doppler config for credential fallback (default: dev_personal)
|
|
14574
14735
|
FMIX_SESSION_WARN_THRESHOLD Per-host session count that triggers a gc warning (default: 24)
|
|
14575
14736
|
FMIX_STABLE_BASE Opt-in stable dependency base for fmix test (default: unset)
|
|
14737
|
+
FMIX_ENSURE Set to 0 to skip auto-starting shared postgres/NATS (default: 1)
|
|
14738
|
+
FMIX_ENSURE_TIMEOUT Seconds to wait after starting ct-infra (default: 90)
|
|
14739
|
+
FMIX_INFRA_PROJECT Docker Compose project for shared infra (default: ct-infra)
|
|
14576
14740
|
FMIX_DB_HOST Postgres host (default: localhost)
|
|
14577
14741
|
FMIX_DB_PORT Postgres port (default: 5432)
|
|
14578
14742
|
FMIX_DB_USER Postgres user (default: calltelemetry)
|
|
@@ -14643,6 +14807,7 @@ main() {
|
|
|
14643
14807
|
setup) cmd_setup "$@" ;;
|
|
14644
14808
|
seed) cmd_seed "$@" ;;
|
|
14645
14809
|
cache) cmd_cache "$@" ;;
|
|
14810
|
+
ensure) cmd_ensure "$@" ;;
|
|
14646
14811
|
doctor) cmd_doctor "$@" ;;
|
|
14647
14812
|
status) cmd_status "$@" ;;
|
|
14648
14813
|
timing) cmd_timing "$@" ;;
|
|
@@ -14651,7 +14816,7 @@ main() {
|
|
|
14651
14816
|
self-test) cmd_self_test "$@" ;;
|
|
14652
14817
|
*)
|
|
14653
14818
|
fmix_error "Unknown command: $cmd"
|
|
14654
|
-
fmix_error "Valid commands: test, coverage, task, setup, seed publish, cache explain, cache verify, doctor, status, timing, gc, install, self-test, version, help"
|
|
14819
|
+
fmix_error "Valid commands: test, coverage, task, setup, seed publish, cache explain, cache verify, ensure, doctor, status, timing, gc, install, self-test, version, help"
|
|
14655
14820
|
return 1
|
|
14656
14821
|
;;
|
|
14657
14822
|
esac
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@calltelemetry/fmix",
|
|
3
|
-
"version": "2.4.
|
|
3
|
+
"version": "2.4.4",
|
|
4
4
|
"description": "Verified native FMix runner for CallTelemetry workspaces",
|
|
5
5
|
"bin": {
|
|
6
6
|
"fmix": "bin/fmix"
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"directory": "packages/npm"
|
|
25
25
|
},
|
|
26
26
|
"fmix": {
|
|
27
|
-
"runnerSha256": "
|
|
28
|
-
"sourceTag": "fmix-v2.4.
|
|
27
|
+
"runnerSha256": "e2cbf06d87961a954b87a746e56bcf6bd9400fc299f127b50daac7505696e482",
|
|
28
|
+
"sourceTag": "fmix-v2.4.4"
|
|
29
29
|
}
|
|
30
30
|
}
|