426e9eeabd
Benchmark Bridge Tests / benchmark (bunx @biomejs/biome check packages/lifeops-bench/src, benchmark-lint) (push) Waiting to run
Benchmark Bridge Tests / benchmark (bunx vitest run --config packages/lifeops-bench/vitest.config.ts --root packages/lifeops-bench --passWithNoTests, benchmark-tests) (push) Waiting to run
Build Agent Image / build-and-push (push) Waiting to run
Chat shell gestures / Chat shell gesture + parity e2e (push) Waiting to run
Cloud Gateway Discord / Test (push) Waiting to run
Cloud Gateway Webhook / Test (push) Waiting to run
Cloud Tests / lint-and-types (push) Waiting to run
Cloud Tests / unit-tests (push) Waiting to run
Cloud Tests / integration-tests (push) Waiting to run
Cloud Tests / e2e-tests (push) Blocked by required conditions
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
Deploy Apps Worker (Product 2) / Determine environment (push) Waiting to run
Deploy Apps Worker (Product 2) / Deploy apps worker to apps-control host (${{ needs.determine-env.outputs.environment }}) (push) Blocked by required conditions
Deploy Eliza Provisioning Worker / Determine environment (push) Waiting to run
Deploy Eliza Provisioning Worker / Deploy worker to Hetzner host (${{ needs.determine-env.outputs.environment }} @ ${{ needs.determine-env.outputs.deployment_sha }}) (push) Blocked by required conditions
Dev Smoke / Classify changed paths (push) Waiting to run
Dev Smoke / bun run dev onboarding chat (push) Blocked by required conditions
Dev Smoke / Vite HMR dependency-level smoke (push) Blocked by required conditions
Electrobun Submodule Guard / electrobun gitlink is fetchable (push) Waiting to run
Publish @elizaos/example-code / check_npm (push) Waiting to run
Publish @elizaos/example-code / publish_npm (push) Blocked by required conditions
Publish @elizaos/plugin-elizacloud / verify_version (push) Waiting to run
Publish @elizaos/plugin-elizacloud / publish_npm (push) Blocked by required conditions
Sandbox Live Smoke / Sandbox live smoke (push) Waiting to run
Snap Build & Test / Build Snap (amd64) (push) Waiting to run
Snap Build & Test / Build Snap (arm64) (push) Waiting to run
supply-chain / sbom (push) Waiting to run
supply-chain / vulnerability-scan (push) Waiting to run
Build, Push & Deploy to Phala Cloud / build-and-push (push) Waiting to run
Test Packaging / Validate Packaging Configs (push) Waiting to run
Test Packaging / PyPI on Python ${{ matrix.python }} (push) Waiting to run
Test Packaging / Pack & Test JS Tarballs (push) Waiting to run
Test Packaging / elizaos CLI global-install smoke (node + bun) (push) Waiting to run
UI Fixture E2E / ui-fixture-e2e (push) Waiting to run
UI Fixture E2E / fixture-e2e (push) Waiting to run
UI Story Gate / story-gate (push) Waiting to run
vault-ci / test (macos-latest) (push) Waiting to run
vault-ci / test (ubuntu-latest) (push) Waiting to run
vault-ci / test (windows-latest) (push) Waiting to run
vault-ci / app-core wiring tests (push) Waiting to run
verify-patches / verify patches/CHECKSUMS.sha256 (push) Waiting to run
Voice Benchmark Smoke / voice-emotion fixture smoke (push) Waiting to run
Voice Benchmark Smoke / voiceagentbench fixture smoke (push) Waiting to run
Voice Benchmark Smoke / voicebench-quality unit smoke (push) Waiting to run
Voice Benchmark Smoke / voicebench TypeScript unit (no audio) (push) Waiting to run
Voice Benchmark Smoke / voice bench smoke summary (push) Blocked by required conditions
Windows CI / windows ([bun run --cwd packages/app-core test bun run --cwd packages/elizaos test bun run --cwd packages/cloud/shared test], app-and-cli) (push) Waiting to run
Windows CI / windows ([bun run --cwd packages/scenario-runner test bun run --cwd packages/vault test bun run --cwd packages/security test bun run --cwd plugins/plugin-coding-tools test], framework-packages) (push) Waiting to run
Windows CI / windows ([bun run --cwd plugins/plugin-elizacloud test bun run --cwd plugins/plugin-discord test bun run --cwd plugins/plugin-anthropic test bun run --cwd plugins/plugin-openai test bun run --cwd plugins/plugin-app-control test bun run --cwd plugins/pl… (push) Waiting to run
Windows CI / windows ([node packages/scripts/run-turbo.mjs run build --filter=@elizaos/core --filter=@elizaos/shared --filter=@elizaos/agent --concurrency=4 node packages/scripts/run-bash-linux-only.mjs scripts/verify-riscv64-buildpaths.sh node packages/scripts/run… (push) Waiting to run
Windows CI / windows ([node packages/scripts/run-turbo.mjs run typecheck --filter=@elizaos/core --filter=@elizaos/shared --filter=@elizaos/cloud-shared --concurrency=4 bun run --cwd packages/core test bun run --cwd packages/shared test], core-runtime, 75) (push) Waiting to run
Test Packaging / Build & Test PyPI Package (push) Waiting to run
Voice Workbench / headless workbench (mocked backends) (push) Has been cancelled
Voice Workbench / real acoustic lane (nightly, provisioned only) (push) Has been cancelled
ci / test (push) Has been cancelled
ci / lint-and-format (push) Has been cancelled
ci / build (push) Has been cancelled
ci / dev-startup (push) Has been cancelled
gitleaks / gitleaks (push) Has been cancelled
Markdown Links / Relative Markdown Links (push) Has been cancelled
Quality (Extended) / Homepage Build (PR smoke) (push) Has been cancelled
Quality (Extended) / Comment-only diff guard (push) Has been cancelled
Quality (Extended) / Format + Type Safety Ratchet (push) Has been cancelled
Quality (Extended) / Develop Gate (secret scan + UI determinism) (push) Has been cancelled
Quality (Extended) / Develop Gate (lint) (push) Has been cancelled
325 lines
10 KiB
TypeScript
325 lines
10 KiB
TypeScript
/**
|
|
* DEPLOY_FRONTEND action tests: frontend hosting deploy. The @elizaos/cloud-sdk client is faked (helpers.ts, SDK boundary only); the action runs for real.
|
|
*/
|
|
import { afterEach, beforeEach, describe, expect, it, mock } from "bun:test";
|
|
import { promises as fs } from "node:fs";
|
|
import { tmpdir } from "node:os";
|
|
import path from "node:path";
|
|
import type {
|
|
AppFrontendDeploymentDto,
|
|
DeployAppFrontendInput,
|
|
} from "@elizaos/cloud-sdk";
|
|
import {
|
|
captureCallback,
|
|
FakeElizaCloudClient,
|
|
keyedRuntime,
|
|
makeApp,
|
|
makeMessage,
|
|
makeRuntime,
|
|
resetSdk,
|
|
setDeployAppFrontend,
|
|
setGetApp,
|
|
setListApps,
|
|
unkeyedRuntime,
|
|
} from "./helpers";
|
|
|
|
mock.module("@elizaos/cloud-sdk", () => ({
|
|
ElizaCloudClient: FakeElizaCloudClient,
|
|
}));
|
|
|
|
const { deployFrontendAction } = await import(
|
|
"../src/actions/deploy-frontend.ts"
|
|
);
|
|
|
|
const APP = makeApp({ id: "app_1", name: "Acme Bot", slug: "acme-bot" });
|
|
|
|
function makeFeDeployment(
|
|
overrides: Partial<AppFrontendDeploymentDto> = {},
|
|
): AppFrontendDeploymentDto {
|
|
return {
|
|
id: "fe_1",
|
|
app_id: "app_1",
|
|
version: 1,
|
|
status: "active",
|
|
r2_prefix: "p/",
|
|
content_hash: "b".repeat(64),
|
|
file_count: 1,
|
|
total_bytes: 42,
|
|
error: null,
|
|
created_at: "2026-06-29T00:00:00.000Z",
|
|
activated_at: "2026-06-29T00:00:00.000Z",
|
|
...overrides,
|
|
};
|
|
}
|
|
|
|
let tmp: string | null = null;
|
|
|
|
describe("DEPLOY_FRONTEND", () => {
|
|
beforeEach(() => {
|
|
resetSdk();
|
|
setListApps(() => Promise.resolve({ success: true, apps: [APP] }));
|
|
setGetApp(() => Promise.resolve({ success: true, app: APP }));
|
|
});
|
|
afterEach(async () => {
|
|
if (tmp) {
|
|
await fs.rm(tmp, { recursive: true, force: true });
|
|
tmp = null;
|
|
}
|
|
});
|
|
|
|
describe("validate", () => {
|
|
it("true with a key, false without", async () => {
|
|
expect(
|
|
await deployFrontendAction.validate(keyedRuntime(), makeMessage("x")),
|
|
).toBe(true);
|
|
expect(
|
|
await deployFrontendAction.validate(unkeyedRuntime(), makeMessage("x")),
|
|
).toBe(false);
|
|
});
|
|
});
|
|
|
|
describe("handler", () => {
|
|
it("reports no-key when unconfigured", async () => {
|
|
const cb = captureCallback();
|
|
const res = await deployFrontendAction.handler(
|
|
unkeyedRuntime(),
|
|
makeMessage("publish Acme Bot"),
|
|
undefined,
|
|
{ directory: "/x" },
|
|
cb.fn,
|
|
);
|
|
expect(res.success).toBe(false);
|
|
expect(res.data).toMatchObject({ reason: "no_key" });
|
|
});
|
|
|
|
it("asks which app when no reference is given", async () => {
|
|
const cb = captureCallback();
|
|
const res = await deployFrontendAction.handler(
|
|
keyedRuntime(),
|
|
makeMessage(""),
|
|
undefined,
|
|
{},
|
|
cb.callback,
|
|
);
|
|
expect(res.success).toBe(false);
|
|
expect(res.data).toMatchObject({ reason: "no_reference" });
|
|
});
|
|
|
|
it("reports not-found for an unknown app", async () => {
|
|
setListApps(() => Promise.resolve({ success: true, apps: [] }));
|
|
setGetApp(() =>
|
|
Promise.resolve({ success: true, app: undefined as never }),
|
|
);
|
|
const cb = captureCallback();
|
|
const res = await deployFrontendAction.handler(
|
|
keyedRuntime(),
|
|
makeMessage("publish Nonexistent"),
|
|
undefined,
|
|
{ directory: "/x" },
|
|
cb.callback,
|
|
);
|
|
expect(res.success).toBe(false);
|
|
expect(res.data).toMatchObject({ reason: "not_found" });
|
|
});
|
|
|
|
it("requires a build source (no directory, no files)", async () => {
|
|
const cb = captureCallback();
|
|
const res = await deployFrontendAction.handler(
|
|
makeRuntime({
|
|
ELIZAOS_CLOUD_API_KEY: "eliza_test_key",
|
|
ELIZAOS_CLOUD_FRONTEND_BUILD_ROOT: tmp,
|
|
}),
|
|
makeMessage("publish Acme Bot"),
|
|
undefined,
|
|
{},
|
|
cb.callback,
|
|
);
|
|
expect(res.success).toBe(false);
|
|
expect(res.data).toMatchObject({ reason: "no_source" });
|
|
});
|
|
|
|
it("publishes inline files", async () => {
|
|
let captured: DeployAppFrontendInput | null = null;
|
|
setDeployAppFrontend((_id, input) => {
|
|
captured = input;
|
|
return Promise.resolve({
|
|
success: true,
|
|
deployment: makeFeDeployment(),
|
|
});
|
|
});
|
|
const cb = captureCallback();
|
|
const res = await deployFrontendAction.handler(
|
|
keyedRuntime(),
|
|
makeMessage("publish Acme Bot"),
|
|
undefined,
|
|
{ files: [{ path: "index.html", content: "<html></html>" }] },
|
|
cb.fn,
|
|
);
|
|
expect(res.success).toBe(true);
|
|
expect(captured?.files).toHaveLength(1);
|
|
expect(res.data).toMatchObject({
|
|
deployment: { version: 1, status: "active" },
|
|
});
|
|
expect(res.userFacingText).toContain("is now live");
|
|
});
|
|
|
|
it("does not claim live when publish returns a built but non-active deployment", async () => {
|
|
setDeployAppFrontend(() =>
|
|
Promise.resolve({
|
|
success: true,
|
|
deployment: makeFeDeployment({
|
|
id: "fe_3",
|
|
version: 3,
|
|
status: "ready",
|
|
activated_at: null,
|
|
}),
|
|
}),
|
|
);
|
|
|
|
const cb = captureCallback();
|
|
const res = await deployFrontendAction.handler(
|
|
keyedRuntime(),
|
|
makeMessage("publish Acme Bot"),
|
|
undefined,
|
|
{ files: [{ path: "index.html", content: "<html></html>" }] },
|
|
cb.fn,
|
|
);
|
|
|
|
expect(res.success).toBe(true);
|
|
expect(res.userFacingText).not.toContain("now live");
|
|
expect(res.userFacingText).toContain("built but NOT yet live");
|
|
expect(res.userFacingText).toContain("status: ready");
|
|
expect(cb.calls[0]?.text).toBe(res.userFacingText);
|
|
expect(res.data).toMatchObject({
|
|
deployment: { id: "fe_3", version: 3, status: "ready" },
|
|
});
|
|
});
|
|
|
|
it("reports NOT yet live when the deployment is not active", async () => {
|
|
setDeployAppFrontend(() =>
|
|
Promise.resolve({
|
|
success: true,
|
|
deployment: {
|
|
id: "fe_1",
|
|
app_id: "app_1",
|
|
version: 1,
|
|
status: "ready",
|
|
r2_prefix: "p/",
|
|
content_hash: "b".repeat(64),
|
|
file_count: 1,
|
|
total_bytes: 42,
|
|
error: null,
|
|
created_at: "2026-06-29T00:00:00.000Z",
|
|
activated_at: null,
|
|
},
|
|
}),
|
|
);
|
|
const cb = captureCallback();
|
|
const res = await deployFrontendAction.handler(
|
|
keyedRuntime(),
|
|
makeMessage("publish Acme Bot"),
|
|
undefined,
|
|
{ files: [{ path: "index.html", content: "<html></html>" }] },
|
|
cb.fn,
|
|
);
|
|
expect(res.success).toBe(true);
|
|
expect(res.data).toMatchObject({
|
|
deployment: { version: 1, status: "ready" },
|
|
});
|
|
expect(cb.calls).toHaveLength(1);
|
|
expect(cb.calls[0]?.text).toContain("NOT yet live (status: ready)");
|
|
expect(cb.calls[0]?.text).not.toContain("is now live");
|
|
});
|
|
|
|
it("reads a build directory and uploads its files (text + base64)", async () => {
|
|
tmp = await fs.mkdtemp(path.join(tmpdir(), "fe-deploy-"));
|
|
await fs.writeFile(
|
|
path.join(tmp, "index.html"),
|
|
"<html><body>hi</body></html>",
|
|
);
|
|
await fs.writeFile(path.join(tmp, ".env"), "SECRET=do-not-publish");
|
|
await fs.mkdir(path.join(tmp, "assets"));
|
|
await fs.writeFile(path.join(tmp, "assets", "app.js"), "console.log(1)");
|
|
// a binary file → base64
|
|
await fs.writeFile(
|
|
path.join(tmp, "logo.png"),
|
|
Buffer.from([0x89, 0x50, 0x4e, 0x47]),
|
|
);
|
|
|
|
let captured: DeployAppFrontendInput | null = null;
|
|
setDeployAppFrontend((_id, input) => {
|
|
captured = input;
|
|
return Promise.resolve({
|
|
success: true,
|
|
deployment: {
|
|
id: "fe_2",
|
|
app_id: "app_1",
|
|
version: 2,
|
|
status: "active",
|
|
r2_prefix: "p2/",
|
|
content_hash: "c".repeat(64),
|
|
file_count: input.files.length,
|
|
total_bytes: 500,
|
|
error: null,
|
|
created_at: "2026-06-29T00:00:00.000Z",
|
|
activated_at: "2026-06-29T00:00:00.000Z",
|
|
},
|
|
});
|
|
});
|
|
|
|
const cb = captureCallback();
|
|
const res = await deployFrontendAction.handler(
|
|
// The build root must be the fixture dir, else `directory: "."` walks CWD.
|
|
makeRuntime({
|
|
ELIZAOS_CLOUD_API_KEY: "eliza_test_key",
|
|
ELIZAOS_CLOUD_FRONTEND_BUILD_ROOT: tmp,
|
|
}),
|
|
makeMessage("publish Acme Bot"),
|
|
undefined,
|
|
{ directory: "." },
|
|
cb.callback,
|
|
);
|
|
expect(res.success).toBe(true);
|
|
const paths = (captured?.files ?? []).map((f) => f.path).sort();
|
|
expect(paths).toEqual(["assets/app.js", "index.html", "logo.png"]);
|
|
expect(paths).not.toContain(".env");
|
|
const png = captured?.files.find((f) => f.path === "logo.png");
|
|
expect(png?.encoding).toBe("base64");
|
|
const html = captured?.files.find((f) => f.path === "index.html");
|
|
expect(html?.encoding).toBe("utf8");
|
|
});
|
|
|
|
it("rejects a build directory outside the configured frontend build root", async () => {
|
|
tmp = await fs.mkdtemp(path.join(tmpdir(), "fe-deploy-root-"));
|
|
const allowedRoot = path.join(tmp, "allowed");
|
|
const outsideRoot = path.join(tmp, "outside");
|
|
await fs.mkdir(allowedRoot);
|
|
await fs.mkdir(outsideRoot);
|
|
await fs.writeFile(path.join(outsideRoot, "index.html"), "<html></html>");
|
|
|
|
let uploaded = false;
|
|
setDeployAppFrontend(() => {
|
|
uploaded = true;
|
|
throw new Error("should not upload");
|
|
});
|
|
|
|
const cb = captureCallback();
|
|
const res = await deployFrontendAction.handler(
|
|
makeRuntime({
|
|
ELIZAOS_CLOUD_API_KEY: "eliza_test_key",
|
|
ELIZAOS_CLOUD_FRONTEND_BUILD_ROOT: allowedRoot,
|
|
}),
|
|
makeMessage("publish Acme Bot"),
|
|
undefined,
|
|
{ directory: outsideRoot },
|
|
cb.callback,
|
|
);
|
|
|
|
expect(res.success).toBe(false);
|
|
expect(res.data).toMatchObject({ reason: "read_failed" });
|
|
expect(res.userFacingText).toContain("configured frontend build root");
|
|
expect(uploaded).toBe(false);
|
|
});
|
|
});
|
|
});
|