aboutsummaryrefslogtreecommitdiffstats
path: root/packages/monorepo-scripts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2019-01-12 00:12:55 +0800
committerFabio Berger <me@fabioberger.com>2019-01-12 00:12:55 +0800
commit96ff5eef644b8c4d3f8fc4ec53270991fb51f121 (patch)
tree530f43b03d2b3aa09b5f6552d4285df92d45fed0 /packages/monorepo-scripts
parent7f5a2c972bb86df77c423fb7029e9a629ecc1ede (diff)
parent2cf57a48dd2857dd5cf2f31f4c60dd47ae4d34a5 (diff)
downloaddexon-sol-tools-96ff5eef644b8c4d3f8fc4ec53270991fb51f121.tar
dexon-sol-tools-96ff5eef644b8c4d3f8fc4ec53270991fb51f121.tar.gz
dexon-sol-tools-96ff5eef644b8c4d3f8fc4ec53270991fb51f121.tar.bz2
dexon-sol-tools-96ff5eef644b8c4d3f8fc4ec53270991fb51f121.tar.lz
dexon-sol-tools-96ff5eef644b8c4d3f8fc4ec53270991fb51f121.tar.xz
dexon-sol-tools-96ff5eef644b8c4d3f8fc4ec53270991fb51f121.tar.zst
dexon-sol-tools-96ff5eef644b8c4d3f8fc4ec53270991fb51f121.zip
merge development
Diffstat (limited to 'packages/monorepo-scripts')
-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..822f48967 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 see
+ // 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 = 15;
+ 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);