Skip to content

Commit

Permalink
Fix release testing script
Browse files Browse the repository at this point in the history
Summary:
Various fixes/tweaks to the `test-e2e-local` script, impacted by recent changes, found during the release process:

- Fix typo in variable name for `circleciToken` arg.
- Relocate erroneously positioned `process.exit` call (a force exit around Verdaccio, which we will remove in future).
- Add notice on exit around Verdaccio server not being killed successfully (to do in T179377112).
- Switch from Yarn to npm for test project installation — Yarn 3 is not respecting `npmRegistryServer`, see yarnpkg/yarn#2508.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D53951606
  • Loading branch information
huntie authored and facebook-github-bot committed Feb 21, 2024
1 parent 7fffe69 commit 6d7f715
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 22 deletions.
37 changes: 18 additions & 19 deletions scripts/e2e/init-template-e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ async function main() {
}

await initNewProjectFromSource(options);

// TODO(T179377112): Fix memory leak from `spawn` in `setupVerdaccio` (above
// kill command does not wait for kill success).
process.exit(0);
}

async function initNewProjectFromSource(
Expand Down Expand Up @@ -122,48 +126,43 @@ async function initNewProjectFromSource(
{
// Avoid loading packages/react-native/react-native.config.js
cwd: REPO_ROOT,
stdio: verbose ? 'inherit' : [process.stderr],
stdio: 'inherit',
},
);
console.log('\nDone ✅');

console.log('Installing project dependencies');
await runYarnUsingProxy(directory);
await installProjectUsingProxy(directory);
console.log('Done ✅');
} catch (e) {
console.log('Failed ❌');
throw e;
} finally {
console.log(`Cleanup: Killing Verdaccio process (PID: ${verdaccioPid})`);
execSync(`kill -9 ${verdaccioPid}`);
console.log('Done ✅');

try {
execSync(`kill -9 ${verdaccioPid}`);
console.log('Done ✅');
} catch {
console.warn('Failed to kill Verdaccio process');
}
console.log('Cleanup: Removing Verdaccio storage directory');
execSync(`rm -rf ${VERDACCIO_STORAGE_PATH}`);
console.log('Done ✅');

// TODO(huntie): Fix memory leak from `spawn` in `setupVerdaccio` (above
// kill command does not wait for kill success).
process.exit(0);
}
}

async function runYarnUsingProxy(cwd /*: string */) {
async function installProjectUsingProxy(cwd /*: string */) {
const execOptions = {
cwd,
stdio: 'inherit',
};
execSync(
`yarn config set npmRegistryServer "${VERDACCIO_SERVER_URL}"`,
execOptions,
);
execSync(
'yarn config set unsafeHttpWhitelist --json \'["localhost"]\'',
execOptions,
);

// TODO(huntie): Review pre-existing retry limit
const success = await retry('yarn', execOptions, 3, 500, ['install']);
const success = await retry('npm', execOptions, 3, 500, [
'install',
'--registry',
VERDACCIO_SERVER_URL,
]);

if (!success) {
throw new Error('Failed to install project dependencies');
Expand Down
16 changes: 13 additions & 3 deletions scripts/release-testing/test-e2e-local.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const {
prepareArtifacts,
setupCircleCIArtifacts,
} = require('./utils/testing-utils');
const chalk = require('chalk');
const debug = require('debug')('test-e2e-local');
const fs = require('fs');
const path = require('path');
Expand Down Expand Up @@ -301,10 +302,10 @@ async function testRNTestProject(
);

cd('..');
exec('yarn ios');
exec('npm run ios');
} else {
// android
exec('yarn android');
exec('npm run android');
}
popd();
}
Expand All @@ -329,14 +330,23 @@ async function main() {

let circleCIArtifacts = await setupCircleCIArtifacts(
// $FlowIgnoreError[prop-missing]
argv.circleCIToken,
argv.circleciToken,
branchName,
);

if (argv.target === 'RNTester') {
await testRNTester(circleCIArtifacts, onReleaseBranch);
} else {
await testRNTestProject(circleCIArtifacts);

console.warn(
chalk.yellow(`
================================================================================
NOTE: Verdaccio may still be running on after this script has finished. Please
Force Quit via Activity Monitor.
================================================================================
`),
);
}
}

Expand Down

0 comments on commit 6d7f715

Please sign in to comment.