aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/monorepo-scripts/src/test_installation.ts73
1 files changed, 39 insertions, 34 deletions
diff --git a/packages/monorepo-scripts/src/test_installation.ts b/packages/monorepo-scripts/src/test_installation.ts
index 5ae13b198..ed9b274e2 100644
--- a/packages/monorepo-scripts/src/test_installation.ts
+++ b/packages/monorepo-scripts/src/test_installation.ts
@@ -45,45 +45,50 @@ function logIfDefined(x: any): void {
const IS_LOCAL_PUBLISH = process.env.IS_LOCAL_PUBLISH === 'true';
const registry = IS_LOCAL_PUBLISH ? 'http://localhost:4873/' : 'https://registry.npmjs.org/';
const monorepoRootPath = path.join(__dirname, '../../..');
- const packages = utils.getPackages(monorepoRootPath);
+ // We sort error messages according to package topology so that we can
+ // them in a more intuitive order. E.g. if package A has an error and
+ // package B imports it, the tests for both package A and package B will
+ // fail. But package B only fails because of an error in package A.
+ // Since the error in package A is the root cause, we log it first.
+ const packages = utils.getTopologicallySortedPackages(monorepoRootPath);
const installablePackages = _.filter(
packages,
pkg => !pkg.packageJson.private && !_.isUndefined(pkg.packageJson.main) && pkg.packageJson.main.endsWith('.js'),
);
- utils.log('Testing packages:');
- _.map(installablePackages, pkg => utils.log(`* ${pkg.packageJson.name}`));
- // Run all package tests asynchronously and push promises into an array so
- // we can wait for all of them to resolve.
- const promises: Array<Promise<void>> = [];
- const errors: PackageErr[] = [];
- for (const installablePackage of installablePackages) {
- const packagePromise = testInstallPackageAsync(monorepoRootPath, registry, installablePackage).catch(error => {
- errors.push({ packageName: installablePackage.packageJson.name, error });
- });
- promises.push(packagePromise);
- }
- await Promise.all(promises);
- if (errors.length > 0) {
- // We sort error messages according to package topology so that we can
- // them in a more intuitive order. E.g. if package A has an error and
- // package B imports it, the tests for both package A and package B will
- // fail. But package B only fails because of an error in package A.
- // Since the error in package A is the root cause, we log it first.
- const topologicallySortedPackages = utils.getTopologicallySortedPackages(monorepoRootPath);
- const topologicallySortedErrors = _.sortBy(errors, packageErr =>
- findPackageIndex(topologicallySortedPackages, packageErr.packageName),
- );
- _.forEach(topologicallySortedErrors, packageError => {
- utils.log(`ERROR in package ${packageError.packageName}:`);
- logIfDefined(packageError.error.message);
- logIfDefined(packageError.error.stderr);
- logIfDefined(packageError.error.stdout);
- logIfDefined(packageError.error.stack);
- });
- process.exit(1);
- } else {
- process.exit(0);
+ const CHUNK_SIZE = 10;
+ const chunkedInstallablePackages = _.chunk(installablePackages, CHUNK_SIZE);
+ utils.log(`Testing all packages in ${chunkedInstallablePackages.length} chunks`);
+ for (const installablePackagesChunk of chunkedInstallablePackages) {
+ utils.log('Testing packages:');
+ _.map(installablePackagesChunk, pkg => utils.log(`* ${pkg.packageJson.name}`));
+ // Run all package tests within that chunk asynchronously and push promises into an array so
+ // we can wait for all of them to resolve.
+ const promises: Array<Promise<void>> = [];
+ const errors: PackageErr[] = [];
+ for (const installablePackage of installablePackagesChunk) {
+ const packagePromise = testInstallPackageAsync(monorepoRootPath, registry, installablePackage).catch(
+ error => {
+ errors.push({ packageName: installablePackage.packageJson.name, error });
+ },
+ );
+ promises.push(packagePromise);
+ }
+ await Promise.all(promises);
+ if (errors.length > 0) {
+ const topologicallySortedErrors = _.sortBy(errors, packageErr =>
+ findPackageIndex(packages, packageErr.packageName),
+ );
+ _.forEach(topologicallySortedErrors, packageError => {
+ utils.log(`ERROR in package ${packageError.packageName}:`);
+ logIfDefined(packageError.error.message);
+ logIfDefined(packageError.error.stderr);
+ logIfDefined(packageError.error.stdout);
+ logIfDefined(packageError.error.stack);
+ });
+ process.exit(1);
+ }
}
+ process.exit(0);
})().catch(err => {
utils.log(`Unexpected error: ${err.message}`);
process.exit(1);