mirror of
https://seed.radicle.dev/rad:z4V1sjrXqjvFdnCUbxPFqd5p4DtH5.git
synced 2026-10-18 19:30:27 +08:00
Paralellize build and fixture creation
This commit is contained in:
@@ -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 });
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -115,11 +128,13 @@ export default async function globalSetup(): Promise<() => void> {
|
||||
await createCobsFixture(peerManager, palm);
|
||||
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();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user