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.

fix(ci): the lane that cannot build wasm now says so, and a gate checks that it did

esengine33893c574656
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index d9f7d7df9..af980f1f5 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -167,6 +167,11 @@ jobs:
- name: Static gates (incl. the SDK, editor, plugin and compiler suites)
env:
SDK_TEST_MODE: no-wasm
+ # This lane installs no emsdk on purpose, so the suites that build a real
+ # module cannot run here. Declared rather than discovered: the gate runner
+ # counts it as a hole this machine could not answer, and `test-engine`
+ # covers those where the wasm is.
+ ESTELLA_NO_EMCC: '1'
run: node tools/run-gates.mjs --scope ci
# The Android packaging tests check what we write against implementations that
diff --git a/tools/check-suite-preconditions.mjs b/tools/check-suite-preconditions.mjs
index 46663388c..60d06054a 100644
--- a/tools/check-suite-preconditions.mjs
+++ b/tools/check-suite-preconditions.mjs
@@ -13,6 +13,12 @@
* without anything going red — which is what this holds together:
*
* probe → prover (once per suite) → declaration env var → the gate runner
+ * → the CI caller that runs without the capability
+ *
+ * The last link was missing, and it broke exactly the way the others would: a
+ * commit taught the suites to demand a declaration and did not teach the
+ * workflow to make one, so a lane that deliberately installs no emsdk died
+ * before collecting a test while this gate stayed green.
*
* Run: node tools/check-suite-preconditions.mjs
*/
@@ -31,9 +37,29 @@ const read = (p) => readFileSync(path.join(ROOT, p), 'utf8');
const CAPABILITIES = [
{ what: 'a host C compiler', probe: 'findHostCC', prover: 'proveHostCC', owner: 'compiler/src/hostCC.ts' },
{ what: 'an activated emsdk', probe: 'emccPath', prover: 'proveEmcc',
- owner: 'build-tools/utils/emscripten.js' },
+ owner: 'build-tools/utils/emscripten.js',
+ // What INSTALLS it in CI. A job matching this provides the capability; a
+ // job that runs the gate list without it owes the declaration.
+ ciProvider: /setup-emsdk/ },
];
+const WORKFLOW = '.github/workflows/build.yml';
+
+/** The workflow's jobs, by name, as raw text. Enough YAML for this question:
+ * jobs are the two-space keys under `jobs:` and steps the four-space dashes. */
+function jobsOf(yaml) {
+ const body = yaml.slice(yaml.indexOf('\njobs:'));
+ const heads = [...body.matchAll(/^ ([A-Za-z0-9_-]+):$/gm)];
+ return heads.map((h, i) => [h[1],
+ body.slice(h.index, i + 1 < heads.length ? heads[i + 1].index : body.length)]);
+}
+
+function stepsOf(job) {
+ const heads = [...job.matchAll(/^ {4}- /gm)];
+ return heads.map((h, i) =>
+ job.slice(h.index, i + 1 < heads.length ? heads[i + 1].index : job.length));
+}
+
/** Test files, by the package that owns them. */
function testFiles(dir, out = []) {
for (const name of readdirSync(path.join(ROOT, dir))) {
@@ -93,6 +119,43 @@ for (const cap of CAPABILITIES) {
problems.push(`run-gates does not count ${declared[1]} as a gap, so declaring it would`
+ ' hide the hole from --complete rather than report it.');
}
+
+ // 3. And the callers: knowing the env var exists says nothing about whether
+ // the machine that lacks the capability actually sets it.
+ if (!cap.ciProvider || !declared) continue;
+ if (!existsSync(path.join(ROOT, WORKFLOW))) {
+ // Loudly, not by throwing: a gate whose subject moved has to say which
+ // link it stopped checking, and a stack trace says only that it died.
+ problems.push(`${WORKFLOW} is not there, so nothing checks whether a CI lane without`
+ + ` ${cap.what} declares ${declared[1]}.`);
+ continue;
+ }
+ const workflow = read(WORKFLOW);
+ let callers = 0;
+ for (const [job, text] of jobsOf(workflow)) {
+ const provides = cap.ciProvider.test(text);
+ for (const step of stepsOf(text)) {
+ if (!/run-gates\.mjs/.test(step)) continue;
+ callers++;
+ const declares = new RegExp(`^\\s*${declared[1]}\\s*:`, 'm').test(step);
+ if (!provides && !declares) {
+ problems.push(`${WORKFLOW}: job "${job}" runs the gate list without`
+ + ` ${cap.what} and does not declare ${declared[1]} — its suites refuse`
+ + ' to start,'
+ + ' and nothing here said so.');
+ }
+ // The other way round is a lie in the other direction: a lane that
+ // HAS the capability reporting a hole hides real coverage.
+ if (provides && declares) {
+ problems.push(`${WORKFLOW}: job "${job}" installs ${cap.what} and still declares`
+ + ` ${declared[1]} — it would report coverage it actually has as a gap.`);
+ }
+ }
+ }
+ if (callers === 0) {
+ problems.push(`${WORKFLOW}: no job runs the gate list, or this gate can no longer find`
+ + ' one — either way the caller half of the chain is unchecked.');
+ }
}
if (problems.length) {