Sandbox Jobs never received WF_DEPLOYMENT_MODE, which every worker requires before anything else, so each Kubernetes sandbox exited at start. The provisioner now passes its own mode. A local development cluster (k3s) has no Kata, no bubblewrap inside runc and no TLS between services. For it, and only with WF_DEPLOYMENT_MODE=development: - WF_ALLOW_INSECURE_HTTP=true lets services reach each other over plain HTTP (Git, the model proxy, the provisioner and IDE gateway targets, the worker's control-plane client); production refuses the setting outright. - The provisioner accepts WF_RUN_SANDBOX_MODE=host and WF_KATA_RUNTIME_CLASS=none and passes the HTTP settings to its sandboxes. - The development seed is built into the image (dist/api/seed.mjs). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
43 lines
2.3 KiB
TypeScript
43 lines
2.3 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { execFile } from 'node:child_process';
|
|
import { access, mkdir, mkdtemp, rm } from 'node:fs/promises';
|
|
import path from 'node:path';
|
|
import { promisify } from 'node:util';
|
|
|
|
// Images run the services built by scripts/build-services.mjs (FR-K5). Each built entry point
|
|
// must load all of its imports and reach its own start-up checks.
|
|
const run = promisify(execFile);
|
|
const outcome = (file: string, env: Record<string, string>) =>
|
|
run(process.execPath, [file], { env: { PATH: process.env.PATH!, ...env }, timeout: 30_000 }).then(
|
|
result => ({ code: 0, output: result.stdout + result.stderr }),
|
|
(error: { code?: number; stdout?: string; stderr?: string }) => ({
|
|
code: error.code ?? 1,
|
|
output: `${error.stdout ?? ''}${error.stderr ?? ''}`,
|
|
}),
|
|
);
|
|
|
|
describe('built services', () => {
|
|
it('compile with the workflow bundle, load every import and stop at their own configuration checks', async () => {
|
|
// Inside the repository, like dist/ in the image, so external packages resolve from node_modules.
|
|
await mkdir('.wishforge', { recursive: true });
|
|
const outdir = await mkdtemp(path.join(process.cwd(), '.wishforge', 'build-test-'));
|
|
try {
|
|
await run(process.execPath, ['scripts/build-services.mjs', '--outdir', outdir], { timeout: 120_000 });
|
|
await access(path.join(outdir, 'worker/workflow-bundle.js'));
|
|
await access(path.join(outdir, 'api/migrations/001_initial.sql'));
|
|
for (const service of ['api/main.mjs', 'worker/main.mjs', 'runner/main.mjs', 'git-service/main.mjs']) {
|
|
const result = await outcome(path.join(outdir, service), {});
|
|
expect(result.code, service).not.toBe(0);
|
|
expect(result.output, service).toContain('Set WF_DEPLOYMENT_MODE');
|
|
}
|
|
const seed = await outcome(path.join(outdir, 'api/seed.mjs'), { WF_DEPLOYMENT_MODE: 'production' });
|
|
expect(seed.output).toContain('never runs in production');
|
|
const migrate = await outcome(path.join(outdir, 'api/migrate.mjs'), { WF_DEPLOYMENT_MODE: 'production' });
|
|
expect(migrate.code).not.toBe(0);
|
|
expect(migrate.output).not.toMatch(/ERR_MODULE_NOT_FOUND|Cannot find (module|package)/);
|
|
} finally {
|
|
await rm(outdir, { recursive: true, force: true });
|
|
}
|
|
}, 180_000);
|
|
});
|