Skip to content

Commit 7bf91d5

Browse files
Merge branch 'master' into event-improvements
2 parents 4c6961e + 29613a0 commit 7bf91d5

974 files changed

Lines changed: 47240 additions & 31935 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.appveyor/config.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ install:
2121
- set PATH=%PATH%;"%ANDROID_HOME%\tools\bin"
2222

2323
- yes 2> nul | sdkmanager --licenses > nul
24-
- sdkmanager "system-images;android-19;google_apis;armeabi-v7a"
25-
- sdkmanager "platforms;android-%ANDROID_BUILD_VERSION%"
26-
- sdkmanager "build-tools;%ANDROID_TOOLS_VERSION%"
27-
- sdkmanager "add-ons;addon-google_apis-google-23"
28-
- sdkmanager "extras;android;m2repository"
24+
- yes 2> nul | sdkmanager "system-images;android-19;google_apis;armeabi-v7a"
25+
- yes 2> nul | sdkmanager "platforms;android-%ANDROID_BUILD_VERSION%"
26+
- yes 2> nul | sdkmanager "build-tools;%ANDROID_TOOLS_VERSION%"
27+
- yes 2> nul | sdkmanager "add-ons;addon-google_apis-google-23"
28+
- yes 2> nul | sdkmanager "extras;android;m2repository"
2929

3030
- appveyor DownloadFile "%NDK_TOOLS_URL%" -FileName "%TMP%/ndk.zip"
3131
- 7z x "%TMP%/ndk.zip" -o"%ANDROID_HOME%" > nul

.circleci/DockerTests.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Dockerfile Tests
2+
3+
This is a high-level overview of the test configuration using Docker. It explains how to run the tests locally.
4+
5+
## Docker Installation
6+
7+
It is required to have Docker running on your machine in order to build and run the tests in the Dockerfiles.
8+
See <https://docs.docker.com/engine/installation/> for more information on how to install.
9+
10+
## Convenience Yarn Run Scripts
11+
12+
We have added a number of default run scripts to the `package.json` file to simplify building and running your tests.
13+
14+
`yarn run docker-setup-android` - Pulls down the base android docker image used for running the tests
15+
16+
`yarn run docker-build-android` - Builds the docker image used to run the tests
17+
18+
`yarn run test-android-run-unit` - Runs all the unit tests that have been built in the latest reactnativeci/android docker image (note: you need to run test-android-build before executing this if the image does not exist it will fail)
19+
20+
`yarn run test-android-run-instrumentation` - Runs all the instrumentation tests that have been built in the latest reactnativeci/android docker image. If the image does not exist, run `test-android-build` before. You can also pass additional flags to filter which tests instrumentation tests are run. Ex: `yarn run test-android-run-instrumentation -- --filter=TestIdTestCase` to only run the TestIdTestCase instrumentation test. See below for more information
21+
on the instrumentation test flags.
22+
23+
`yarn run test-android-run-e2e` - Runs all the end to end tests that have been built in the latest reactnativeci/android docker image (note: you need to run test-android-build before executing this if the image does not exist it will fail)
24+
25+
`yarn run test-android-unit` - Builds and runs the Android unit tests.
26+
27+
`yarn run test-android-instrumentation` - Builds and runs the Android instrumentation tests.
28+
29+
`yarn run test-android-e2e` - Builds and runs the Android end to end tests.
30+
31+
## Detailed Android Setup
32+
33+
There are two Dockerfiles for use with the Android codebase.
34+
35+
The `Dockerfile.android-base` contains all the necessary prerequisites required to run the React Android tests. It is
36+
separated out into a separate Dockerfile because these are dependencies that rarely change and also because it is quite
37+
a beastly image since it contains all the Android dependencies for running Android and the emulators (~9GB).
38+
39+
The good news is you should rarely have to build or pull down the base image! All iterative code updates happen as
40+
part of the `Dockerfile.android` image build.
41+
42+
So step one...
43+
44+
`docker pull reactnativecommunity/react-native-android:latest`
45+
46+
This will take quite some time depending on your connection and you need to ensure you have ~10GB of free disk space.
47+
48+
Once this is done, you can run tests locally by executing two simple commands:
49+
50+
1. `docker build -t reactnativeci/android -f ./.circleci/Dockerfiles/Dockerfile.android .`
51+
2. `docker run --cap-add=SYS_ADMIN -it reactnativeci/android bash .circleci/Dockerfiles/scripts/run-android-docker-unit-tests.sh`
52+
53+
> Note: `--cap-add=SYS_ADMIN` flag is required for the `.circleci/Dockerfiles/scripts/run-android-docker-unit-tests.sh` and
54+
`.circleci/Dockerfiles/scripts/run-android-docker-instrumentation-tests.sh` in order to allow the remounting of `/dev/shm` as writeable
55+
so the `buck` build system may write temporary output to that location
56+
57+
Every time you make any modifications to the codebase, you should re-run the `docker build ...` command in order for your
58+
updates to be included in your local docker image.
59+
60+
The following shell scripts have been provided for android testing:
61+
62+
`.circleci/Dockerfiles/scripts/run-android-docker-unit-tests.sh` - Runs the standard android unit tests
63+
64+
`.circleci/Dockerfiles/scripts/run-android-docker-instrumentation-tests.sh` - Runs the Android instrumentation tests on the emulator. *Note* that these
65+
tests take quite some time to run so there are various flags you can pass in order to filter which tests are run (see below)
66+
67+
`.circleci/Dockerfiles/scripts/run-ci-e2e-tests.sh` - Runs the android end to end tests
68+
69+
#### .circleci/Dockerfiles/scripts/run-android-docker-instrumentation-tests.sh
70+
71+
The instrumentation test script accepts the following flags in order to customize the execution of the tests:
72+
73+
`--filter` - A regex that filters which instrumentation tests will be run. (Defaults to .*)
74+
75+
`--package` - Name of the java package containing the instrumentation tests (Defaults to com.facebook.react.tests)
76+
77+
`--path` - Path to the directory containing the instrumentation tests. (Defaults to ./ReactAndroid/src/androidTest/java/com/facebook/react/tests)
78+
79+
`--retries` - Number of times to retry a failed test before declaring a failure (Defaults to 2)
80+
81+
For example, if locally you only wanted to run the InitialPropsTestCase, you could do the following:
82+
83+
`docker run --cap-add=SYS_ADMIN -it reactnativeci/android bash .circleci/Dockerfiles/scripts/run-android-docker-instrumentation-tests.sh --filter="InitialPropsTestCase"`
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# image. Ideally, this image would be rebuilt with any new commit to the master
1010
# branch. Doing so will catch issues such as BUCK failing to fetch dependencies
1111
# or run tests, as well as unit test failures.
12-
FROM reactnativeci/android-base:latest
12+
FROM react-native-community/react-native
1313

1414
LABEL Description="This image prepares and runs React Native's Android tests."
1515
LABEL maintainer="Héctor Ramos <hector@fb.com>"

ContainerShip/scripts/run-android-ci-instrumentation-tests.js renamed to .circleci/Dockerfiles/scripts/run-android-ci-instrumentation-tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ return async.mapSeries(testClasses, (clazz, callback) => {
8686
}
8787

8888
return async.retry(test_opts.RETRIES, (retryCb) => {
89-
const test_process = child_process.spawn('./ContainerShip/scripts/run-instrumentation-tests-via-adb-shell.sh', [test_opts.PACKAGE, clazz], {
89+
const test_process = child_process.spawn('./.circleci/Dockerfiles/scripts/run-instrumentation-tests-via-adb-shell.sh', [test_opts.PACKAGE, clazz], {
9090
stdio: 'inherit',
9191
});
9292

ContainerShip/scripts/run-android-docker-instrumentation-tests.sh renamed to .circleci/Dockerfiles/scripts/run-android-docker-instrumentation-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ node cli.js bundle --platform android --dev true --entry-file ReactAndroid/src/a
3838
source ./scripts/android-setup.sh && NO_BUCKD=1 retry3 buck install ReactAndroid/src/androidTest/buck-runner:instrumentation-tests --config build.threads=1
3939

4040
# run installed apk with tests
41-
node ./ContainerShip/scripts/run-android-ci-instrumentation-tests.js "$*"
41+
node ./.circleci/Dockerfiles/scripts/run-android-ci-instrumentation-tests.js "$*"
4242
exit $?

ContainerShip/scripts/run-android-docker-unit-tests.sh renamed to .circleci/Dockerfiles/scripts/run-android-docker-unit-tests.sh

File renamed without changes.
File renamed without changes.

ContainerShip/scripts/run-instrumentation-tests-via-adb-shell.sh renamed to .circleci/Dockerfiles/scripts/run-instrumentation-tests-via-adb-shell.sh

File renamed without changes.

0 commit comments

Comments
 (0)