Test the Android Template with the JSC engine (#34664)

Summary:
https://www.internalfb.com/T131530362

We are testing the New App template in CircleCI.

For Android we test the combination of Debug/Release and Old/New Architecture, and always use the Hermes engine.
We don't test the JSC engines (in iOS this is already happening).

We're not automatically testing that we can create a new project with JSC, forcing release managers to do it manually.

## Changelog

[Android] [Added] - Automatic testing of the new project template with the JSC engine.

Pull Request resolved: https://github.com/facebook/react-native/pull/34664

Test Plan:
- Open the circle-ci dashboard
- Verify there are now 8 jobs adeed to the pipeline:
```
test_android_template-Debug-Hermes-false
test_android_template-Debug-Hermes-true
test_android_template-Debug-JSC-false
test_android_template-Debug-JSC-true
test_android_template-Release-Hermes-false
test_android_template-Release-Hermes-true
test_android_template-Release-JSC-false
test_android_template-Release-JSC-true
```
- Verify they are all passing.

Reviewed By: cortinico

Differential Revision: D39426388

Pulled By: vincenzovitale

fbshipit-source-id: e5d606b1cc3ace53f8dab0f7d6d7d06ab11a2b46
This commit is contained in:
Vincenzo Vitale
2022-09-12 12:33:07 -07:00
committed by Facebook GitHub Bot
parent 5198d56f28
commit 90e7f510dc
2 changed files with 68 additions and 1 deletions
+15 -1
View File
@@ -674,6 +674,9 @@ jobs:
newarchitecture:
type: boolean
default: false
jsengine:
type: string
default: "Hermes"
environment:
- PROJECT_NAME: "AndroidTemplateProject"
steps:
@@ -681,6 +684,16 @@ jobs:
- run_yarn
- attach_workspace:
at: .
- when:
condition:
equal: ["JSC", << parameters.jsengine >>]
steps:
- run:
name: Set enableHermes in buld.gradle to false
command: |
node ./scripts/set-rn-engine.js -e jsc
echo "Hermes disabled."
grep enableHermes: template/android/app/build.gradle
- run:
name: Create Android template project
@@ -692,7 +705,7 @@ jobs:
yarn
- run:
name: Build the template application for << parameters.flavor >> with New Architecture set << parameters.newarchitecture >>
name: Build the template application for << parameters.flavor >> with New Architecture set to << parameters.newarchitecture >>, and using the << parameters.jsengine>> JS engine.
command: cd /tmp/$PROJECT_NAME/android/ && ./gradlew assemble<< parameters.flavor >> -PnewArchEnabled=<< parameters.newarchitecture >>
# -------------------------
@@ -1376,6 +1389,7 @@ workflows:
matrix:
parameters:
newarchitecture: [true, false]
jsengine: ["Hermes", "JSC"]
flavor: ["Debug", "Release"]
- test_buck
- test_ios_template:
+53
View File
@@ -0,0 +1,53 @@
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
'use strict';
/**
* This script updates the engine used by React Native
*/
const {echo, exec, exit, sed} = require('shelljs');
const yargs = require('yargs');
let argv = yargs.option('e', {
alias: 'engine',
describe: 'Choose an engine',
type: 'string',
choices: ['hermes', 'jsc'],
}).argv;
const engine = argv.engine;
if (!engine) {
echo('You must specify an engine using -e');
exit(1);
}
// Change the template build.gradle
sed(
'-i',
/enableHermes:.*/,
engine === 'jsc' ? 'enableHermes: false' : 'enableHermes: true',
'template/android/app/build.gradle',
);
// Validate the hermes flag has been changed properly
const hermes =
exec(
'grep enableHermes: template/android/app/build.gradle | awk \'{split($0,a,"[:,]"); print a[2]}\'',
{silent: true},
).stdout.trim() === 'true';
if ((engine === 'jsc' && hermes) || (engine === 'hermes' && !hermes)) {
echo('Failed to update the engine in template/android/app/build.gradle');
echo('Fix the issue and try again');
exit(1);
}
exit(0);