Visitar URL original
fix(test): serialize core build in build-theme.variants through the s… · meta/astryx@6453d64 · GitHub
Skip to content

Commit 6453d64

Browse files
committed
fix(test): serialize core build in build-theme.variants through the shared lock
build-theme.variants.test.mjs was the one build-theme suite still running its own unguarded 'if (!exists) pnpm -F core build' in beforeAll instead of the ensureCoreBuilt() lock helper that exists precisely because concurrent core builds collide on packages/core/dist (the build starts by wiping dist). The ui/node project split changed file scheduling so the build-theme suites start near-simultaneously on fresh-checkout CI, which made the latent race fire: variants' unlocked build ran concurrently with the lock-holder's build, dist was wiped mid-suite, and the CLI under test exited 1 on missing core .d.ts files ('expected 1 to be +0' in CI run 29151203513, while the first two tests of the same suite passed). Verified by deleting packages/core/dist and running all four build-theme suites concurrently in the node project — all pass with the build serialized behind the lock.
1 parent 1a85712 commit 6453d64

1 file changed

Lines changed: 7 additions & 18 deletions

File tree

‎packages/cli/src/commands/build-theme.variants.test.mjs‎

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,10 @@ import * as fs from 'node:fs';
2828
import * as path from 'node:path';
2929
import * as os from 'node:os';
3030
import {fileURLToPath} from 'node:url';
31+
import {ensureCoreBuilt} from './ensure-core-built.mjs';
3132

3233
const __dirname = path.dirname(fileURLToPath(import.meta.url));
3334
const CLI_BIN = path.resolve(__dirname, '../../bin/astryx.mjs');
34-
const REPO_ROOT = path.resolve(__dirname, '../../../..');
35-
const CORE_THEME_ENTRY = path.join(
36-
REPO_ROOT,
37-
'packages/core/dist/theme/index.js',
38-
);
39-
// The fix reads core's shipped component declarations to decide whether an
40-
// interface is augmentable; those .d.ts files come from the same core build.
41-
const CORE_BUTTON_DTS = path.join(
42-
REPO_ROOT,
43-
'packages/core/dist/Button/index.d.ts',
44-
);
4535

4636
function runCli(args, cwd) {
4737
try {
@@ -68,14 +58,13 @@ function writeTheme(dir, contents) {
6858
return file;
6959
}
7060

61+
// Build core through the shared lock helper — this suite previously ran its
62+
// own unguarded `if (!exists) pnpm -F core build`, and when Vitest scheduled
63+
// it alongside the other build-theme suites on a fresh checkout, the
64+
// concurrent builds collided on packages/core/dist (core's build starts by
65+
// wiping dist), nondeterministically breaking whichever suite was mid-read.
7166
beforeAll(() => {
72-
if (!fs.existsSync(CORE_THEME_ENTRY) || !fs.existsSync(CORE_BUTTON_DTS)) {
73-
execFileSync('pnpm', ['-F', '@astryxdesign/core', 'build'], {
74-
cwd: REPO_ROOT,
75-
stdio: 'pipe',
76-
timeout: 180_000,
77-
});
78-
}
67+
ensureCoreBuilt();
7968
}, 200_000);
8069

8170
let tmpDir;

0 commit comments

Comments
 (0)