From 3b93430fd7fd9115a3a8c9625b3294cd35960939 Mon Sep 17 00:00:00 2001 From: Aria Minaei Date: Sun, 6 Aug 2023 08:43:45 +0200 Subject: [PATCH] Install compat tests in parallel --- compat-tests/scripts/scripts.mjs | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/compat-tests/scripts/scripts.mjs b/compat-tests/scripts/scripts.mjs index be4888b..82c5fda 100644 --- a/compat-tests/scripts/scripts.mjs +++ b/compat-tests/scripts/scripts.mjs @@ -83,14 +83,15 @@ export async function installFixtures() { console.log('Running `$ npm install` on test packages') await runNpmInstallOnTestPackages() - console.log('All fixtures installed successfully') + + restoreTestPackageJsons() + if (keepAlive) { console.log('Keeping verdaccio alive. Press Ctrl+C to exit.') // wait for ctrl+c await new Promise((resolve) => {}) } else { console.log('Closing verdaccio. Use --keep-alive to keep it running.') - restoreTestPackageJsons() await verdaccioServer.close() } console.log('Done') @@ -99,7 +100,7 @@ export async function installFixtures() { async function runNpmInstallOnTestPackages() { const packagePaths = await getCompatibilityTestSetups() - for (const pathToPackageDir of packagePaths) { + const promises = packagePaths.map(async (pathToPackageDir) => { await fs.remove(path.join(pathToPackageDir, 'node_modules')) await fs.remove(path.join(pathToPackageDir, 'package-lock.json')) cd(path.join(pathToPackageDir, '../')) @@ -131,9 +132,26 @@ Try running \`npm install\` in that directory manually via: cd ${pathToPackageDir} npm install --registry ${config.VERDACCIO_URL} Original error: ${error}`) + throw new Error(`Failed to install dependencies for ${pathToPackageDir}`) } finally { await fs.remove(tempPath) } + }) + + const result = await Promise.allSettled(promises) + const failed = result.filter((x) => x.status === 'rejected') + if (failed.length > 0) { + console.error( + `Failed to install dependencies for the following packages:`, + result + .map((result, i) => [packagePaths[i], result]) + .filter( + ([p, result]) => + // @ts-ignore + result.status === 'rejected', + ) + .map(([path]) => path), + ) } }