Skip to content

Commit

Permalink
finishing touches
Browse files Browse the repository at this point in the history
  • Loading branch information
kelset committed Sep 26, 2022
1 parent 12d9d6c commit e8ab62b
Showing 1 changed file with 59 additions and 67 deletions.
126 changes: 59 additions & 67 deletions scripts/test-e2e-local.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,20 +107,18 @@ if (argv.target === 'RNTester') {
);

// launch the app on Android simulator
pushd('packages/rn-tester');
exec('npx react-native run-android');
popd();
// TODO: we should find a way to make it work like for iOS, via npx react-native run-android
// currently, that fails with an error.

// we might not need this section if the above lines work
// // if everything succeeded so far, we can launch Metro and the app
// // start the Metro server in a separate window
// launchPackagerInSeparateWindow();
// // just to make sure that the Android up won't have troubles finding the Metro server
// exec('adb reverse tcp:8081 tcp:8081');
// // launch the app
// exec(
// 'adb shell am start -n com.facebook.react.uiapp/com.facebook.react.uiapp.RNTesterActivity',
// );
// if everything succeeded so far, we can launch Metro and the app
// start the Metro server in a separate window
launchPackagerInSeparateWindow();
// just to make sure that the Android up won't have troubles finding the Metro server
exec('adb reverse tcp:8081 tcp:8081');
// launch the app
exec(
'adb shell am start -n com.facebook.react.uiapp/com.facebook.react.uiapp.RNTesterActivity',
);
}
} else {
console.info("We're going to test a fresh new RN project");
Expand All @@ -131,7 +129,7 @@ if (argv.target === 'RNTester') {
const tmpPublishingFolder = fs.mkdtempSync(
path.join(os.tmpdir(), 'rn-publish-'),
);
echo(`The temp publishing folder is ${tmpPublishingFolder}`);
console.info(`The temp publishing folder is ${tmpPublishingFolder}`);

saveFilesToRestore(tmpPublishingFolder);

Expand All @@ -146,68 +144,62 @@ if (argv.target === 'RNTester') {

const releaseVersion = `${baseVersion}-${dateIdentifier}`;

// need to put it into into a try finally to ensure that we clean up the state
try {
// this is needed to generate the Android artifacts correctly
exec(`node scripts/set-rn-version.js --to-version ${releaseVersion}`).code;
// this is needed to generate the Android artifacts correctly
exec(`node scripts/set-rn-version.js --to-version ${releaseVersion}`).code;

// Generate native files (Android only for now)
generateAndroidArtifacts(releaseVersion, tmpPublishingFolder);
// Generate native files (Android only for now)
generateAndroidArtifacts(releaseVersion, tmpPublishingFolder);

// create locally the node module
exec('npm pack');
// create locally the node module
exec('npm pack');

const localNodeTGZPath = `${pwd()}/react-native-${releaseVersion}.tgz`;
exec(`node scripts/set-rn-template-version.js "file:${localNodeTGZPath}"`);
const localNodeTGZPath = `${pwd()}/react-native-${releaseVersion}.tgz`;
exec(`node scripts/set-rn-template-version.js "file:${localNodeTGZPath}"`);

const repoRoot = pwd();
const repoRoot = pwd();

pushd('/tmp/');
// need to avoid the pod install step because it will fail! (see above)
exec(
`node ${repoRoot}/cli.js init RNTestProject --template ${repoRoot} --skip-install`,
);
pushd('/tmp/');
// need to avoid the pod install step because it will fail! (see above)
exec(
`node ${repoRoot}/cli.js init RNTestProject --template ${repoRoot} --skip-install`,
);

cd('RNTestProject');
exec('yarn install');

if (argv.platform === 'iOS') {
// if we want iOS, we need to do pod install - but with a trick
cd('ios');
exec('bundle install');

cd('RNTestProject');
exec('yarn install');

if (argv.platform === 'iOS') {
// if we want iOS, we need to do pod install - but with a trick
cd('ios');
exec('bundle install');

// TODO: we should be able to also use HERMES_ENGINE_TARBALL_PATH
// if we can make RNTester step generate it already so that it gets reused

// need to discern if it's main branch or release branch
if (baseVersion === '1000.0.0') {
// main branch
exec(
`USE_HERMES=${argv.hermes ? 1 : 0} bundle exec pod install --ansi`,
);
} else {
// a release branch
// copy over the .hermesversion file from react-native core into the RNTestProject
exec(`cp -f ${repoRoot}/sdks/.hermesversion .`);
exec(
`CI=true USE_HERMES=${
argv.hermes ? 1 : 0
} bundle exec pod install --ansi`,
);
}
cd('..');
exec('yarn ios');
// TODO: we should be able to also use HERMES_ENGINE_TARBALL_PATH
// if we can make RNTester step generate it already so that it gets reused

// need to discern if it's main branch or release branch
if (baseVersion === '1000.0.0') {
// main branch
exec(`USE_HERMES=${argv.hermes ? 1 : 0} bundle exec pod install --ansi`);
} else {
// android
exec('yarn android');
// TODO: to test this, I need to apply changes on top of a release branch
// a release branch
// copy over the .hermesversion file from react-native core into the RNTestProject
exec(`cp -f ${repoRoot}/sdks/.hermesversion .`);
exec(
`CI=true USE_HERMES=${
argv.hermes ? 1 : 0
} bundle exec pod install --ansi`,
);
}
popd();
} finally {
// at the end here I most likely want to set back the rn version to baseVersion!
// for git "cleanness" reasons
exec(`node scripts/set-rn-template-version.js ${baseVersion}`);
exec(`rm -rf ${tmpPublishingFolder}`);
cd('..');
exec('yarn ios');
} else {
// android
exec('yarn android');
}
popd();

// just cleaning up the temp folder, the rest is done by the test clean script
exec(`rm -rf ${tmpPublishingFolder}`);
}

exit(0);

0 comments on commit e8ab62b

Please sign in to comment.