From 10e5b0347477cc0ff8570a46800aaaabcd296834 Mon Sep 17 00:00:00 2001 From: Blake Friedman Date: Fri, 6 Dec 2024 15:00:26 +0000 Subject: [PATCH] Infra: clean out android build folder + add timing - Removes packages/react-native/ReactAndroid/build as part of the release testing steps. - Added timing information to the release testing clean step. Changelog: [Internal] Test: Ran locally --- .../release-testing/test-e2e-local-clean.js | 50 +++++++++++-------- .../release-testing/utils/testing-utils.js | 17 +++++++ 2 files changed, 46 insertions(+), 21 deletions(-) diff --git a/scripts/release-testing/test-e2e-local-clean.js b/scripts/release-testing/test-e2e-local-clean.js index 7d436ae692b..9aea7c5839e 100644 --- a/scripts/release-testing/test-e2e-local-clean.js +++ b/scripts/release-testing/test-e2e-local-clean.js @@ -30,10 +30,10 @@ */ const {VERDACCIO_STORAGE_PATH} = require('../e2e/utils/verdaccio'); -const {isPackagerRunning} = require('./utils/testing-utils'); +const {isPackagerRunning, timeBlock} = require('./utils/testing-utils'); const {exec, exit} = require('shelljs'); -console.info('\n** Starting the clean up process **\n'); +console.info('** Starting the clean up process **'); // let's check if Metro is already running, if it is let's kill it and start fresh if (isPackagerRunning() === 'running') { @@ -42,35 +42,43 @@ if (isPackagerRunning() === 'running') { } // Android -console.info('\n** Cleaning Gradle build artifacts **\n'); -exec('./gradlew clean'); -exec('rm -rf /tmp/maven-local'); -exec('rm -rf /tmp/react-native-tmp'); +timeBlock('Cleaning Gradle build artifacts', () => { + exec('./gradlew clean'); + exec('rm -rf package/react-native/ReactAndroid/build'); + exec('rm -rf /tmp/maven-local'); + exec('rm -rf /tmp/react-native-tmp'); +}); // iOS -console.info('\n** Nuking the derived data folder **\n'); -exec('rm -rf ~/Library/Developer/Xcode/DerivedData'); +timeBlock('Nuking the derived data folder', () => { + 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'); +timeBlock('Removing the hermes-engine pod cache', () => { + exec('rm -rf ~/Library/Caches/CocoaPods/Pods/External/hermes-engine'); +}); // RNTester Pods -console.info('\n** Removing the RNTester Pods **\n'); -exec('rm -rf packages/rn-tester/Pods'); +timeBlock('Removing the RNTester Pods', () => { + exec('rm -rf packages/rn-tester/Pods'); +}); // RNTestProject -console.info('\n** Removing the RNTestProject folder **\n'); -exec('rm -rf /tmp/RNTestProject'); +timeBlock('Removing the RNTestProject folder', () => { + exec('rm -rf /tmp/RNTestProject'); +}); -console.info('\n** Removing Verdaccio storage directory **\n'); -exec(`rm -rf ${VERDACCIO_STORAGE_PATH}`); +timeBlock('Removing Verdaccio storage directory', () => { + exec(`rm -rf ${VERDACCIO_STORAGE_PATH}`); +}); // final clean up -console.info('\n** Final git level wipe **\n'); -// clean unstaged changes from git -exec('git checkout -- .'); -// remove all the untracked files -exec('git clean -fdx'); +timeBlock('Final git level wipe', () => { + // clean unstaged changes from git + exec('git checkout -- .'); + // remove all the untracked files + exec('git clean -fdx'); +}); console.info( '\n** Clean up process completed\nPlease remember to run yarn install if you are planning to test again\n', diff --git a/scripts/release-testing/utils/testing-utils.js b/scripts/release-testing/utils/testing-utils.js index 9f29fe14cda..34bbbc731b5 100644 --- a/scripts/release-testing/utils/testing-utils.js +++ b/scripts/release-testing/utils/testing-utils.js @@ -21,6 +21,7 @@ const { } = require('../../releases/utils/release-utils'); const circleCIArtifactsUtils = require('./circle-ci-artifacts-utils.js'); const ghaArtifactsUtils = require('./github-actions-utils.js'); +const chalk = require('chalk'); const fs = require('fs'); // $FlowIgnore[cannot-resolve-module] const {spawn} = require('node:child_process'); @@ -367,6 +368,21 @@ async function prepareArtifacts( }; } +function timeBlock(label /*: string*/, block /*: () => void */) { + console.info(`\nā²ļø ${chalk.bold.green(label)}:\n`); + let failed = true; + const start = new Date().getTime(); + try { + block(); + failed = false; + } finally { + const delta = new Date().getTime() - start; + console.info( + `šŸ ${chalk.bold.blue(label)} → ${(delta / 1000).toFixed(0)}s to ${failed ? chalk.red('fail') : chalk.green('succeed')}.`, + ); + } +} + module.exports = { checkPackagerRunning, maybeLaunchAndroidEmulator, @@ -375,4 +391,5 @@ module.exports = { setupCircleCIArtifacts, setupGHAArtifacts, prepareArtifacts, + timeBlock, };