Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

test(pipeline): the boundary is checked by packaging a project, not by reading imports

esengineb22802aaeef2
diff --git a/pipeline/bin/estella.mjs b/pipeline/bin/estella.mjs
index 64c5c7d7c..58a270ae9 100644
--- a/pipeline/bin/estella.mjs
+++ b/pipeline/bin/estella.mjs
@@ -16,6 +16,7 @@ const USAGE = `usage: node pipeline/bin/estella.mjs export <projectDir> [options
--platform <id> web | desktop | wechat | playable | android | ios (default web)
--out <dir> output dir (default <projectDir>/dist-<platform>)
+ --wasm <dir> engine runtime to ship (default: the build tree, else the editor's copy)
--scene <path> entry scene, project-relative (default: the project's own)
--title <name> app title (default: the project's name)
--scripts <path> scripts entry, project-relative (default src/main.ts if present)
@@ -183,7 +184,7 @@ try {
gameHostEntry: path.join(PIPELINE, 'src', 'runtime', 'gameHost.ts'),
playableHostEntry: path.join(PIPELINE, 'src', 'runtime', 'playableHost.ts'),
sdkDistDir: path.join(REPO, 'sdk', 'dist'),
- wasmDir: engineRuntimeDir(platform),
+ wasmDir: opts.wasm ? path.resolve(opts.wasm) : engineRuntimeDir(platform),
outDir,
platform,
title: opts.title ?? project.name ?? path.basename(opts.projectDir),
diff --git a/tools/check-headless-export.mjs b/tools/check-headless-export.mjs
new file mode 100644
index 000000000..04b8c1029
--- /dev/null
+++ b/tools/check-headless-export.mjs
@@ -0,0 +1,67 @@
+// SPDX-License-Identifier: Apache-2.0
+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
+/**
+ * @file check-headless-export.mjs — a project ships without the editor.
+ *
+ * The pipeline can only be called from a build server if nothing in it needs the
+ * process that edits a project. `check-pipeline-boundary` keeps the imports
+ * honest, but an import graph does not prove a build: a path into the editor's
+ * output, a file only its packaging writes, and packaging is quietly editor-only
+ * again with every gate still green.
+ *
+ * So this RUNS one. A real example project, through the command line, with no
+ * editor built and no editor process anywhere — and then reads the package.
+ *
+ * The engine binary is stubbed: it is copied, never parsed, and it is not what
+ * this checks. That a package made this way actually boots and draws is
+ * `verify-golden`, which runs where a real runtime and a GPU exist.
+ *
+ * node tools/check-headless-export.mjs
+ */
+import { spawnSync } from 'node:child_process';
+import { mkdtempSync, mkdirSync, writeFileSync, rmSync, existsSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import path from 'node:path';
+import { fileURLToPath } from 'node:url';
+
+const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
+const PROJECT = path.join(ROOT, 'examples', 'hello-world');
+const CLI = path.join(ROOT, 'pipeline', 'bin', 'estella.mjs');
+
+/** What a web package has to carry to be one at all. */
+const EXPECTED = ['index.html', 'game.js', 'game.config.json', 'scripts.mjs', 'sdk', 'wasm', 'assets'];
+
+const work = mkdtempSync(path.join(tmpdir(), 'estella-headless-'));
+const out = path.join(work, 'package');
+const wasm = path.join(work, 'runtime');
+mkdirSync(wasm, { recursive: true });
+for (const name of ['esengine.js', 'esengine.wasm']) writeFileSync(path.join(wasm, name), '');
+
+function fail(message, detail) {
+ console.error(`check-headless-export: ${message}`);
+ if (detail) console.error(detail);
+ rmSync(work, { recursive: true, force: true });
+ process.exit(1);
+}
+
+const run = spawnSync(process.execPath, [
+ CLI, 'export', PROJECT, '--platform', 'web', '--out', out, '--wasm', wasm,
+], { encoding: 'utf8', cwd: ROOT });
+
+if (run.status !== 0) fail(`the export exited ${run.status}.`, run.stderr || run.stdout);
+
+const brace = run.stdout.indexOf('{');
+let result;
+try {
+ result = JSON.parse(run.stdout.slice(brace));
+} catch {
+ fail('the export printed no result JSON.', run.stdout.slice(-2000));
+}
+
+if (!result.ok) fail('the export reported failure.', result.errors?.join('\n'));
+
+const missing = EXPECTED.filter((name) => !existsSync(path.join(out, name)));
+if (missing.length > 0) fail(`the package is missing ${missing.join(', ')}.`);
+
+rmSync(work, { recursive: true, force: true });
+console.log(`check-headless-export: ${path.basename(PROJECT)} packaged for web from the command line — ${EXPECTED.length} artifact(s) present.`);
diff --git a/tools/gates.mjs b/tools/gates.mjs
index 20c3b7019..026453053 100644
--- a/tools/gates.mjs
+++ b/tools/gates.mjs
@@ -60,6 +60,9 @@ export const GATES = [
// Same shape of rule, other direction: what builds a project may not need the
// process that edits one.
{ id: 'pipeline-boundary', run: 'node tools/check-pipeline-boundary.mjs' },
+ // And the boundary holds in practice: a real project packages from the command
+ // line with no editor built.
+ { id: 'headless-export', run: 'node tools/check-headless-export.mjs' },
{ id: 'cycles', run: 'node tools/check-cycles.mjs' },
{ id: 'layers', run: 'node tools/check-layers.mjs' },
{ id: 'project-settings', run: 'node tools/check-project-settings.mjs' },