Update test_android_template to use build_npm_package (#33068)

Summary:
I'm updating the `test_android_template` CI step to use the result of `build_npm_package` instead of sed-ing the RN version to `file:..`.
This should be more robust and will allow to install transitive deps automatically, without having to deal with separate installation steps.

This also fixes the broken CI for Android

Changelog:
[Internal] [Changed] - Update `test_android_template` to use `build_npm_package`

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

Reviewed By: ShikaSD

Differential Revision: D34083047

Pulled By: cortinico

fbshipit-source-id: de34472d5737db445cfc0d4b1c6feaf1e746bb61
This commit is contained in:
Nicola Corti
2022-02-09 08:23:43 -08:00
committed by Andrei Shikov
parent 1b2b2198e1
commit 0924a28b19
+9 -14
View File
@@ -569,20 +569,18 @@ jobs:
steps:
- checkout
- run_yarn
- attach_workspace:
at: .
- run:
name: Setup the Android Template
name: Create Android template project
command: |
REPO_ROOT=$(pwd)
PACKAGE=$(cat build/react-native-package-version)
PATH_TO_PACKAGE="$REPO_ROOT/build/$PACKAGE"
cd template
# We replace the "react-native" dependency version with file:.. so we use it from source.
sed -i 's/\"react-native\"\:.*/\"react-native\"\: \"file\:\.\.\"/g' package.json
npm add $PATH_TO_PACKAGE
npm install
# react-native-community/cli is needed as the Android template is referencing a .gradle file inside it.
npm i @react-native-community/cli
- run:
name: Bundle the latest version of ReactAndroid
command: ./gradlew :ReactAndroid:publishReleasePublicationToNpmRepository
- run:
name: Build the template application
@@ -866,11 +864,6 @@ workflows:
- build_npm_package:
# Build a release package on every untagged commit, but do not publish to npm.
publish_npm_args: --dry-run
filters:
branches:
only:
- main
- /^pull\/.*$/
- test_js:
run_disabled_tests: false
filters:
@@ -882,6 +875,8 @@ workflows:
branches:
ignore: gh-pages
- test_android_template:
requires:
- build_npm_package
filters:
branches:
ignore: gh-pages