This commit is contained in:
rob
2026-12-02 15:44:24 +00:00
parent cbcc9fa4b5
commit 8d01d02cc0
17 changed files with 125 additions and 35 deletions
@@ -0,0 +1,4 @@
#!/bin/sh
set -eu
repo=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
exec python3 "$repo/.bortstack/create-chatgpt-snapshot.py" "$repo"
@@ -1,46 +0,0 @@
#!/usr/bin/env python3
"""Provision only this generated project's local Compose development account."""
import json
import os
import subprocess
import sys
from pathlib import Path
project = os.environ.get("BORTSTACK_COMPOSE_PROJECT", "")
compose_file = Path(os.environ.get("BORTSTACK_COMPOSE_FILE", ""))
secret_file = Path(os.environ.get("BORTSTACK_CREDENTIALS_FILE", ""))
if not project.startswith("bortstack-") or not compose_file.is_file() or not secret_file.is_file():
raise SystemExit("local Compose project and temporary credentials are required")
if os.environ.get("APP_ENV", "development") != "development":
raise SystemExit("refusing account provisioning outside development")
secret = json.loads(secret_file.read_text(encoding="utf-8"))
if not secret.get("BORTSTACK_TEST_EMAIL") or not secret.get("BORTSTACK_TEST_PASSWORD"):
raise SystemExit("missing local test credentials")
base = ["docker", "compose", "--project-name", project, "--file", str(compose_file)]
if subprocess.run(base + ["exec", "-T", "api", "flask", "--app", "api.py", "db", "upgrade"], check=False).returncode:
raise SystemExit("local development migration failed")
code = '''
import json, sys
from datetime import datetime
from sqlalchemy import func
from settings import app, db
from models.user import User, normalize_email
values = json.load(sys.stdin)
email = normalize_email(values["BORTSTACK_TEST_EMAIL"])
password = values["BORTSTACK_TEST_PASSWORD"]
if len(password) < 8:
raise SystemExit("test password must have at least eight characters")
with app.app_context():
existing = User.query.filter(func.lower(User.email) == email).first()
if existing:
if not existing.check_password(password) or existing.email_verified_at is None:
raise SystemExit("test account exists with different credentials or is unverified; no account was changed")
else:
user = User(email=email, username="Local Test User", email_verified_at=datetime.utcnow())
user.set_password(password)
db.session.add(user)
db.session.commit()
'''
result = subprocess.run(base + ["exec", "-T", "api", "python", "-c", code],
input=json.dumps(secret), text=True, check=False)
sys.exit(result.returncode)
@@ -1,8 +0,0 @@
#!/bin/sh
set -eu
root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
if [ ! -d "$root/react/node_modules" ]; then
echo 'integration tests unavailable: install react/node_modules first' >&2
exit 3
fi
(cd "$root/react" && npm run test:e2e)
@@ -1,9 +0,0 @@
#!/bin/sh
set -eu
root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
if [ ! -x "$root/api/.venv/bin/python" ] || [ ! -d "$root/react/node_modules" ]; then
echo 'unit tests unavailable: install api/.venv and react/node_modules first' >&2
exit 3
fi
(cd "$root/api" && APP_ENV=testing .venv/bin/python -m pytest -c pytest.ini tests)
(cd "$root/react" && npm test -- --run)