Skip to content

Commit

Permalink
Finish up script and run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
Riccardo Cipolleschi committed Jun 20, 2023
1 parent ed15470 commit e114e24
Show file tree
Hide file tree
Showing 3 changed files with 104 additions and 101 deletions.
8 changes: 4 additions & 4 deletions scripts/test-e2e-local-clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,25 +44,25 @@ if (isPackagerRunning() === 'running') {
console.info('\n** Cleaning Gradle build artifacts **\n');
exec('./gradlew clean');
exec('rm -rf /tmp/maven-local');
exec('rm -rf /tmp/hermes-ios-debug.tar.gz');
exec('rm -rf /tmp/maven-local.zip');
exec('rm -rf /tmp/rntester.apk');

// iOS
console.info('\n** Nuking the derived data folder **\n');
exec('rm -rf ~/Library/Developer/Xcode/DerivedData');

console.info('\n** Removing the hermes-engine pod cache **\n');
exec('rm -rf ~/Library/Caches/CocoaPods/Pods/External/hermes-engine');
exec('rm -rf /tmp/hermes-ios-debug.tar.gz');

// RNTester Pods
console.info('\n** Removing the RNTester Pods **\n');
exec('rm -rf packages/rn-tester/Pods');

// I'm not sure we want to also remove the lock file
// exec('rm -rf packages/rn-tester/Podfile.lock');

// RNTestProject
console.info('\n** Removing the RNTestProject folder **\n');
exec('rm -rf /tmp/RNTestProject');
exec('rm -rf /tmp/packaged-react-native.tar.gz');

// final clean up
console.info('\n** Final git level wipe **\n');
Expand Down
123 changes: 52 additions & 71 deletions scripts/test-e2e-local.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ const argv = yargs
required: true,
}).argv;

async function main () {
async function main() {
/*
* see the test-local-e2e.js script for clean up process
*/
* see the test-local-e2e.js script for clean up process
*/

// command order: we ask the user to select if they want to test RN tester
// or RNTestProject
Expand All @@ -73,19 +73,19 @@ async function main () {

// let's check if Metro is already running, if it is let's kill it and start fresh
if (isPackagerRunning() === 'running') {
exec("lsof -i :8081 | grep LISTEN | /usr/bin/awk '{print $2}' | xargs kill");
exec(
"lsof -i :8081 | grep LISTEN | /usr/bin/awk '{print $2}' | xargs kill",
);
}

const branchName = "0.72-stable"
/*exec('git rev-parse --abbrev-ref HEAD', {
silent: true,
})
.stdout.trim();
*/
const branchName = exec('git rev-parse --abbrev-ref HEAD', {
silent: true,
}).stdout.trim();

const onReleaseBranch = branchName.endsWith('-stable');

const circleCIArtifacts = new CircleCIArtifacts(argv.circleciToken);
await circleCIArtifacts.initialize(branchName)
await circleCIArtifacts.initialize(branchName);

if (argv.target === 'RNTester') {
// FIXME: make sure that the commands retains colors
Expand All @@ -100,7 +100,6 @@ async function main () {
} version of RNTester iOS with the new Architecture enabled`,
);


// remember that for this to be successful
// you should have run bundle install once
// in your local setup
Expand All @@ -113,20 +112,23 @@ async function main () {
// download hermes source code from manifold
circleCIArtifacts.downloadArtifact(hermesURL, hermesPath);
console.info(`Downloaded Hermes in ${hermesPath}`);
exec(`HERMES_ENGINE_TARBALL_PATH=${hermesPath} RCT_NEW_ARCH_ENABLED=1 bundle exec pod install --ansi`)
exec(
`HERMES_ENGINE_TARBALL_PATH=${hermesPath} RCT_NEW_ARCH_ENABLED=1 bundle exec pod install --ansi`,
);
} else {
exec(
`USE_HERMES=0 CI=${onReleaseBranch} RCT_NEW_ARCH_ENABLED=1 bundle exec pod install --ansi`,
);
}


// if everything succeeded so far, we can launch Metro and the app
// start the Metro server in a separate window
launchPackagerInSeparateWindow(pwd());

// launch the app on iOS simulator
exec('npx react-native run-ios --scheme RNTester --simulator "iPhone 14"');
exec(
'npx react-native run-ios --scheme RNTester --simulator "iPhone 14"',
);
} else {
// we do the android path here

Expand All @@ -138,16 +140,16 @@ async function main () {
} version of RNTester Android with the new Architecture enabled`,
);

const downloadPath = "/tmp/rntester.apk";
const downloadPath = '/tmp/rntester.apk';

const rntesterAPKURL = argv.hermes ?
await circleCIArtifacts.artifactURLForHermesRNTesterAPK() :
await circleCIArtifacts.artifactURLForJSCRNTesterAPK()
const rntesterAPKURL = argv.hermes
? await circleCIArtifacts.artifactURLForHermesRNTesterAPK()
: await circleCIArtifacts.artifactURLForJSCRNTesterAPK();

console.info("Start Downloading APK");
console.info('Start Downloading APK');
circleCIArtifacts.downloadArtifact(rntesterAPKURL, downloadPath);

exec(`adb install ${downloadPath}`)
exec(`adb install ${downloadPath}`);

// launch the app on Android simulator
// TODO: we should find a way to make it work like for iOS, via npx react-native run-android
Expand All @@ -174,11 +176,12 @@ async function main () {
// base setup required (specular to publish-npm.js)

// we need to add the unique timestamp to avoid npm/yarn to use some local caches
const baseVersion = require('../packages/react-native/package.json').version;
const baseVersion =
require('../packages/react-native/package.json').version;

// in local testing, 1000.0.0 mean we are on main, every other case means we are
// working on a release version
const buildType = baseVersion !== '1000.0.0' ? 'release' : 'dry-run';
// // in local testing, 1000.0.0 mean we are on main, every other case means we are
// // working on a release version
// const buildType = baseVersion !== '1000.0.0' ? 'release' : 'dry-run';

const dateIdentifier = new Date()
.toISOString()
Expand All @@ -188,56 +191,33 @@ async function main () {

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

// this is needed to generate the Android artifacts correctly
const exitCode = exec(
`node scripts/set-rn-version.js --to-version ${releaseVersion} --build-type ${buildType}`,
).code;

if (exitCode !== 0) {
console.error(
`Failed to set the RN version. Version ${releaseVersion} is not valid for ${buildType}`,
);
process.exit(exitCode);
}

// Generate native files for Android
generateAndroidArtifacts(releaseVersion);
// generateAndroidArtifacts(releaseVersion);
const mavenLocalURL = await circleCIArtifacts.artifactURLForMavenLocal();
const packagedReactNativeURL =
await circleCIArtifacts.artifactURLForPackagedReactNative();
const hermesURL = await circleCIArtifacts.artifactURLHermesDebug();

const mavenLocalPath = '/tmp/maven-local.zip';
const packagedReactNativePath = '/tmp/packaged-react-native.tar.gz';
const hermesPath = '/tmp/hermes-ios-debug.tar.gz';

console.info('[Download] Maven Local Artifacts');
circleCIArtifacts.downloadArtifact(mavenLocalURL, mavenLocalPath);
console.info('[Download] Packaged React Native');
circleCIArtifacts.downloadArtifact(
packagedReactNativeURL,
packagedReactNativePath,
);
console.info('[Download] Hermes');
circleCIArtifacts.downloadArtifact(hermesURL, hermesPath);

// Setting up generating native iOS (will be done later)
const repoRoot = pwd();
const reactNativePackagePath = `${repoRoot}/packages/react-native`;
const jsiFolder = `${reactNativePackagePath}/ReactCommon/jsi`;
const hermesCoreSourceFolder = `${reactNativePackagePath}/sdks/hermes`;

if (!fs.existsSync(hermesCoreSourceFolder)) {
console.info('The Hermes source folder is missing. Downloading...');
downloadHermesSourceTarball();
expandHermesSourceTarball();
}

// need to move the scripts inside the local hermes cloned folder
// cp sdks/hermes-engine/utils/*.sh <your_hermes_checkout>/utils/.
cp(
`${reactNativePackagePath}/sdks/hermes-engine/utils/*.sh`,
`${reactNativePackagePath}/sdks/hermes/utils/.`,
);

// for this scenario, we only need to create the debug build
// (env variable PRODUCTION defines that podspec side)
const buildTypeiOSArtifacts = 'Debug';

// the android ones get set into /private/tmp/maven-local
const localMavenPath = '/private/tmp/maven-local';

// Generate native files for iOS
const tarballOutputPath = generateiOSArtifacts(
jsiFolder,
hermesCoreSourceFolder,
buildTypeiOSArtifacts,
localMavenPath,
);

const localNodeTGZPath = `${reactNativePackagePath}/react-native-${releaseVersion}.tgz`;
exec(`cp ${packagedReactNativePath} ${localNodeTGZPath}`);
updateTemplatePackage({
'react-native': `file:${localNodeTGZPath}`,
});
Expand All @@ -252,18 +232,20 @@ async function main () {
);

cd('RNTestProject');

// TODO: test whether that's works. On the local test it doesn't, but I'm forcing a version which is weird.
exec('yarn install');

// need to do this here so that Android will be properly setup either way
exec(
'echo "REACT_NATIVE_MAVEN_LOCAL_REPO=/private/tmp/maven-local" >> android/gradle.properties',
`echo "REACT_NATIVE_MAVEN_LOCAL_REPO=${mavenLocalPath}" >> android/gradle.properties`,
);

// doing the pod install here so that it's easier to play around RNTestProject
cd('ios');
exec('bundle install');
exec(
`HERMES_ENGINE_TARBALL_PATH=${tarballOutputPath} USE_HERMES=${
`HERMES_ENGINE_TARBALL_PATH=${hermesPath} USE_HERMES=${
argv.hermes ? 1 : 0
} bundle exec pod install --ansi`,
);
Expand All @@ -281,4 +263,3 @@ async function main () {
}

main();
// exit(0);

0 comments on commit e114e24

Please sign in to comment.