From 8eff78170bf5f979c6d479784c732dd38d8e150e Mon Sep 17 00:00:00 2001 From: teahubxyz Date: Tue, 13 Oct 2026 06:42:56 -0700 Subject: [PATCH] labs/aicharts: live at aicharts., like ventures (#36) The account has no workers.dev subdomain; use TIME_VENTURE_DOMAIN when set. Deploy step fails on its own error (pipefail); smoke waits up to 3 min for the cert. Claude-Session: https://claude.ai/code/session_01VDkN7ukK1kXkqov8FaZxva Co-authored-by: Claude --- .github/time/labs/aicharts/deploy.py | 10 ++++++---- .github/workflows/labs-aicharts.yml | 6 ++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/time/labs/aicharts/deploy.py b/.github/time/labs/aicharts/deploy.py index 93d6c4c..15e32bb 100644 --- a/.github/time/labs/aicharts/deploy.py +++ b/.github/time/labs/aicharts/deploy.py @@ -1,9 +1,10 @@ -"""Deploy the AICharts demo: one Worker (`time-aicharts`), one D1 database, Workers AI, on workers.dev only. +"""Deploy the AICharts demo: one Worker (`time-aicharts`), one D1 database, Workers AI. python3 .github/time/labs/aicharts/deploy.py # prints {url, worker, db, rev} -Reuses cloudflare.py (token, account, database, workers.dev). No DNS and no custom domain. Idempotent: the same -database is reused and the script is replaced in place. +Reuses cloudflare.py. Lives where ventures live: aicharts. when that is set (a Workers custom +domain; Cloudflare adds the record and the cert), the account's workers.dev otherwise. Idempotent: the same database is +reused and the script is replaced in place. """ from __future__ import annotations @@ -41,7 +42,8 @@ def deploy() -> dict: + [{"type": "plain_text", "name": k, "text": str(v)} for k, v in vars_.items()]} data, ctype = cf.multipart([("metadata", "application/json", json.dumps(meta).encode()), *code]) cf.cf("PUT", f"{cf.account()}/workers/scripts/{NAME}", data=data, ctype=ctype) - return {"url": cf.workers_dev(NAME), "worker": NAME, "db": db, "rev": rev} + hostname = cf.host("aicharts") + return {"url": cf.attach(NAME, hostname) if hostname else cf.workers_dev(NAME), "worker": NAME, "db": db, "rev": rev} if __name__ == "__main__": diff --git a/.github/workflows/labs-aicharts.yml b/.github/workflows/labs-aicharts.yml index 5c95229..64db756 100644 --- a/.github/workflows/labs-aicharts.yml +++ b/.github/workflows/labs-aicharts.yml @@ -1,5 +1,5 @@ name: labs-aicharts -# Deploy the AICharts demo Worker (workers.dev, one D1, Workers AI), then smoke-test it. Manual only. +# Deploy the AICharts demo Worker (aicharts., one D1, Workers AI), then smoke-test it. Manual only. on: workflow_dispatch permissions: contents: read @@ -17,15 +17,17 @@ jobs: - run: node .github/time/labs/aicharts/test_aicharts.mjs - id: deploy run: | + set -o pipefail python3 .github/time/labs/aicharts/deploy.py | tee out.json echo "url=$(python3 -c 'import json; print(json.load(open("out.json"))["url"])')" >> "$GITHUB_OUTPUT" env: CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + TIME_VENTURE_DOMAIN: ${{ vars.TIME_VENTURE_DOMAIN }} - name: smoke run: | u="${{ steps.deploy.outputs.url }}" - for i in 1 2 3 4 5 6; do curl -fsS "${u}api/health" && break; sleep 10; done + for i in $(seq 1 18); do curl -fsS "${u}api/health" && break; sleep 10; done curl -fsS "${u}api/schema?dataset=orders" | python3 -c 'import json,sys; d=json.load(sys.stdin); assert len(d["sample"])==5, d; print("schema ok")' curl -fsS -X POST "${u}api/spec" -H 'content-type: application/json' \ -d '{"dataset":"orders","prompt":"total revenue by region"}' | tee spec.json