Skip to content

Commit

Permalink
Test the Android Template with the JSC engine (#34664)
Browse files Browse the repository at this point in the history
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: #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
  • Loading branch information
vincenzovitale authored and facebook-github-bot committed Sep 12, 2022
1 parent 5198d56 commit 90e7f51
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 1 deletion.
16 changes: 15 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -674,13 +674,26 @@ jobs:
newarchitecture:
type: boolean
default: false
jsengine:
type: string
default: "Hermes"
environment:
- PROJECT_NAME: "AndroidTemplateProject"
steps:
- checkout_code_with_cache
- 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
Expand All @@ -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 >>

# -------------------------
Expand Down Expand Up @@ -1376,6 +1389,7 @@ workflows:
matrix:
parameters:
newarchitecture: [true, false]
jsengine: ["Hermes", "JSC"]
flavor: ["Debug", "Release"]
- test_buck
- test_ios_template:
Expand Down
53 changes: 53 additions & 0 deletions scripts/set-rn-engine.js
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit 90e7f51

Please sign in to comment.