Paralellize build and fixture creation

This commit is contained in:
Rūdolfs Ošiņš
2026-02-26 14:57:57 -06:00
parent b0923d9096
commit d97560936e
2 changed files with 98 additions and 70 deletions
+6 -2
View File
@@ -609,9 +609,13 @@ from ${parent}
const fastImportFile = Path.join(tmpDir, "repos", "commits-fast-import");
await Fs.writeFile(fastImportFile, fastImportData);
await peer.spawn("bash", ["-c", `git fast-import --force < "${fastImportFile}"`], {
await peer.spawn(
"bash",
["-c", `git fast-import --force < "${fastImportFile}"`],
{
cwd: repoFolder,
});
},
);
await Fs.unlink(fastImportFile);
await peer.git(["push", "rad"], { cwd: repoFolder });
+44 -20
View File
@@ -54,21 +54,34 @@ export default async function globalSetup(): Promise<() => void> {
process.exit(1);
}
if (!process.env.SKIP_BUILD) {
// Build the app once before running tests to avoid compilation
// overhead on each worker.
console.log("Building the app for tests...");
const { execa: exec } = await import("execa");
await exec("npm", ["run", "build"], { stdio: "inherit" });
console.log("Build complete");
} else {
console.log("Skipping build. Set SKIP_BUILD to skip this");
}
console.log("⚡ Starting parallel setup...");
// Run build and fixture setup in parallel
const buildPromise = (async () => {
if (!process.env.SKIP_BUILD) {
console.log(" 🔨 Starting build...");
const { execa: exec } = await import("execa");
try {
await exec("npm", ["run", "build"]);
console.log(" 🔨 Build complete");
} catch (error) {
console.log(" 🔨 Build failed!");
if (error && typeof error === "object" && "stdout" in error) {
console.log(error.stdout);
}
if (error && typeof error === "object" && "stderr" in error) {
console.log(error.stderr);
}
throw error;
}
} else {
console.log(" 🔨 Skipping build");
}
})();
const fixturesPromise = (async () => {
if (!process.env.SKIP_FIXTURE_CREATION) {
console.log(
"Recreating static fixtures. Set SKIP_FIXTURE_CREATION to skip this",
);
console.log(" 🗂️ Starting fixture creation...");
await removeWorkspace();
}
@@ -107,19 +120,21 @@ export default async function globalSetup(): Promise<() => void> {
await palm.startHttpd(config.nodes.defaultHttpdPort);
try {
console.log("Creating source-browsing fixture");
console.log(" Creating source-browsing fixture");
await createSourceBrowsingFixture(peerManager, palm);
console.log("Creating markdown fixture");
console.log(" Creating markdown fixture");
await createMarkdownFixture(palm);
console.log("Creating cobs fixture");
console.log(" Creating cobs fixture");
await createCobsFixture(peerManager, palm);
console.log("Creating commits fixture");
console.log(" Creating commits fixture");
await createCommitsFixture(palm);
console.log("All fixtures created");
console.log(" 🗂️ All fixtures created");
} catch (error) {
console.log("");
console.log("Not able to create the required fixtures.");
console.log("Make sure you are not using binaries compiled for release.");
console.log(" 🗂️ Not able to create the required fixtures.");
console.log(
" Make sure you are not using binaries compiled for release.",
);
console.log("");
console.log(error);
console.log("");
@@ -127,9 +142,18 @@ export default async function globalSetup(): Promise<() => void> {
}
await palm.stopNode();
} else {
console.log(" 🗂️ Skipping fixture creation");
await palm.startHttpd(config.nodes.defaultHttpdPort);
}
return peerManager;
})();
// Wait for both build and fixtures to complete
const [, peerManager] = await Promise.all([buildPromise, fixturesPromise]);
console.log("🚀 Setup complete, ready to run tests");
return async () => {
await peerManager.shutdown();
};