diff --git a/scripts/release-testing/test-e2e-local.js b/scripts/release-testing/test-e2e-local.js index 0b99a10c56b..8c76e810fb3 100644 --- a/scripts/release-testing/test-e2e-local.js +++ b/scripts/release-testing/test-e2e-local.js @@ -155,27 +155,18 @@ async function testRNTesterAndroid( // Github Actions zips all the APKs in a single archive console.info('Start Downloading APK'); const rntesterAPKURL = - await ciArtifacts.artifactURLForHermesRNTesterAPK(emulatorArch); + argv.hermes === true + ? await ciArtifacts.artifactURLForHermesRNTesterAPK(emulatorArch) + : await ciArtifacts.artifactURLForJSCRNTesterAPK(emulatorArch); + ciArtifacts.downloadArtifact(rntesterAPKURL, downloadPath); const unzipFolder = path.join(ciArtifacts.baseTmpPath(), 'rntester-apks'); exec(`rm -rf ${unzipFolder}`); exec(`unzip ${downloadPath} -d ${unzipFolder}`); - let apkPath; - if (argv.hermes === true) { - apkPath = path.join( - unzipFolder, - 'hermes', - 'release', - `app-hermes-${emulatorArch}-release.apk`, - ); - } else { - apkPath = path.join( - unzipFolder, - 'jsc', - 'release', - `app-jsc-${emulatorArch}-release.apk`, - ); - } + let apkPath = path.join( + unzipFolder, + `app-${argv.hermes === true ? 'hermes' : 'jsc'}-${emulatorArch}-release.apk`, + ); exec(`adb install ${apkPath}`); } else { @@ -298,14 +289,9 @@ async function testRNTestProject( cd('RNTestProject'); - // When using CircleCI artifacts, the CI will zip maven local into a - // /tmp/maven-local subfolder struct. - // When we generate the project manually, there is no such structure. - const expandedMavenLocal = - ciArtifacts == null ? mavenLocalPath : `${mavenLocalPath}/maven-local`; // need to do this here so that Android will be properly setup either way exec( - `echo "react.internal.mavenLocalRepo=${expandedMavenLocal}" >> android/gradle.properties`, + `echo "react.internal.mavenLocalRepo=${mavenLocalPath}" >> android/gradle.properties`, ); // Only build the simulator architecture. CI is however generating only that one. diff --git a/scripts/release-testing/utils/github-actions-utils.js b/scripts/release-testing/utils/github-actions-utils.js index 1efd6353852..2089acb337c 100644 --- a/scripts/release-testing/utils/github-actions-utils.js +++ b/scripts/release-testing/utils/github-actions-utils.js @@ -60,7 +60,7 @@ const reactNativeRepo = 'https://api.github.com/repos/facebook/react-native/'; const reactNativeActionsURL = `${reactNativeRepo}actions/runs`; async function _getActionRunsOnBranch() /*: Promise */ { - const url = `${reactNativeActionsURL}?branch=${branch}`; + const url = `${reactNativeActionsURL}?branch=${branch}&per_page=100`; const options = { method: 'GET', headers: ciHeaders, @@ -81,7 +81,7 @@ async function _getActionRunsOnBranch() /*: Promise */ { } async function _getArtifacts(run_id /*: number */) /*: Promise */ { - const url = `${reactNativeActionsURL}/${run_id}/artifacts`; + const url = `${reactNativeActionsURL}/${run_id}/artifacts?per_page=100`; const options = { method: 'GET', headers: ciHeaders, @@ -121,11 +121,26 @@ async function initialize( 'X-GitHub-Api-Version': '2022-11-28', }; - const testAllWorkflow = (await _getActionRunsOnBranch()).workflow_runs + const testAllWorkflows = (await _getActionRunsOnBranch()).workflow_runs .filter(w => w.name === 'Test All') - .sort((a, b) => (a.created_at > b.created_at ? -1 : 1))[0]; + .sort((a, b) => { + // Date.getTime is needed to make Flow happy with arithmetic + return ( + new Date(b.created_at).getTime() - new Date(a.created_at).getTime() + ); + }); - artifacts = await _getArtifacts(testAllWorkflow.id); + if (testAllWorkflows.length === 0) { + console.error('No Test-All workflow found'); + process.exit(1); + } + + console.log(`\nUsing github workflow run ${testAllWorkflows[0].run_number}`); + console.log( + `https://github.com/facebook/react-native/actions/runs/${testAllWorkflows[0].id}\n`, + ); + + artifacts = await _getArtifacts(testAllWorkflows[0].id); } function downloadArtifact( @@ -146,37 +161,37 @@ function downloadArtifact( async function artifactURLForJSCRNTesterAPK( emulatorArch /*: string */, ) /*: Promise */ { - const url = artifacts.artifacts.filter(a => a.name === 'rntester-apk')[0] - .archive_download_url; - return Promise.resolve(url); + return getArtifactURL('rntester-jsc-release'); } async function artifactURLForHermesRNTesterAPK( emulatorArch /*: string */, ) /*: Promise */ { - const url = artifacts.artifacts.filter(a => a.name === 'rntester-apk')[0] - .archive_download_url; - return Promise.resolve(url); + return getArtifactURL('rntester-hermes-release'); } async function artifactURLForMavenLocal() /*: Promise */ { - const url = artifacts.artifacts.filter(a => a.name === 'maven-local')[0] - .archive_download_url; - return Promise.resolve(url); + return getArtifactURL('maven-local'); +} + +async function getArtifactURL( + artifactName /*: string */, +) /*: Promise */ { + const filteredUrls = artifacts.artifacts.filter(a => a.name === artifactName); + + if (filteredUrls.length === 0) { + console.error(`No artifact found with name ${artifactName}`); + process.exit(1); + } + return filteredUrls[0].archive_download_url; } async function artifactURLHermesDebug() /*: Promise */ { - const url = artifacts.artifacts.filter( - a => a.name === 'hermes-darwin-bin-Debug', - )[0].archive_download_url; - return Promise.resolve(url); + return getArtifactURL('hermes-darwin-bin-Debug'); } async function artifactURLForReactNative() /*: Promise */ { - const url = artifacts.artifacts.filter( - a => a.name === 'react-native-package', - )[0].archive_download_url; - return Promise.resolve(url); + return getArtifactURL('react-native-package'); } function baseTmpPath() /*: string */ { diff --git a/scripts/release-testing/utils/testing-utils.js b/scripts/release-testing/utils/testing-utils.js index c5be9657c51..9f29fe14cda 100644 --- a/scripts/release-testing/utils/testing-utils.js +++ b/scripts/release-testing/utils/testing-utils.js @@ -230,11 +230,6 @@ async function downloadArtifacts( console.info(`Unzipping into ${mavenLocalPath}`); exec(`unzip -oq ${mavenLocalZipPath} -d ${mavenLocalPath}`); - // Github Actions are zipping a zip. Needs to move it to the right place and unzip it again - exec(`rm -rf ${mavenLocalZipPath}`); - exec(`mv ${mavenLocalPath}/maven-local.zip ${mavenLocalZipPath}`); - exec(`unzip -oq ${mavenLocalZipPath} -d ${mavenLocalPath}`); - console.info('\n[Download] Hermes'); ciArtifacts.downloadArtifact(hermesURLZip, hermesPathZip); exec(`unzip ${hermesPathZip} -d ${ciArtifacts.baseTmpPath()}/hermes`);