forked from molecule-ai/molecule-core
Last sweep of code-review items before merging PR #5. ## _lib.sh cleanup - Removed unused e2e_register and e2e_heartbeat helpers (dead code — no caller ever invoked them) - Standardized on $BASE variable set via : "${BASE:=...}" so every script uses one name (was mixed $BASE / $e2e_base) - e2e_extract_token now writes stderr warnings on JSON parse failure or missing auth_token, instead of silently returning empty. Previous behavior made downstream "missing workspace auth token" 401s much harder to diagnose ## Script cleanup - test_api.sh, test_comprehensive_e2e.sh, test_activity_e2e.sh all drop the redundant `e2e_base + BASE="$e2e_base"` aliasing; sourcing _lib.sh sets BASE via : "${BASE:=...}" default ## CI hardening (.github/workflows/ci.yml) - Postgres credentials now match .env.example (dev:dev — was molecule:molecule, caused confusion for local repros) - Added Go module cache via actions/setup-go cache:true + cache-dependency-path: platform/go.sum. ~30s cold-run improvement - New pre-E2E step asserts migrations actually ran by checking for the 'workspaces' table. Catches future migration-author mistakes before they surface as obscure E2E failures ## Follow-up issue Filed Molecule-AI/molecule-monorepo#6 for the deterministic token- mint admin endpoint. PR #5 uses an empirical "beat the container" race (5/5 wins in benchmarks); issue #6 tracks the real fix for any future CI load that invalidates the assumption. ## Verification - bash tests/e2e/test_api.sh -> 62/62 - bash tests/e2e/test_comprehensive_e2e.sh -> 67/67 - python3 -c "import yaml; yaml.safe_load(open('.github/workflows/ci.yml'))" -> ok ## Operational note Hourly PR-triage + issue-pickup cron scheduled this session (job id 0328bc8f, fires at :17 past each hour). Runtime reports it as session-only despite durable:true — re-invoke via /loop or CronCreate in a fresh session if needed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
46 lines
1.5 KiB
Bash
Executable File
46 lines
1.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Common E2E helpers. Source this from every tests/e2e/*.sh.
|
|
#
|
|
# Usage:
|
|
# source "$(dirname "$0")/_lib.sh"
|
|
# e2e_cleanup_all_workspaces # call at top of script
|
|
# TOKEN=$(echo "$register_response" | e2e_extract_token)
|
|
#
|
|
# BASE defaults to http://localhost:8080. Set it before sourcing to override.
|
|
|
|
: "${BASE:=http://localhost:8080}"
|
|
export BASE
|
|
|
|
# Emit the auth_token from a /registry/register response on stdout.
|
|
# Logs a warning to stderr when the JSON parse fails or the token is
|
|
# missing — silent empty strings masked real failures as the
|
|
# downstream "missing workspace auth token" 401. Return value is
|
|
# still empty-string-on-failure so grandfather-path callers work.
|
|
e2e_extract_token() {
|
|
python3 -c "
|
|
import sys, json
|
|
try:
|
|
data = json.load(sys.stdin)
|
|
except Exception as e:
|
|
sys.stderr.write(f'e2e_extract_token: invalid JSON response ({e})\n')
|
|
print('')
|
|
sys.exit(0)
|
|
tok = data.get('auth_token', '')
|
|
if not tok:
|
|
sys.stderr.write('e2e_extract_token: response contained no auth_token field\n')
|
|
print(tok)
|
|
"
|
|
}
|
|
|
|
# Delete every workspace currently on the platform. Use at the top of a
|
|
# script so count-based assertions are reproducible across runs.
|
|
e2e_cleanup_all_workspaces() {
|
|
for _wid in $(curl -s "$BASE/workspaces" | python3 -c "import json,sys
|
|
try:
|
|
[print(w['id']) for w in json.load(sys.stdin)]
|
|
except Exception:
|
|
pass" 2>/dev/null); do
|
|
curl -s -X DELETE "$BASE/workspaces/$_wid?confirm=true" > /dev/null || true
|
|
done
|
|
}
|