diff --git a/.flowconfig b/.flowconfig index 789fe76ba..113b86535 100644 --- a/.flowconfig +++ b/.flowconfig @@ -42,6 +42,12 @@ # Ignore Website .*/website/.* +# Ignore generators +.*/local-cli/generator.* + +# Ignore BUCK generated folders +.*\.buckd/ + .*/node_modules/is-my-json-valid/test/.*\.json .*/node_modules/iconv-lite/encodings/tables/.*\.json .*/node_modules/y18n/test/.*\.json @@ -59,6 +65,7 @@ .*/node_modules/isemail/.*\.json .*/node_modules/tr46/.*\.json + [include] [libs] diff --git a/circle.yml b/circle.yml index 74a18fc0f..8efc7b821 100644 --- a/circle.yml +++ b/circle.yml @@ -76,7 +76,8 @@ test: - ./gradlew :ReactAndroid:installDebugAndroidTest - source scripts/circle-ci-android-setup.sh && retry3 ./scripts/run-android-instrumentation-tests.sh com.facebook.react.tests.gradle - - ./scripts/e2e-test.sh --packager + # JS and Android e2e test + - ./scripts/e2e-test.sh --packager --android # testing docs generation is not broken - cd website && node ./server/generate.js diff --git a/local-cli/generator-android/templates/src/app/BUCK b/local-cli/generator-android/templates/src/app/BUCK new file mode 100644 index 000000000..38d334d86 --- /dev/null +++ b/local-cli/generator-android/templates/src/app/BUCK @@ -0,0 +1,66 @@ +import re + +# To learn about Buck see [Docs](https://buckbuild.com/). +# To run your application with Buck: +# - install Buck +# - `npm start` - to start the packager +# - `cd android` +# - `cp ~/.android/debug.keystore keystores/debug.keystore` +# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck +# - `buck install -r android/app` - compile, install and run application +# + +lib_deps = [] +for jarfile in glob(['libs/*.jar']): + name = 'jars__' + re.sub(r'^.*/([^/]+)\.jar$', r'\1', jarfile) + lib_deps.append(':' + name) + prebuilt_jar( + name = name, + binary_jar = jarfile, + ) + +for aarfile in glob(['libs/*.aar']): + name = 'aars__' + re.sub(r'^.*/([^/]+)\.aar$', r'\1', aarfile) + lib_deps.append(':' + name) + android_prebuilt_aar( + name = name, + aar = aarfile, + ) + +android_library( + name = 'all-libs', + exported_deps = lib_deps +) + +android_library( + name = 'app-code', + srcs = glob([ + 'src/main/java/**/*.java', + ]), + deps = [ + ':all-libs', + ':build_config', + ':res', + ], +) + +android_build_config( + name = 'build_config', + package = '<%= package %>', +) + +android_resource( + name = 'res', + res = 'src/main/res', + package = '<%= package %>', +) + +android_binary( + name = 'app', + package_type = 'debug', + manifest = 'src/main/AndroidManifest.xml', + keystore = '//android/keystores:debug', + deps = [ + ':app-code', + ], +) diff --git a/local-cli/generator-android/templates/src/app/build.gradle b/local-cli/generator-android/templates/src/app/build.gradle index bad655e7e..fe553085a 100644 --- a/local-cli/generator-android/templates/src/app/build.gradle +++ b/local-cli/generator-android/templates/src/app/build.gradle @@ -124,3 +124,10 @@ dependencies { compile "com.android.support:appcompat-v7:23.0.1" compile "com.facebook.react:react-native:+" // From node_modules } + +// Run this once to be able to run the application with BUCK +// puts all compile dependencies into folder libs for BUCK to use +task copyDownloadableDepsToLibs(type: Copy) { + from configurations.compile + into 'libs' +} diff --git a/local-cli/generator-android/templates/src/app/src/main/AndroidManifest.xml b/local-cli/generator-android/templates/src/app/src/main/AndroidManifest.xml index 7adac4f2b..3bcfaf186 100644 --- a/local-cli/generator-android/templates/src/app/src/main/AndroidManifest.xml +++ b/local-cli/generator-android/templates/src/app/src/main/AndroidManifest.xml @@ -1,7 +1,14 @@ + package="<%= package %>" + android:versionCode="1" + android:versionName="1.0"> + + + /dev/null - ../node_modules/react-native/packager/packager.sh --nonPersistent & - SERVER_PID=$! - # Start the app on the simulator - xctool -scheme EndToEndTest -sdk iphonesimulator test - ;; -"--android"*) - echo "Running an Android app" - cd android - # Make sure we installed local version of react-native - ls `basename $MARKER_ANDROID` > /dev/null - ../node_modules/react-native/packager/packager.sh --nonPersistent & - SERVER_PID=$! - # TODO Start the app and check it renders "Welcome to React Native" - echo "The Android e2e test is not implemented yet" >&2 - exit 1 - ;; -*) - echo "Please run the script with --ios, --android or --packager" >&2 - exit 1 - ;; -esac +# Iterates through all arguments and runs e2e tests for all of them one by one +# e.g. ./scripts/e2e-test.sh --packager --ios --android will run all e2e tests but will install the test app once +while test $# -gt 0 +do + case $1 in + "--packager"*) + echo "Running a basic packager test" + # Check the packager produces a bundle (doesn't throw an error) + react-native bundle --platform android --dev true --entry-file index.android.js --bundle-output android-bundle.js + # Check that flow passes + $ROOT/node_modules/.bin/flow check + ;; + "--ios"*) + echo "Running an iOS app" + cd ios + # Make sure we installed local version of react-native + ls EndToEndTest/`basename $MARKER_IOS` > /dev/null + ../node_modules/react-native/packager/packager.sh --nonPersistent & + SERVER_PID=$! + # Start the app on the simulator + xctool -scheme EndToEndTest -sdk iphonesimulator test + ;; + "--android"*) + echo "Running an Android app" + cd android + # Make sure we installed local version of react-native + ls `basename $MARKER_ANDROID` > /dev/null + ../node_modules/react-native/packager/packager.sh --nonPersistent & + SERVER_PID=$! + cp ~/.android/debug.keystore keystores/debug.keystore + ./gradlew :app:copyDownloadableDepsToLibs + buck install -r android/app + # TODO t10114777 check it renders "Welcome to React Native" + ;; + *) + echo "Please run the script with --ios, --android or --packager" >&2 + exit 1 + ;; + esac + shift +done + +exit 0